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
20 changed files with 335 additions and 241 deletions
Showing only changes of commit 2e3f17945e - Show all commits

View File

@ -11,4 +11,6 @@ public class PreviewDto
[JsonProperty("size")] public int? Size { get; set; }
[JsonProperty("url")] public string Url { get; set; } = "";
[JsonProperty("sources")] public SourcesDto Sources { get; set; } = new();
}

View File

@ -11,4 +11,6 @@ public class SquarePreviewDto
[JsonProperty("height")] public int Height { get; set; }
[JsonProperty("size")] public long Size { get; set; }
[JsonProperty("sources")] public SourcesDto Sources { get; set; } = new();
}

View File

@ -0,0 +1,22 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Highlights;
public class HighlightMediaDto
{
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("userId")] public long UserId { get; set; }
[JsonProperty("title")] public string Title { get; set; } = "";
[JsonProperty("coverStoryId")] public long CoverStoryId { get; set; }
[JsonProperty("cover")] public string Cover { get; set; } = "";
[JsonProperty("storiesCount")] public int StoriesCount { get; set; }
[JsonProperty("createdAt")] public DateTime? CreatedAt { get; set; }
[JsonProperty("stories")] public List<StoryDto> Stories { get; set; } = [];
}

View File

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

View File

@ -0,0 +1,20 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Highlights;
public class ListItemDto
{
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("userId")] public long UserId { get; set; }
[JsonProperty("title")] public string Title { get; set; } = "";
[JsonProperty("coverStoryId")] public long CoverStoryId { get; set; }
[JsonProperty("cover")] public string Cover { get; set; } = "";
[JsonProperty("storiesCount")] public int StoriesCount { get; set; }
[JsonProperty("createdAt")] public DateTime? CreatedAt { get; set; }
}

View File

@ -0,0 +1,21 @@
using Newtonsoft.Json;
using OF_DL.Models.Dtos.Common;
namespace OF_DL.Models.Dtos.Highlights;
public class MediumDto
{
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("type")] public string Type { get; set; } = "";
[JsonProperty("convertedToVideo")] public bool ConvertedToVideo { get; set; }
[JsonProperty("canView")] public bool CanView { get; set; }
[JsonProperty("hasError")] public bool HasError { get; set; }
[JsonProperty("createdAt")] public DateTime? CreatedAt { get; set; }
[JsonProperty("files")] public FilesDto Files { get; set; } = new();
}

View File

@ -0,0 +1,24 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Dtos.Highlights;
public class StoryDto
{
[JsonProperty("id")] public long Id { get; set; }
[JsonProperty("userId")] public long UserId { get; set; }
[JsonProperty("isWatched")] public bool IsWatched { get; set; }
[JsonProperty("isReady")] public bool IsReady { get; set; }
[JsonProperty("media")] public List<MediumDto> Media { get; set; } = [];
[JsonProperty("createdAt")] public DateTime? CreatedAt { get; set; }
[JsonProperty("question")] public object Question { get; set; } = new();
[JsonProperty("canLike")] public bool CanLike { get; set; }
[JsonProperty("isLiked")] public bool IsLiked { get; set; }
}

View File

@ -0,0 +1,6 @@
namespace OF_DL.Models.Entities.Highlights;
public class HighlightMedia
{
public List<Story> Stories { get; set; } = [];
}

View File

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

View File

@ -0,0 +1,6 @@
namespace OF_DL.Models.Entities.Highlights;
public class ListItem
{
public long Id { get; set; }
}

View File

@ -0,0 +1,16 @@
using OF_DL.Models.Entities.Common;
namespace OF_DL.Models.Entities.Highlights;
public class Medium
{
public long Id { get; set; }
public string? Type { get; set; }
public bool CanView { get; set; }
public DateTime? CreatedAt { get; set; }
public Files? Files { get; set; }
}

View File

@ -0,0 +1,10 @@
namespace OF_DL.Models.Entities.Highlights;
public class Story
{
public long Id { get; set; }
public DateTime? CreatedAt { get; set; }
public List<Medium>? Media { get; set; }
}

View File

@ -1,102 +0,0 @@
using Newtonsoft.Json;
namespace OF_DL.Models.Highlights;
public class HighlightMedia
{
public long id { get; set; }
public long userId { get; set; }
public string title { get; set; }
public long coverStoryId { get; set; }
public string cover { get; set; }
public int storiesCount { get; set; }
public DateTime? createdAt { get; set; }
public List<Story> stories { get; set; }
public class Files
{
public Full full { get; set; }
public Thumb thumb { get; set; }
public Preview preview { get; set; }
public SquarePreview squarePreview { get; set; }
}
public class Full
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
public long size { get; set; }
public List<object> sources { get; set; }
}
public class Medium
{
public long id { get; set; }
public string type { get; set; }
public bool convertedToVideo { get; set; }
public bool canView { get; set; }
public bool hasError { get; set; }
public DateTime? createdAt { get; set; }
public Files files { get; set; }
}
public class Preview
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
public long size { get; set; }
public Sources sources { get; set; }
}
public class Source
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
public int duration { get; set; }
public long size { get; set; }
public Sources sources { get; set; }
}
public class Sources
{
[JsonProperty("720")] public string _720 { get; set; }
[JsonProperty("240")] public string _240 { get; set; }
public string w150 { get; set; }
public string w480 { get; set; }
}
public class SquarePreview
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
public long size { get; set; }
public Sources sources { get; set; }
}
public class Story
{
public long id { get; set; }
public long userId { get; set; }
public bool isWatched { get; set; }
public bool isReady { get; set; }
public List<Medium> media { get; set; }
public DateTime? createdAt { get; set; }
public object question { get; set; }
public bool canLike { get; set; }
public bool isLiked { get; set; }
}
public class Thumb
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
public long size { get; set; }
}
}

View File

@ -1,18 +0,0 @@
namespace OF_DL.Models.Highlights;
public class Highlights
{
public List<List> list { get; set; }
public bool hasMore { get; set; }
public class List
{
public long id { get; set; }
public long userId { get; set; }
public string title { get; set; }
public long coverStoryId { get; set; }
public string cover { get; set; }
public int storiesCount { get; set; }
public DateTime? createdAt { get; set; }
}
}

View File

@ -0,0 +1,66 @@
using OF_DL.Models.Dtos.Common;
using OF_DL.Models.Dtos.Highlights;
using OF_DL.Models.Entities.Common;
using OF_DL.Models.Entities.Highlights;
namespace OF_DL.Models.Mappers;
public static class HighlightsMapper
{
public static Highlights FromDto(HighlightsDto? dto)
{
Highlights mapped = new() { HasMore = dto?.HasMore ?? false };
if (dto?.List == null)
{
return mapped;
}
foreach (ListItemDto entry in dto.List)
{
mapped.List.Add(MapListItem(entry));
}
return mapped;
}
public static HighlightMedia FromDto(HighlightMediaDto? dto)
{
HighlightMedia mapped = new();
if (dto?.Stories == null)
{
return mapped;
}
foreach (StoryDto story in dto.Stories)
{
mapped.Stories.Add(MapStory(story));
}
return mapped;
}
private static ListItem MapListItem(ListItemDto dto) => new() { Id = dto.Id };
private static Story MapStory(StoryDto dto) =>
new() { Id = dto.Id, CreatedAt = dto.CreatedAt, Media = MapMedia(dto.Media) };
private static List<Medium>? MapMedia(List<MediumDto>? media) =>
media?.Select(MapMedium).ToList();
private static Medium MapMedium(MediumDto dto) =>
new()
{
Id = dto.Id,
Type = dto.Type,
CanView = dto.CanView,
CreatedAt = dto.CreatedAt,
Files = MapFiles(dto.Files)
};
private static Files? MapFiles(FilesDto? dto) => dto == null ? null : new Files { Full = MapFull(dto.Full) };
private static Full? MapFull(FullDto? dto) =>
dto == null ? null : new Full { Url = dto.Url };
}

View File

@ -13,11 +13,11 @@ using OF_DL.Models.Purchased;
using OF_DL.Models.Streams;
using OF_DL.Enumerations;
using OF_DL.Helpers;
using OF_DL.Models.Entities.Archived;
using ArchivedModels = OF_DL.Models.Entities.Archived;
using OF_DL.Services;
using Serilog;
using Spectre.Console;
using Constants = OF_DL.Widevine.Constants;
using WidevineConstants = OF_DL.Widevine.Constants;
namespace OF_DL;
@ -502,7 +502,8 @@ public class Program(IServiceProvider serviceProvider)
Environment.Exit(4);
}
if (!File.Exists(Path.Join(Constants.DEVICES_FOLDER, Constants.DEVICE_NAME, "device_client_id_blob")))
if (!File.Exists(Path.Join(WidevineConstants.DEVICES_FOLDER, WidevineConstants.DEVICE_NAME,
"device_client_id_blob")))
{
clientIdBlobMissing = true;
Log.Debug("clientIdBlobMissing missing");
@ -510,11 +511,12 @@ public class Program(IServiceProvider serviceProvider)
else
{
AnsiConsole.Markup("[green]device_client_id_blob located successfully![/]\n");
Log.Debug("clientIdBlobMissing found: " + File.Exists(Path.Join(Constants.DEVICES_FOLDER,
Constants.DEVICE_NAME, "device_client_id_blob")));
Log.Debug("clientIdBlobMissing found: " + File.Exists(Path.Join(WidevineConstants.DEVICES_FOLDER,
WidevineConstants.DEVICE_NAME, "device_client_id_blob")));
}
if (!File.Exists(Path.Join(Constants.DEVICES_FOLDER, Constants.DEVICE_NAME, "device_private_key")))
if (!File.Exists(Path.Join(WidevineConstants.DEVICES_FOLDER, WidevineConstants.DEVICE_NAME,
"device_private_key")))
{
devicePrivateKeyMissing = true;
Log.Debug("devicePrivateKeyMissing missing");
@ -522,8 +524,8 @@ public class Program(IServiceProvider serviceProvider)
else
{
AnsiConsole.Markup("[green]device_private_key located successfully![/]\n");
Log.Debug("devicePrivateKeyMissing found: " + File.Exists(Path.Join(Constants.DEVICES_FOLDER,
Constants.DEVICE_NAME, "device_private_key")));
Log.Debug("devicePrivateKeyMissing found: " + File.Exists(Path.Join(WidevineConstants.DEVICES_FOLDER,
WidevineConstants.DEVICE_NAME, "device_private_key")));
}
if (clientIdBlobMissing || devicePrivateKeyMissing)
@ -1272,7 +1274,7 @@ public class Program(IServiceProvider serviceProvider)
IAPIService apiService = serviceProvider.GetRequiredService<IAPIService>();
IDownloadService downloadService = serviceProvider.GetRequiredService<IDownloadService>();
ArchivedCollection archived = new();
ArchivedModels.ArchivedCollection archived = new();
await AnsiConsole.Status()
.StartAsync("[red]Getting Archived Posts[/]",

View File

@ -6,7 +6,6 @@ using System.Xml.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OF_DL.Models;
using OF_DL.Models.Highlights;
using OF_DL.Models.Lists;
using OF_DL.Models.Messages;
using OF_DL.Models.Post;
@ -15,8 +14,9 @@ using OF_DL.Models.Stories;
using OF_DL.Models.Streams;
using OF_DL.Enumerations;
using OF_DL.Models.Dtos.Archived;
using OF_DL.Models.Entities;
using OF_DL.Models.Entities.Archived;
using OF_DL.Models.Dtos.Highlights;
using ArchivedModels = OF_DL.Models.Entities.Archived;
using HighlightEntities = OF_DL.Models.Entities.Highlights;
using OF_DL.Models.Mappers;
using OF_DL.Widevine;
using Serilog;
@ -452,24 +452,25 @@ public class APIService(IAuthService authService, IConfigService configService,
else if (mediatype == MediaType.Highlights)
{
List<string> highlight_ids = new();
Highlights highlights = JsonConvert.DeserializeObject<Highlights>(body, m_JsonSerializerSettings) ??
new Highlights();
HighlightsDto? highlightsDto =
JsonConvert.DeserializeObject<HighlightsDto>(body, m_JsonSerializerSettings);
HighlightEntities.Highlights highlights = HighlightsMapper.FromDto(highlightsDto);
if (highlights.hasMore)
if (highlights.HasMore)
{
offset += 5;
getParams["offset"] = offset.ToString();
while (true)
{
Highlights newhighlights = new();
Log.Debug("Media Highlights - " + endpoint);
string? loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient());
newhighlights = JsonConvert.DeserializeObject<Highlights>(loopbody, m_JsonSerializerSettings);
HighlightsDto? newHighlightsDto =
JsonConvert.DeserializeObject<HighlightsDto>(loopbody, m_JsonSerializerSettings);
HighlightEntities.Highlights newHighlights = HighlightsMapper.FromDto(newHighlightsDto);
highlights.list.AddRange(newhighlights.list);
if (!newhighlights.hasMore)
highlights.List.AddRange(newHighlights.List);
if (!newHighlights.HasMore)
{
break;
}
@ -479,17 +480,16 @@ public class APIService(IAuthService authService, IConfigService configService,
}
}
foreach (Highlights.List list in highlights.list)
foreach (HighlightEntities.ListItem list in highlights.List)
{
if (!highlight_ids.Contains(list.id.ToString()))
if (!highlight_ids.Contains(list.Id.ToString()))
{
highlight_ids.Add(list.id.ToString());
highlight_ids.Add(list.Id.ToString());
}
}
foreach (string highlight_id in highlight_ids)
{
HighlightMedia highlightMedia = new();
Dictionary<string, string> highlight_headers =
GetDynamicHeaders("/api2/v2/stories/highlights/" + highlight_id, string.Empty);
@ -506,61 +506,61 @@ public class APIService(IAuthService authService, IConfigService configService,
using HttpResponseMessage highlightResponse = await highlight_client.SendAsync(highlight_request);
highlightResponse.EnsureSuccessStatusCode();
string highlightBody = await highlightResponse.Content.ReadAsStringAsync();
highlightMedia =
JsonConvert.DeserializeObject<HighlightMedia>(highlightBody, m_JsonSerializerSettings);
if (highlightMedia != null)
HighlightMediaDto? highlightMediaDto =
JsonConvert.DeserializeObject<HighlightMediaDto>(highlightBody, m_JsonSerializerSettings);
HighlightEntities.HighlightMedia highlightMedia = HighlightsMapper.FromDto(highlightMediaDto);
foreach (HighlightEntities.Story item in highlightMedia.Stories)
{
foreach (HighlightMedia.Story item in highlightMedia.stories)
if (item.Media != null && item.Media.Count > 0 && item.Media[0].CreatedAt.HasValue)
{
if (item.media[0].createdAt.HasValue)
{
await dbService.AddStory(folder, item.id, string.Empty, "0", false, false,
item.media[0].createdAt.Value);
await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false,
item.Media[0].CreatedAt.Value);
}
else if (item.createdAt.HasValue)
else if (item.CreatedAt.HasValue)
{
await dbService.AddStory(folder, item.id, string.Empty, "0", false, false,
item.createdAt.Value);
await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false,
item.CreatedAt.Value);
}
else
{
await dbService.AddStory(folder, item.id, string.Empty, "0", false, false,
await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false,
DateTime.Now);
}
if (item.media.Count > 0 && item.media[0].canView)
if (item.Media != null && item.Media.Count > 0 && item.Media[0].CanView)
{
foreach (HighlightMedia.Medium medium in item.media)
foreach (HighlightEntities.Medium medium in item.Media)
{
await dbService.AddMedia(folder, medium.id, item.id, item.media[0].files.full.url,
null, null, null, "Stories",
medium.type == "photo" ? "Images" :
medium.type == "video" || medium.type == "gif" ? "Videos" :
medium.type == "audio" ? "Audios" : null, false, false, null);
if (medium.type == "photo" && !configService.CurrentConfig.DownloadImages)
string storyUrl = item.Media[0].Files?.Full?.Url ?? string.Empty;
await dbService.AddMedia(folder, medium.Id, item.Id, storyUrl, null, null, null,
"Stories",
medium.Type == "photo" ? "Images" :
medium.Type == "video" || medium.Type == "gif" ? "Videos" :
medium.Type == "audio" ? "Audios" : null, false, false, null);
if (medium.Type == "photo" && !configService.CurrentConfig.DownloadImages)
{
continue;
}
if (medium.type == "video" && !configService.CurrentConfig.DownloadVideos)
if (medium.Type == "video" && !configService.CurrentConfig.DownloadVideos)
{
continue;
}
if (medium.type == "gif" && !configService.CurrentConfig.DownloadVideos)
if (medium.Type == "gif" && !configService.CurrentConfig.DownloadVideos)
{
continue;
}
if (medium.type == "audio" && !configService.CurrentConfig.DownloadAudios)
if (medium.Type == "audio" && !configService.CurrentConfig.DownloadAudios)
{
continue;
}
if (!return_urls.ContainsKey(medium.id))
if (!return_urls.ContainsKey(medium.Id) && !string.IsNullOrEmpty(storyUrl))
{
return_urls.Add(medium.id, item.media[0].files.full.url);
}
return_urls.Add(medium.Id, storyUrl);
}
}
}
@ -1361,14 +1361,14 @@ public class APIService(IAuthService authService, IConfigService configService,
}
public async Task<ArchivedCollection> GetArchived(string endpoint, string folder, StatusContext ctx)
public async Task<ArchivedModels.ArchivedCollection> GetArchived(string endpoint, string folder, StatusContext ctx)
{
Log.Debug($"Calling GetArchived - {endpoint}");
try
{
Archived archived = new();
ArchivedCollection archivedCollection = new();
ArchivedModels.Archived archived = new();
ArchivedModels.ArchivedCollection archivedCollection = new();
int post_limit = 50;
Dictionary<string, string> getParams = new()
{
@ -1406,7 +1406,7 @@ public class APIService(IAuthService authService, IConfigService configService,
archived.TailMarker);
while (true)
{
Archived newarchived = new();
ArchivedModels.Archived newarchived = new();
string? loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient());
ArchivedDto newarchivedDto =
@ -1429,7 +1429,7 @@ public class APIService(IAuthService authService, IConfigService configService,
}
}
foreach (ListItem archive in archived.List)
foreach (ArchivedModels.ListItem archive in archived.List)
{
List<long> previewids = new();
if (archive.Preview != null)
@ -1452,7 +1452,7 @@ public class APIService(IAuthService authService, IConfigService configService,
archivedCollection.ArchivedPostObjects.Add(archive);
if (archive.Media != null && archive.Media.Count > 0)
{
foreach (Medium medium in archive.Media)
foreach (ArchivedModels.Medium medium in archive.Media)
{
if (medium.Type == "photo" && !configService.CurrentConfig.DownloadImages)
{

View File

@ -9,8 +9,7 @@ using OF_DL.Models.Post;
using OF_DL.Models.Purchased;
using OF_DL.Models.Streams;
using OF_DL.Enumerations;
using OF_DL.Models.Entities;
using OF_DL.Models.Entities.Archived;
using ArchivedModels = OF_DL.Models.Entities.Archived;
using OF_DL.Utils;
using Serilog;
using Serilog.Events;
@ -1037,7 +1036,7 @@ public class DownloadService(
public async Task<bool> DownloadMessageMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Messages.Medium? messageMedia,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Medium? messageMedia,
Messages.FromUser? fromUser, Dictionary<string, long> users)
{
string path;
@ -1061,7 +1060,7 @@ public class DownloadService(
public async Task<bool> DownloadMessagePreviewMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users)
{
string path;
@ -1085,8 +1084,8 @@ public class DownloadService(
public async Task<bool> DownloadArchivedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, ListItem? messageInfo,
OF_DL.Models.Entities.Archived.Medium? messageMedia, Models.Entities.Common.Author? author,
IProgressReporter progressReporter, string? filenameFormat, ArchivedModels.ListItem? messageInfo,
ArchivedModels.Medium? messageMedia, Models.Entities.Common.Author? author,
Dictionary<string, long> users)
{
string path = "/Archived/Posts/Free";
@ -1111,7 +1110,7 @@ public class DownloadService(
public async Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users)
{
string path;
@ -1135,7 +1134,7 @@ public class DownloadService(
public async Task<bool> DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users)
{
string path;
@ -1164,7 +1163,7 @@ public class DownloadService(
IProgressReporter progressReporter,
string? filenameFormat,
Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser,
Dictionary<string, long> users)
{
@ -1194,7 +1193,7 @@ public class DownloadService(
public async Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Messages.Medium? messageMedia,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Medium? messageMedia,
Messages.FromUser? fromUser, Dictionary<string, long> users)
{
try
@ -1324,7 +1323,7 @@ public class DownloadService(
public async Task<bool> DownloadSingleMessagePreviewDRMVideo(string policy, string signature, string kvp,
string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users)
{
try
@ -1455,7 +1454,7 @@ public class DownloadService(
public async Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users)
{
try
@ -1584,7 +1583,7 @@ public class DownloadService(
public async Task<bool> DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp,
string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users)
{
try
@ -2098,7 +2097,7 @@ public class DownloadService(
public async Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo,
Messages.Medium? postMedia,
Medium? postMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users)
{
try
@ -2228,8 +2227,8 @@ public class DownloadService(
public async Task<bool> DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, ListItem? postInfo,
OF_DL.Models.Entities.Archived.Medium? postMedia,
IProgressReporter progressReporter, string? filenameFormat, ArchivedModels.ListItem? postInfo,
ArchivedModels.Medium? postMedia,
Models.Entities.Common.Author? author, Dictionary<string, long> users)
{
try
@ -2455,7 +2454,7 @@ public class DownloadService(
public async Task<DownloadResult> DownloadArchived(string username, long userId, string path,
Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
ArchivedCollection archived, IProgressReporter progressReporter)
ArchivedModels.ArchivedCollection archived, IProgressReporter progressReporter)
{
Log.Debug($"Calling DownloadArchived - {username}");
@ -2512,9 +2511,9 @@ public class DownloadService(
pssh);
}
OF_DL.Models.Entities.Archived.Medium? mediaInfo =
ArchivedModels.Medium? mediaInfo =
archived.ArchivedPostMedia.FirstOrDefault(m => m.Id == archivedKVP.Key);
ListItem? postInfo =
ArchivedModels.ListItem? postInfo =
archived.ArchivedPostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true);
isNew = await DownloadArchivedPostDRMVideo(
@ -2542,9 +2541,9 @@ public class DownloadService(
}
else
{
OF_DL.Models.Entities.Archived.Medium? mediaInfo =
ArchivedModels.Medium? mediaInfo =
archived.ArchivedPostMedia.FirstOrDefault(m => m.Id == archivedKVP.Key);
ListItem? postInfo =
ArchivedModels.ListItem? postInfo =
archived.ArchivedPostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true);
isNew = await DownloadArchivedMedia(
@ -2642,7 +2641,7 @@ public class DownloadService(
pssh);
}
Messages.Medium? mediaInfo = messages.MessageMedia.FirstOrDefault(m => m.id == messageKVP.Key);
Medium? mediaInfo = messages.MessageMedia.FirstOrDefault(m => m.id == messageKVP.Key);
List? messageInfo =
messages.MessageObjects.FirstOrDefault(p => p?.media?.Contains(mediaInfo) == true);
@ -2671,7 +2670,7 @@ public class DownloadService(
}
else
{
Messages.Medium? mediaInfo = messages.MessageMedia.FirstOrDefault(m => m.id == messageKVP.Key);
Medium? mediaInfo = messages.MessageMedia.FirstOrDefault(m => m.id == messageKVP.Key);
List? messageInfo = messages.MessageObjects.FirstOrDefault(p => p?.media?.Contains(mediaInfo) == true);
isNew = await DownloadMessageMedia(
@ -2758,7 +2757,7 @@ public class DownloadService(
$"https://onlyfans.com/api2/v2/users/media/{parsed[4]}/drm/message/{parsed[5]}?type=widevine",
pssh);
Messages.Medium? mediaInfo =
Medium? mediaInfo =
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.id == kvp.Key);
Purchased.List? messageInfo =
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p =>
@ -2776,7 +2775,7 @@ public class DownloadService(
}
else
{
Messages.Medium? mediaInfo =
Medium? mediaInfo =
paidMessageCollection.PaidMessageMedia.FirstOrDefault(m => m.id == kvp.Key);
Purchased.List? messageInfo =
paidMessageCollection.PaidMessageObjects.FirstOrDefault(p => p?.media?.Contains(mediaInfo) == true);
@ -3033,7 +3032,7 @@ public class DownloadService(
$"https://onlyfans.com/api2/v2/users/media/{parsed[4]}/drm/post/{parsed[5]}?type=widevine",
pssh);
Messages.Medium? mediaInfo = purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.id == postKVP.Key);
Medium? mediaInfo = purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.id == postKVP.Key);
Purchased.List? postInfo =
purchasedPosts.PaidPostObjects.FirstOrDefault(p => p?.media?.Contains(mediaInfo) == true);
@ -3049,7 +3048,7 @@ public class DownloadService(
}
else
{
Messages.Medium? mediaInfo = purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.id == postKVP.Key);
Medium? mediaInfo = purchasedPosts.PaidPostMedia.FirstOrDefault(m => m.id == postKVP.Key);
Purchased.List? postInfo =
purchasedPosts.PaidPostObjects.FirstOrDefault(p => p?.media?.Contains(mediaInfo) == true);
isNew = await DownloadPurchasedPostMedia(postKVP.Value, path, postKVP.Key, "Posts", progressReporter,

View File

@ -5,7 +5,7 @@ using OF_DL.Models.Post;
using OF_DL.Models.Purchased;
using OF_DL.Models.Streams;
using OF_DL.Enumerations;
using OF_DL.Models.Entities.Archived;
using ArchivedModels = OF_DL.Models.Entities.Archived;
using Spectre.Console;
namespace OF_DL.Services;
@ -28,7 +28,7 @@ public interface IAPIService
Task<PostCollection> GetPosts(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
Task<SinglePostCollection> GetPost(string endpoint, string folder);
Task<StreamsCollection> GetStreams(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
Task<ArchivedCollection> GetArchived(string endpoint, string folder, StatusContext ctx);
Task<ArchivedModels.ArchivedCollection> GetArchived(string endpoint, string folder, StatusContext ctx);
Task<MessageCollection> GetMessages(string endpoint, string folder, StatusContext ctx);
Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, StatusContext ctx);
Task<SinglePaidMessageCollection> GetPaidMessage(string endpoint, string folder);

View File

@ -1,5 +1,5 @@
using OF_DL.Models;
using OF_DL.Models.Entities.Archived;
using ArchivedModels = OF_DL.Models.Entities.Archived;
using OF_DL.Models.Messages;
using OF_DL.Models.Post;
using OF_DL.Models.Purchased;
@ -17,14 +17,14 @@ public interface IDownloadService
string serverFileName, string resolvedFileName, string extension, IProgressReporter progressReporter);
Task<bool> DownloadArchivedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, ListItem? messageInfo,
OF_DL.Models.Entities.Archived.Medium? messageMedia, Models.Entities.Common.Author? author,
IProgressReporter progressReporter, string? filenameFormat, ArchivedModels.ListItem? messageInfo,
ArchivedModels.Medium? messageMedia, Models.Entities.Common.Author? author,
Dictionary<string, long> users);
Task<bool> DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, ListItem? postInfo,
OF_DL.Models.Entities.Archived.Medium? postMedia,
IProgressReporter progressReporter, string? filenameFormat, ArchivedModels.ListItem? postInfo,
ArchivedModels.Medium? postMedia,
Models.Entities.Common.Author? author, Dictionary<string, long> users);
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
@ -41,11 +41,11 @@ public interface IDownloadService
Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
string? filenameFormat, List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser,
string? filenameFormat, List? messageInfo, Medium? messageMedia, Messages.FromUser? fromUser,
Dictionary<string, long> users);
Task<bool> DownloadMessageMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Messages.Medium? messageMedia,
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Medium? messageMedia,
Messages.FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type,
@ -58,35 +58,35 @@ public interface IDownloadService
Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo,
Messages.Medium? postMedia,
Medium? postMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
Purchased.FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadStoryMedia(string url, string folder, long media_id, string api_type,
@ -104,12 +104,12 @@ public interface IDownloadService
Task<bool> DownloadSingleMessagePreviewDRMVideo(string policy, string signature, string kvp, string url,
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users);
Task<bool> DownloadMessagePreviewMedia(string url, string folder, long media_id, string api_type,
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo,
Messages.Medium? messageMedia,
Medium? messageMedia,
FromUser? fromUser, Dictionary<string, long> users);
Task<DownloadResult> DownloadHighlights(string username, long userId, string path, HashSet<long> paidPostIds,
@ -119,7 +119,7 @@ public interface IDownloadService
IProgressReporter progressReporter);
Task<DownloadResult> DownloadArchived(string username, long userId, string path, Dictionary<string, long> users,
bool clientIdBlobMissing, bool devicePrivateKeyMissing, ArchivedCollection archived,
bool clientIdBlobMissing, bool devicePrivateKeyMissing, ArchivedModels.ArchivedCollection archived,
IProgressReporter progressReporter);
Task<DownloadResult> DownloadMessages(string username, long userId, string path, Dictionary<string, long> users,