Major refactor #141

Merged
sim0n00ps merged 55 commits from whimsical-c4lic0/OF-DL:refactor-architecture into master 2026-02-13 00:21:58 +00:00
11 changed files with 263 additions and 189 deletions
Showing only changes of commit cd5c22d862 - Show all commits

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json;
using OF_DL.Models.Dtos.Subscriptions;
namespace OF_DL.Models.Dtos.Users;
namespace OF_DL.Models.Dtos.Common;
public class SubscribedByDataDto
{
@ -20,21 +21,24 @@ public class SubscribedByDataDto
[JsonProperty("expiredAt")] public DateTime? ExpiredAt { get; set; }
[JsonProperty("renewedAt")] public object? RenewedAt { get; set; }
[JsonProperty("renewedAt")] public DateTime? RenewedAt { get; set; }
[JsonProperty("discountFinishedAt")] public object? DiscountFinishedAt { get; set; }
[JsonProperty("discountFinishedAt")] public object? DiscountFinishedAt { get; set; } = new();
[JsonProperty("discountStartedAt")] public object? DiscountStartedAt { get; set; }
[JsonProperty("discountStartedAt")] public object? DiscountStartedAt { get; set; } = new();
[JsonProperty("status")] public string? Status { get; set; }
[JsonProperty("status")] public string Status { get; set; } = "";
[JsonProperty("isMuted")] public bool? IsMuted { get; set; }
[JsonProperty("unsubscribeReason")] public string? UnsubscribeReason { get; set; }
[JsonProperty("unsubscribeReason")] public string UnsubscribeReason { get; set; } = "";
[JsonProperty("duration")] public string? Duration { get; set; }
[JsonProperty("duration")] public string Duration { get; set; } = "";
[JsonProperty("showPostsInFeed")] public bool? ShowPostsInFeed { get; set; }
[JsonProperty("subscribes")] public List<SubscribeDto>? Subscribes { get; set; }
[JsonProperty("subscribes")] public List<SubscribeDto> Subscribes { get; set; } = [];
[JsonProperty("hasActivePaidSubscriptions")]
public bool? HasActivePaidSubscriptions { get; set; }
}

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json;
using OF_DL.Models.Dtos.Subscriptions;
namespace OF_DL.Models.Dtos.Users;
namespace OF_DL.Models.Dtos.Common;
public class SubscribedOnDataDto
{
@ -22,17 +23,17 @@ public class SubscribedOnDataDto
[JsonProperty("renewedAt")] public DateTime? RenewedAt { get; set; }
[JsonProperty("discountFinishedAt")] public object? DiscountFinishedAt { get; set; }
[JsonProperty("discountFinishedAt")] public object? DiscountFinishedAt { get; set; } = new();
[JsonProperty("discountStartedAt")] public object? DiscountStartedAt { get; set; }
[JsonProperty("discountStartedAt")] public object? DiscountStartedAt { get; set; } = new();
[JsonProperty("status")] public object? Status { get; set; }
[JsonProperty("isMuted")] public bool? IsMuted { get; set; }
[JsonProperty("unsubscribeReason")] public string? UnsubscribeReason { get; set; }
[JsonProperty("unsubscribeReason")] public string? UnsubscribeReason { get; set; } = "";
[JsonProperty("duration")] public string? Duration { get; set; }
[JsonProperty("duration")] public string Duration { get; set; } = "";
[JsonProperty("tipsSumm")] public string? TipsSumm { get; set; }
@ -46,5 +47,8 @@ public class SubscribedOnDataDto
[JsonProperty("totalSumm")] public string? TotalSumm { get; set; }
[JsonProperty("subscribes")] public List<SubscribeDto>? Subscribes { get; set; }
[JsonProperty("subscribes")] public List<SubscribeDto> Subscribes { get; set; } = [];
[JsonProperty("hasActivePaidSubscriptions")]
public bool? HasActivePaidSubscriptions { get; set; }
}

View File

@ -0,0 +1,111 @@
using Newtonsoft.Json;
using OF_DL.Models.Dtos.Common;
namespace OF_DL.Models.Dtos.Subscriptions;
public class ListItemDto
{
[JsonProperty("view")] public string View { get; set; } = "";
[JsonProperty("avatar")] public string? Avatar { get; set; }
[JsonProperty("avatarThumbs")] public AvatarThumbsDto AvatarThumbs { get; set; } = new();
[JsonProperty("header")] public string? Header { get; set; }
[JsonProperty("headerSize")] public HeaderSizeDto HeaderSize { get; set; } = new();
[JsonProperty("headerThumbs")] public HeaderThumbsDto HeaderThumbs { get; set; } = new();
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("name")] public string Name { get; set; } = "";
[JsonProperty("username")] public string? Username { get; set; }
[JsonProperty("canLookStory")] public bool? CanLookStory { get; set; }
[JsonProperty("canCommentStory")] public bool? CanCommentStory { get; set; }
[JsonProperty("hasNotViewedStory")] public bool? HasNotViewedStory { get; set; }
[JsonProperty("isVerified")] public bool? IsVerified { get; set; }
[JsonProperty("canPayInternal")] public bool? CanPayInternal { get; set; }
[JsonProperty("hasScheduledStream")] public bool? HasScheduledStream { get; set; }
[JsonProperty("hasStream")] public bool? HasStream { get; set; }
[JsonProperty("hasStories")] public bool? HasStories { get; set; }
[JsonProperty("tipsEnabled")] public bool? TipsEnabled { get; set; }
[JsonProperty("tipsTextEnabled")] public bool? TipsTextEnabled { get; set; }
[JsonProperty("tipsMin")] public int? TipsMin { get; set; }
[JsonProperty("tipsMinInternal")] public int? TipsMinInternal { get; set; }
[JsonProperty("tipsMax")] public int? TipsMax { get; set; }
[JsonProperty("canEarn")] public bool? CanEarn { get; set; }
[JsonProperty("canAddSubscriber")] public bool? CanAddSubscriber { get; set; }
[JsonProperty("subscribePrice")] public string? SubscribePrice { get; set; }
[JsonProperty("isPaywallRequired")] public bool? IsPaywallRequired { get; set; }
[JsonProperty("unprofitable")] public bool? Unprofitable { get; set; }
[JsonProperty("listsStates")] public List<ListsStateDto> ListsStates { get; set; } = [];
[JsonProperty("isMuted")] public bool? IsMuted { get; set; }
[JsonProperty("isRestricted")] public bool? IsRestricted { get; set; }
[JsonProperty("canRestrict")] public bool? CanRestrict { get; set; }
[JsonProperty("subscribedBy")] public bool? SubscribedBy { get; set; }
[JsonProperty("subscribedByExpire")] public bool? SubscribedByExpire { get; set; }
[JsonProperty("subscribedByExpireDate")] public DateTime? SubscribedByExpireDate { get; set; }
[JsonProperty("subscribedByAutoprolong")] public bool? SubscribedByAutoprolong { get; set; }
[JsonProperty("subscribedIsExpiredNow")] public bool? SubscribedIsExpiredNow { get; set; }
[JsonProperty("currentSubscribePrice")] public string? CurrentSubscribePrice { get; set; }
[JsonProperty("subscribedOn")] public bool? SubscribedOn { get; set; }
[JsonProperty("subscribedOnExpiredNow")] public bool? SubscribedOnExpiredNow { get; set; }
[JsonProperty("subscribedOnDuration")] public string SubscribedOnDuration { get; set; } = "";
[JsonProperty("canReport")] public bool? CanReport { get; set; }
[JsonProperty("canReceiveChatMessage")] public bool? CanReceiveChatMessage { get; set; }
[JsonProperty("hideChat")] public bool? HideChat { get; set; }
[JsonProperty("lastSeen")] public DateTime? LastSeen { get; set; }
[JsonProperty("isPerformer")] public bool? IsPerformer { get; set; }
[JsonProperty("isRealPerformer")] public bool? IsRealPerformer { get; set; }
[JsonProperty("subscribedByData")] public SubscribedByDataDto SubscribedByData { get; set; } = new();
[JsonProperty("subscribedOnData")] public SubscribedOnDataDto SubscribedOnData { get; set; } = new();
[JsonProperty("canTrialSend")] public bool? CanTrialSend { get; set; }
[JsonProperty("isBlocked")] public bool? IsBlocked { get; set; }
[JsonProperty("displayName")] public string DisplayName { get; set; } = "";
[JsonProperty("notice")] public string Notice { get; set; } = "";
}

View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Subscriptions;
public class ListsStateDto
{
[JsonProperty("id")] public object Id { get; set; } = new();
[JsonProperty("type")] public string Type { get; set; } = "";
[JsonProperty("name")] public string Name { get; set; } = "";
[JsonProperty("hasUser")] public bool? HasUser { get; set; }
[JsonProperty("canAddUser")] public bool? CanAddUser { get; set; }
}

View File

@ -0,0 +1,38 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Subscriptions;
public class SubscribeDto
{
[JsonProperty("id")] public object Id { get; set; } = new();
[JsonProperty("userId")] public long? UserId { get; set; }
[JsonProperty("subscriberId")] public int? SubscriberId { get; set; }
[JsonProperty("date")] public DateTime? Date { get; set; }
[JsonProperty("duration")] public int? Duration { get; set; }
[JsonProperty("startDate")] public DateTime? StartDate { get; set; }
[JsonProperty("expireDate")] public DateTime? ExpireDate { get; set; }
[JsonProperty("cancelDate")] public object CancelDate { get; set; } = new();
[JsonProperty("price")] public string? Price { get; set; }
[JsonProperty("regularPrice")] public string? RegularPrice { get; set; }
[JsonProperty("discount")] public string? Discount { get; set; }
[JsonProperty("action")] public string Action { get; set; } = "";
[JsonProperty("type")] public string Type { get; set; } = "";
[JsonProperty("offerStart")] public object OfferStart { get; set; } = new();
[JsonProperty("offerEnd")] public object OfferEnd { get; set; } = new();
[JsonProperty("isCurrent")] public bool? IsCurrent { get; set; }
}

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Subscriptions;
public class SubscriptionsDto
{
[JsonProperty("list")] public List<ListItemDto> List { get; set; } = [];
[JsonProperty("hasMore")] public bool HasMore { get; set; }
}

View File

@ -0,0 +1,10 @@
namespace OF_DL.Models.Entities.Subscriptions;
public class ListItem
{
public string Username { get; set; } = "";
public bool? IsRestricted { get; set; }
public long Id { get; set; }
}

View File

@ -0,0 +1,8 @@
namespace OF_DL.Models.Entities.Subscriptions;
public class Subscriptions
{
public List<ListItem> List { get; set; } = [];
public bool HasMore { get; set; }
}

View File

@ -0,0 +1,27 @@
using OF_DL.Models.Dtos.Subscriptions;
using OF_DL.Models.Entities.Subscriptions;
namespace OF_DL.Models.Mappers;
public static class SubscriptionsMapper
{
public static Subscriptions FromDto(SubscriptionsDto? dto)
{
Subscriptions mapped = new() { HasMore = dto?.HasMore ?? false };
if (dto?.List == null)
{
return mapped;
}
foreach (ListItemDto entry in dto.List)
{
mapped.List.Add(MapList(entry));
}
return mapped;
}
private static ListItem MapList(ListItemDto dto) =>
new() { Id = dto.Id, Username = dto.Username ?? string.Empty, IsRestricted = dto.IsRestricted };
}

View File

@ -1,159 +0,0 @@
namespace OF_DL.Models.Subscriptions;
public class Subscriptions
{
public List<List> list { get; set; }
public bool hasMore { get; set; }
public class AvatarThumbs
{
public string c50 { get; set; }
public string c144 { get; set; }
}
public class HeaderSize
{
public int? width { get; set; }
public int? height { get; set; }
}
public class HeaderThumbs
{
public string w480 { get; set; }
public string w760 { get; set; }
}
public class List
{
public string view { get; set; }
public string avatar { get; set; }
public AvatarThumbs avatarThumbs { get; set; }
public string header { get; set; }
public HeaderSize headerSize { get; set; }
public HeaderThumbs headerThumbs { get; set; }
public long id { get; set; }
public string name { get; set; }
public string username { get; set; }
public bool? canLookStory { get; set; }
public bool? canCommentStory { get; set; }
public bool? hasNotViewedStory { get; set; }
public bool? isVerified { get; set; }
public bool? canPayInternal { get; set; }
public bool? hasScheduledStream { get; set; }
public bool? hasStream { get; set; }
public bool? hasStories { get; set; }
public bool? tipsEnabled { get; set; }
public bool? tipsTextEnabled { get; set; }
public int? tipsMin { get; set; }
public int? tipsMinInternal { get; set; }
public int? tipsMax { get; set; }
public bool? canEarn { get; set; }
public bool? canAddSubscriber { get; set; }
public string? subscribePrice { get; set; }
public bool? isPaywallRequired { get; set; }
public bool? unprofitable { get; set; }
public List<ListsState> listsStates { get; set; }
public bool? isMuted { get; set; }
public bool? isRestricted { get; set; }
public bool? canRestrict { get; set; }
public bool? subscribedBy { get; set; }
public bool? subscribedByExpire { get; set; }
public DateTime? subscribedByExpireDate { get; set; }
public bool? subscribedByAutoprolong { get; set; }
public bool? subscribedIsExpiredNow { get; set; }
public string? currentSubscribePrice { get; set; }
public bool? subscribedOn { get; set; }
public bool? subscribedOnExpiredNow { get; set; }
public string subscribedOnDuration { get; set; }
public bool? canReport { get; set; }
public bool? canReceiveChatMessage { get; set; }
public bool? hideChat { get; set; }
public DateTime? lastSeen { get; set; }
public bool? isPerformer { get; set; }
public bool? isRealPerformer { get; set; }
public SubscribedByData subscribedByData { get; set; }
public SubscribedOnData subscribedOnData { get; set; }
public bool? canTrialSend { get; set; }
public bool? isBlocked { get; set; }
public string displayName { get; set; }
public string notice { get; set; }
}
public class ListsState
{
public object id { get; set; }
public string type { get; set; }
public string name { get; set; }
public bool? hasUser { get; set; }
public bool? canAddUser { get; set; }
}
public class Subscribe
{
public object id { get; set; }
public long? userId { get; set; }
public int? subscriberId { get; set; }
public DateTime? date { get; set; }
public int? duration { get; set; }
public DateTime? startDate { get; set; }
public DateTime? expireDate { get; set; }
public object cancelDate { get; set; }
public string? price { get; set; }
public string? regularPrice { get; set; }
public string? discount { get; set; }
public string action { get; set; }
public string type { get; set; }
public object offerStart { get; set; }
public object offerEnd { get; set; }
public bool? isCurrent { get; set; }
}
public class SubscribedByData
{
public string? price { get; set; }
public string? newPrice { get; set; }
public string? regularPrice { get; set; }
public string? subscribePrice { get; set; }
public int? discountPercent { get; set; }
public int? discountPeriod { get; set; }
public DateTime? subscribeAt { get; set; }
public DateTime? expiredAt { get; set; }
public DateTime? renewedAt { get; set; }
public object discountFinishedAt { get; set; }
public object discountStartedAt { get; set; }
public string status { get; set; }
public bool? isMuted { get; set; }
public string unsubscribeReason { get; set; }
public string duration { get; set; }
public bool? showPostsInFeed { get; set; }
public List<Subscribe> subscribes { get; set; }
public bool? hasActivePaidSubscriptions { get; set; }
}
public class SubscribedOnData
{
public string? price { get; set; }
public string? newPrice { get; set; }
public string? regularPrice { get; set; }
public string? subscribePrice { get; set; }
public int? discountPercent { get; set; }
public int? discountPeriod { get; set; }
public DateTime? subscribeAt { get; set; }
public DateTime? expiredAt { get; set; }
public DateTime? renewedAt { get; set; }
public object discountFinishedAt { get; set; }
public object discountStartedAt { get; set; }
public object status { get; set; }
public bool? isMuted { get; set; }
public string unsubscribeReason { get; set; }
public string duration { get; set; }
public string? tipsSumm { get; set; }
public string? subscribesSumm { get; set; }
public string? messagesSumm { get; set; }
public string? postsSumm { get; set; }
public string? streamsSumm { get; set; }
public string? totalSumm { get; set; }
public List<Subscribe> subscribes { get; set; }
public bool? hasActivePaidSubscriptions { get; set; }
}
}

View File

@ -16,6 +16,7 @@ using PurchasedDtos = OF_DL.Models.Dtos.Purchased;
using StoriesDtos = OF_DL.Models.Dtos.Stories;
using StreamsDtos = OF_DL.Models.Dtos.Streams;
using UserDtos = OF_DL.Models.Dtos.Users;
using SubscriptionsDtos = OF_DL.Models.Dtos.Subscriptions;
using ArchivedEntities = OF_DL.Models.Entities.Archived;
using HighlightEntities = OF_DL.Models.Entities.Highlights;
using ListEntities = OF_DL.Models.Entities.Lists;
@ -24,9 +25,9 @@ using PostEntities = OF_DL.Models.Entities.Posts;
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
using StoryEntities = OF_DL.Models.Entities.Stories;
using StreamEntities = OF_DL.Models.Entities.Streams;
using SubscriptionEntities = OF_DL.Models.Entities.Subscriptions;
using UserEntities = OF_DL.Models.Entities.Users;
using OF_DL.Models.Mappers;
using OF_DL.Models.Subscriptions;
using OF_DL.Widevine;
using Serilog;
using Spectre.Console;
@ -3412,49 +3413,53 @@ public class APIService(IAuthService authService, IConfigService configService,
try
{
Dictionary<string, long> users = new();
Subscriptions subscriptions = new();
SubscriptionEntities.Subscriptions subscriptions = new();
Log.Debug("Calling GetAllSubscrptions");
string? body = await BuildHeaderAndExecuteRequests(getParams, endpoint, new HttpClient());
subscriptions = JsonConvert.DeserializeObject<Subscriptions>(body);
if (subscriptions != null && subscriptions.hasMore)
SubscriptionsDtos.SubscriptionsDto? subscriptionsDto =
JsonConvert.DeserializeObject<SubscriptionsDtos.SubscriptionsDto>(body, m_JsonSerializerSettings);
subscriptions = SubscriptionsMapper.FromDto(subscriptionsDto);
if (subscriptions.HasMore)
{
getParams["offset"] = subscriptions.list.Count.ToString();
getParams["offset"] = subscriptions.List.Count.ToString();
while (true)
{
Subscriptions newSubscriptions = new();
SubscriptionEntities.Subscriptions newSubscriptions = new();
string? loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, new HttpClient());
if (!string.IsNullOrEmpty(loopbody) && (!loopbody.Contains("[]") || loopbody.Trim() != "[]"))
{
newSubscriptions =
JsonConvert.DeserializeObject<Subscriptions>(loopbody, m_JsonSerializerSettings);
SubscriptionsDtos.SubscriptionsDto? newSubscriptionsDto =
JsonConvert.DeserializeObject<SubscriptionsDtos.SubscriptionsDto>(loopbody,
m_JsonSerializerSettings);
newSubscriptions = SubscriptionsMapper.FromDto(newSubscriptionsDto);
}
else
{
break;
}
subscriptions.list.AddRange(newSubscriptions.list);
if (!newSubscriptions.hasMore)
subscriptions.List.AddRange(newSubscriptions.List);
if (!newSubscriptions.HasMore)
{
break;
}
getParams["offset"] = subscriptions.list.Count.ToString();
getParams["offset"] = subscriptions.List.Count.ToString();
}
}
foreach (Subscriptions.List subscription in subscriptions.list)
foreach (SubscriptionEntities.ListItem subscription in subscriptions.List)
{
if ((!(subscription.isRestricted ?? false) ||
((subscription.isRestricted ?? false) && includeRestricted))
&& !users.ContainsKey(subscription.username))
if ((!(subscription.IsRestricted ?? false) ||
((subscription.IsRestricted ?? false) && includeRestricted))
&& !users.ContainsKey(subscription.Username))
{
users.Add(subscription.username, subscription.id);
users.Add(subscription.Username, subscription.Id);
}
}