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
19 changed files with 446 additions and 213 deletions
Showing only changes of commit 911f98bc25 - Show all commits

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class AvatarThumbsDto
{
[JsonProperty("c50")] public string C50 { get; set; } = "";
[JsonProperty("c144")] public string C144 { get; set; } = "";
}

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class HeaderSizeDto
{
[JsonProperty("width")] public int? Width { get; set; }
[JsonProperty("height")] public int? Height { get; set; }
}

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class HeaderThumbsDto
{
[JsonProperty("w480")] public string W480 { get; set; } = "";
[JsonProperty("w760")] public string W760 { get; set; } = "";
}

View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class ListsStateDto
{
[JsonProperty("id")] public string Id { get; set; } = "";
[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.Lists;
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,40 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class SubscribedByDataDto
{
[JsonProperty("price")] public string? Price { get; set; }
[JsonProperty("newPrice")] public string? NewPrice { get; set; }
[JsonProperty("regularPrice")] public string? RegularPrice { get; set; }
[JsonProperty("subscribePrice")] public string? SubscribePrice { get; set; }
[JsonProperty("discountPercent")] public string? DiscountPercent { get; set; }
[JsonProperty("discountPeriod")] public string? DiscountPeriod { get; set; }
[JsonProperty("subscribeAt")] public DateTime? SubscribeAt { get; set; }
[JsonProperty("expiredAt")] public DateTime? ExpiredAt { get; set; }
[JsonProperty("renewedAt")] public object RenewedAt { get; set; } = new();
[JsonProperty("discountFinishedAt")] public object DiscountFinishedAt { get; set; } = new();
[JsonProperty("discountStartedAt")] public object DiscountStartedAt { get; set; } = new();
[JsonProperty("status")] public string Status { get; set; } = "";
[JsonProperty("isMuted")] public bool? IsMuted { get; set; }
[JsonProperty("unsubscribeReason")] public string UnsubscribeReason { get; set; } = "";
[JsonProperty("duration")] public string Duration { get; set; } = "";
[JsonProperty("showPostsInFeed")] public bool? ShowPostsInFeed { get; set; }
[JsonProperty("subscribes")] public List<SubscribeDto> Subscribes { get; set; } = [];
}

View File

@ -0,0 +1,54 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class SubscribedOnDataDto
{
[JsonProperty("price")] public string? Price { get; set; }
[JsonProperty("newPrice")] public string? NewPrice { get; set; }
[JsonProperty("regularPrice")] public string? RegularPrice { get; set; }
[JsonProperty("subscribePrice")] public string? SubscribePrice { get; set; }
[JsonProperty("discountPercent")] public string? DiscountPercent { get; set; }
[JsonProperty("discountPeriod")] public string? DiscountPeriod { get; set; }
[JsonProperty("subscribeAt")] public DateTime? SubscribeAt { get; set; }
[JsonProperty("expiredAt")] public DateTime? ExpiredAt { get; set; }
[JsonProperty("renewedAt")] public object RenewedAt { get; set; } = new();
[JsonProperty("discountFinishedAt")] public object DiscountFinishedAt { get; set; } = new();
[JsonProperty("discountStartedAt")] public object DiscountStartedAt { get; set; } = new();
[JsonProperty("status")] public object Status { get; set; } = new();
[JsonProperty("isMuted")] public bool? IsMuted { get; set; }
[JsonProperty("unsubscribeReason")] public string UnsubscribeReason { get; set; } = "";
[JsonProperty("duration")] public string Duration { get; set; } = "";
[JsonProperty("tipsSumm")] public string? TipsSumm { get; set; }
[JsonProperty("subscribesSumm")] public string? SubscribesSumm { get; set; }
[JsonProperty("messagesSumm")] public string? MessagesSumm { get; set; }
[JsonProperty("postsSumm")] public string? PostsSumm { get; set; }
[JsonProperty("streamsSumm")] public string? StreamsSumm { get; set; }
[JsonProperty("totalSumm")] public string? TotalSumm { get; set; }
[JsonProperty("lastActivity")] public DateTime? LastActivity { get; set; }
[JsonProperty("recommendations")] public int? Recommendations { get; set; }
[JsonProperty("subscribes")] public List<object> Subscribes { get; set; } = [];
}

View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class SubscriptionBundleDto
{
[JsonProperty("id")] public long? Id { get; set; }
[JsonProperty("discount")] public string? Discount { get; set; }
[JsonProperty("duration")] public string? Duration { get; set; }
[JsonProperty("price")] public string? Price { get; set; }
[JsonProperty("canBuy")] public bool? CanBuy { get; set; }
}

View File

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

View File

@ -0,0 +1,42 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class UserListItemDto
{
[JsonProperty("id")] public string Id { get; set; } = "";
[JsonProperty("type")] public string Type { get; set; } = "";
[JsonProperty("name")] public string Name { get; set; } = "";
[JsonProperty("usersCount")] public int? UsersCount { get; set; }
[JsonProperty("postsCount")] public int? PostsCount { get; set; }
[JsonProperty("canUpdate")] public bool? CanUpdate { get; set; }
[JsonProperty("canDelete")] public bool? CanDelete { get; set; }
[JsonProperty("canManageUsers")] public bool? CanManageUsers { get; set; }
[JsonProperty("canAddUsers")] public bool? CanAddUsers { get; set; }
[JsonProperty("canPinnedToFeed")] public bool? CanPinnedToFeed { get; set; }
[JsonProperty("isPinnedToFeed")] public bool? IsPinnedToFeed { get; set; }
[JsonProperty("canPinnedToChat")] public bool? CanPinnedToChat { get; set; }
[JsonProperty("isPinnedToChat")] public bool? IsPinnedToChat { get; set; }
[JsonProperty("order")] public string Order { get; set; } = "";
[JsonProperty("direction")] public string Direction { get; set; } = "";
[JsonProperty("users")] public List<UserListUserDto> Users { get; set; } = [];
[JsonProperty("customOrderUsersIds")] public List<object> CustomOrderUsersIds { get; set; } = [];
[JsonProperty("posts")] public List<object> Posts { get; set; } = [];
}

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class UserListUserDto
{
[JsonProperty("id")] public long? Id { get; set; }
[JsonProperty("_view")] public string View { get; set; } = "";
}

View File

@ -0,0 +1,115 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Lists;
public class UsersListDto
{
[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("subscriptionBundles")]
public List<SubscriptionBundleDto> SubscriptionBundles { get; set; } = [];
[JsonProperty("displayName")] public string DisplayName { get; set; } = "";
[JsonProperty("notice")] public string Notice { 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("promoOffers")] public List<object> PromoOffers { get; set; } = [];
}

View File

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

View File

@ -0,0 +1,8 @@
namespace OF_DL.Models.Entities.Lists;
public class UserListItem
{
public string Id { get; set; } = "";
public string Name { get; set; } = "";
}

View File

@ -0,0 +1,6 @@
namespace OF_DL.Models.Entities.Lists;
public class UsersList
{
public string Username { get; set; } = "";
}

View File

@ -1,35 +0,0 @@
namespace OF_DL.Models.Lists;
public class UserList
{
public List<List> list { get; set; }
public bool? hasMore { get; set; }
public class List
{
public string id { get; set; }
public string type { get; set; }
public string name { get; set; }
public int? usersCount { get; set; }
public int? postsCount { get; set; }
public bool? canUpdate { get; set; }
public bool? canDelete { get; set; }
public bool? canManageUsers { get; set; }
public bool? canAddUsers { get; set; }
public bool? canPinnedToFeed { get; set; }
public bool? isPinnedToFeed { get; set; }
public bool? canPinnedToChat { get; set; }
public bool? isPinnedToChat { get; set; }
public string order { get; set; }
public string direction { get; set; }
public List<User> users { get; set; }
public List<object> customOrderUsersIds { get; set; }
public List<object> posts { get; set; }
}
public class User
{
public long? id { get; set; }
public string _view { get; set; }
}
}

View File

@ -1,164 +0,0 @@
namespace OF_DL.Models.Lists;
public class UsersList
{
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 List<SubscriptionBundle> subscriptionBundles { get; set; }
public string displayName { get; set; }
public string notice { 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 List<object> promoOffers { 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 ListsState
{
public string 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 string? discountPercent { get; set; }
public string? discountPeriod { get; set; }
public DateTime? subscribeAt { get; set; }
public DateTime? expiredAt { get; set; }
public object 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 class SubscribedOnData
{
public string? price { get; set; }
public string? newPrice { get; set; }
public string? regularPrice { get; set; }
public string? subscribePrice { get; set; }
public string? discountPercent { get; set; }
public string? discountPeriod { get; set; }
public DateTime? subscribeAt { get; set; }
public DateTime? expiredAt { get; set; }
public object 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 DateTime? lastActivity { get; set; }
public int? recommendations { get; set; }
public List<object> subscribes { get; set; }
}
public class SubscriptionBundle
{
public long? id { get; set; }
public string? discount { get; set; }
public string? duration { get; set; }
public string? price { get; set; }
public bool? canBuy { get; set; }
}
}

View File

@ -0,0 +1,40 @@
using OF_DL.Models.Dtos.Lists;
using OF_DL.Models.Entities.Lists;
namespace OF_DL.Models.Mappers;
public static class UserListsMapper
{
public static UserList FromDto(UserListDto? dto)
{
UserList mapped = new() { HasMore = dto?.HasMore ?? false };
if (dto?.List == null)
{
return mapped;
}
foreach (UserListItemDto entry in dto.List)
{
mapped.List.Add(MapListItem(entry));
}
return mapped;
}
public static List<UsersList> FromDto(List<UsersListDto>? dto)
{
if (dto == null)
{
return [];
}
return dto.Select(MapUsersList).ToList();
}
private static UserListItem MapListItem(UserListItemDto dto) =>
new() { Id = dto.Id, Name = dto.Name };
private static UsersList MapUsersList(UsersListDto dto) =>
new() { Username = dto.Username };
}

View File

@ -6,7 +6,6 @@ using System.Xml.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OF_DL.Models; using OF_DL.Models;
using OF_DL.Models.Lists;
using OF_DL.Models.Messages; using OF_DL.Models.Messages;
using OF_DL.Models.Post; using OF_DL.Models.Post;
using OF_DL.Models.Purchased; using OF_DL.Models.Purchased;
@ -14,9 +13,11 @@ using OF_DL.Models.Stories;
using OF_DL.Models.Streams; using OF_DL.Models.Streams;
using OF_DL.Enumerations; using OF_DL.Enumerations;
using OF_DL.Models.Dtos.Archived; using OF_DL.Models.Dtos.Archived;
using OF_DL.Models.Dtos.Lists;
using OF_DL.Models.Dtos.Highlights; using OF_DL.Models.Dtos.Highlights;
using ArchivedModels = OF_DL.Models.Entities.Archived; using ArchivedModels = OF_DL.Models.Entities.Archived;
using HighlightEntities = OF_DL.Models.Entities.Highlights; using HighlightEntities = OF_DL.Models.Entities.Highlights;
using ListEntities = OF_DL.Models.Entities.Lists;
using OF_DL.Models.Mappers; using OF_DL.Models.Mappers;
using OF_DL.Widevine; using OF_DL.Widevine;
using Serilog; using Serilog;
@ -242,21 +243,18 @@ public class APIService(IAuthService authService, IConfigService configService,
break; break;
} }
UserList userList = JsonConvert.DeserializeObject<UserList>(body); UserListDto? userListDto = JsonConvert.DeserializeObject<UserListDto>(body);
if (userList == null) ListEntities.UserList userList = UserListsMapper.FromDto(userListDto);
{
break;
}
foreach (UserList.List l in userList.list) foreach (ListEntities.UserListItem listItem in userList.List)
{ {
if (IsStringOnlyDigits(l.id) && !lists.ContainsKey(l.name)) if (IsStringOnlyDigits(listItem.Id) && !lists.ContainsKey(listItem.Name))
{ {
lists.Add(l.name, Convert.ToInt32(l.id)); lists.Add(listItem.Name, Convert.ToInt32(listItem.Id));
} }
} }
if (userList.hasMore.Value) if (userList.HasMore)
{ {
offset += 50; offset += 50;
getParams["offset"] = Convert.ToString(offset); getParams["offset"] = Convert.ToString(offset);
@ -305,16 +303,17 @@ public class APIService(IAuthService authService, IConfigService configService,
break; break;
} }
List<UsersList>? usersList = JsonConvert.DeserializeObject<List<UsersList>>(body); List<UsersListDto>? usersListDto = JsonConvert.DeserializeObject<List<UsersListDto>>(body);
List<ListEntities.UsersList> usersList = UserListsMapper.FromDto(usersListDto);
if (usersList == null || usersList.Count <= 0) if (usersList.Count <= 0)
{ {
break; break;
} }
foreach (UsersList ul in usersList) foreach (ListEntities.UsersList ul in usersList)
{ {
users.Add(ul.username); users.Add(ul.Username);
} }
if (users.Count < 50) if (users.Count < 50)