From be7339dca012aea189e89aa914d2016faa6e62a5 Mon Sep 17 00:00:00 2001 From: nyc_tk Date: Sun, 14 Dec 2025 22:20:20 +0000 Subject: [PATCH] revert 14d2411e88ddbcb0a86753ecfed994c4b792e787 revert merge upstream --- OF DL/Entities/Archived/Archived.cs | 10 +- OF DL/Entities/Highlights/HighlightMedia.cs | 20 +- OF DL/Entities/Highlights/Highlights.cs | 6 +- OF DL/Entities/Lists/UserList.cs | 2 +- OF DL/Entities/Lists/UsersList.cs | 6 +- OF DL/Entities/Messages/Messages.cs | 8 +- OF DL/Entities/Messages/SingleMessage.cs | 4 +- OF DL/Entities/Post/Post.cs | 8 +- OF DL/Entities/Post/SinglePost.cs | 14 +- OF DL/Entities/Purchased/Purchased.cs | 12 +- OF DL/Entities/Stories/Stories.cs | 14 +- OF DL/Entities/Streams/Streams.cs | 12 +- OF DL/Entities/Subscriptions.cs | 4 +- OF DL/Entities/User.cs | 4 +- OF DL/Helpers/APIHelper.cs | 65 +++--- OF DL/Helpers/DBHelper.cs | 10 +- OF DL/Helpers/DownloadHelper.cs | 123 ++++------- OF DL/Helpers/FileNameHelper.cs | 6 +- OF DL/Helpers/Interfaces/IAPIHelper.cs | 10 +- OF DL/Helpers/Interfaces/IDBHelper.cs | 6 +- OF DL/Helpers/Interfaces/IDownloadHelper.cs | 32 +-- OF DL/Helpers/Interfaces/IFileNameHelper.cs | 2 +- OF DL/Helpers/VersionHelper.cs | 15 +- OF DL/Program.cs | 215 ++++++-------------- docs/config/all-configuration-options.md | 20 -- docs/config/configuration.md | 2 - 26 files changed, 241 insertions(+), 389 deletions(-) diff --git a/OF DL/Entities/Archived/Archived.cs b/OF DL/Entities/Archived/Archived.cs index 7f132e2..49658e9 100644 --- a/OF DL/Entities/Archived/Archived.cs +++ b/OF DL/Entities/Archived/Archived.cs @@ -17,7 +17,7 @@ namespace OF_DL.Entities.Archived public Counters counters { get; set; } public class Author { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } @@ -64,7 +64,7 @@ namespace OF_DL.Entities.Archived public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -73,7 +73,7 @@ namespace OF_DL.Entities.Archived public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Thumb @@ -81,7 +81,7 @@ namespace OF_DL.Entities.Archived public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Hls @@ -105,7 +105,7 @@ namespace OF_DL.Entities.Archived public class LinkedPost { public string responseType { get; set; } - public long? id { get; set; } + public int? id { get; set; } public DateTime? postedAt { get; set; } public string postedAtPrecise { get; set; } public object expiredAt { get; set; } diff --git a/OF DL/Entities/Highlights/HighlightMedia.cs b/OF DL/Entities/Highlights/HighlightMedia.cs index af51136..d4b141a 100644 --- a/OF DL/Entities/Highlights/HighlightMedia.cs +++ b/OF DL/Entities/Highlights/HighlightMedia.cs @@ -9,10 +9,10 @@ namespace OF_DL.Entities.Highlights { public class HighlightMedia { - public long id { get; set; } - public long userId { get; set; } + public int id { get; set; } + public int userId { get; set; } public string title { get; set; } - public long coverStoryId { get; set; } + public int coverStoryId { get; set; } public string cover { get; set; } public int storiesCount { get; set; } public DateTime? createdAt { get; set; } @@ -30,7 +30,7 @@ namespace OF_DL.Entities.Highlights public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -50,7 +50,7 @@ namespace OF_DL.Entities.Highlights public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } @@ -60,7 +60,7 @@ namespace OF_DL.Entities.Highlights public int width { get; set; } public int height { get; set; } public int duration { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } @@ -80,14 +80,14 @@ namespace OF_DL.Entities.Highlights public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } public class Story { - public long id { get; set; } - public long userId { get; set; } + public int id { get; set; } + public int userId { get; set; } public bool isWatched { get; set; } public bool isReady { get; set; } public List media { get; set; } @@ -102,7 +102,7 @@ namespace OF_DL.Entities.Highlights public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } } } diff --git a/OF DL/Entities/Highlights/Highlights.cs b/OF DL/Entities/Highlights/Highlights.cs index fbcd4dc..fc29ff7 100644 --- a/OF DL/Entities/Highlights/Highlights.cs +++ b/OF DL/Entities/Highlights/Highlights.cs @@ -12,10 +12,10 @@ namespace OF_DL.Entities.Highlights public bool hasMore { get; set; } public class List { - public long id { get; set; } - public long userId { get; set; } + public int id { get; set; } + public int userId { get; set; } public string title { get; set; } - public long coverStoryId { get; set; } + public int coverStoryId { get; set; } public string cover { get; set; } public int storiesCount { get; set; } public DateTime? createdAt { get; set; } diff --git a/OF DL/Entities/Lists/UserList.cs b/OF DL/Entities/Lists/UserList.cs index cc42563..0a2c067 100644 --- a/OF DL/Entities/Lists/UserList.cs +++ b/OF DL/Entities/Lists/UserList.cs @@ -34,7 +34,7 @@ namespace OF_DL.Entities.Lists public class User { - public long? id { get; set; } + public int? id { get; set; } public string _view { get; set; } } } diff --git a/OF DL/Entities/Lists/UsersList.cs b/OF DL/Entities/Lists/UsersList.cs index 010db51..3b77dfa 100644 --- a/OF DL/Entities/Lists/UsersList.cs +++ b/OF DL/Entities/Lists/UsersList.cs @@ -14,7 +14,7 @@ namespace OF_DL.Entities.Lists public string header { get; set; } public HeaderSize headerSize { get; set; } public HeaderThumbs headerThumbs { get; set; } - public long? id { get; set; } + public int? id { get; set; } public string name { get; set; } public string username { get; set; } public bool? canLookStory { get; set; } @@ -92,7 +92,7 @@ namespace OF_DL.Entities.Lists public class Subscribe { public object id { get; set; } - public long? userId { get; set; } + public int? userId { get; set; } public int? subscriberId { get; set; } public DateTime? date { get; set; } public int? duration { get; set; } @@ -160,7 +160,7 @@ namespace OF_DL.Entities.Lists public class SubscriptionBundle { - public long? id { get; set; } + public int? id { get; set; } public string? discount { get; set; } public string? duration { get; set; } public string? price { get; set; } diff --git a/OF DL/Entities/Messages/Messages.cs b/OF DL/Entities/Messages/Messages.cs index c211368..1f17f70 100644 --- a/OF DL/Entities/Messages/Messages.cs +++ b/OF DL/Entities/Messages/Messages.cs @@ -43,7 +43,7 @@ namespace OF_DL.Entities.Messages public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -52,7 +52,7 @@ namespace OF_DL.Entities.Messages public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Thumb @@ -60,12 +60,12 @@ namespace OF_DL.Entities.Messages public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class FromUser { - public long? id { get; set; } + public int? id { get; set; } public string _view { get; set; } } diff --git a/OF DL/Entities/Messages/SingleMessage.cs b/OF DL/Entities/Messages/SingleMessage.cs index 2e013f4..f6231fb 100644 --- a/OF DL/Entities/Messages/SingleMessage.cs +++ b/OF DL/Entities/Messages/SingleMessage.cs @@ -17,7 +17,7 @@ namespace OF_DL.Entities.Messages public string header { get; set; } public HeaderSize headerSize { get; set; } public HeaderThumbs headerThumbs { get; set; } - public long? id { get; set; } + public int? id { get; set; } public string name { get; set; } public string username { get; set; } public bool canLookStory { get; set; } @@ -81,7 +81,7 @@ namespace OF_DL.Entities.Messages { public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class SingleMessage diff --git a/OF DL/Entities/Post/Post.cs b/OF DL/Entities/Post/Post.cs index d7b661b..5078f95 100644 --- a/OF DL/Entities/Post/Post.cs +++ b/OF DL/Entities/Post/Post.cs @@ -20,7 +20,7 @@ public class Post public string tailMarker { get; set; } public class Author { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } @@ -56,7 +56,7 @@ public class Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -65,7 +65,7 @@ public class Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Thumb @@ -73,7 +73,7 @@ public class Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Hls diff --git a/OF DL/Entities/Post/SinglePost.cs b/OF DL/Entities/Post/SinglePost.cs index ef37c40..f38795f 100644 --- a/OF DL/Entities/Post/SinglePost.cs +++ b/OF DL/Entities/Post/SinglePost.cs @@ -12,7 +12,7 @@ namespace OF_DL.Entities.Post public class SinglePost { public string responseType { get; set; } - public long id { get; set; } + public int id { get; set; } public DateTime postedAt { get; set; } public string postedAtPrecise { get; set; } public object expiredAt { get; set; } @@ -67,7 +67,7 @@ namespace OF_DL.Entities.Post public List preview { get; set; } public class Author { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } @@ -85,7 +85,7 @@ namespace OF_DL.Entities.Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -94,7 +94,7 @@ namespace OF_DL.Entities.Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Thumb @@ -102,7 +102,7 @@ namespace OF_DL.Entities.Post public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Info @@ -134,7 +134,7 @@ namespace OF_DL.Entities.Post { public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public string url { get; set; } } @@ -143,7 +143,7 @@ namespace OF_DL.Entities.Post public string source { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public int duration { get; set; } } diff --git a/OF DL/Entities/Purchased/Purchased.cs b/OF DL/Entities/Purchased/Purchased.cs index 64ae348..11fddda 100644 --- a/OF DL/Entities/Purchased/Purchased.cs +++ b/OF DL/Entities/Purchased/Purchased.cs @@ -13,14 +13,17 @@ namespace OF_DL.Entities.Purchased public List list { get; set; } public bool hasMore { get; set; } + + + public class FromUser { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } public class Author { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } @@ -78,5 +81,10 @@ namespace OF_DL.Entities.Purchased public string hls { get; set; } public string dash { get; set; } } + + + + + } } diff --git a/OF DL/Entities/Stories/Stories.cs b/OF DL/Entities/Stories/Stories.cs index 1f2efcd..0d8961d 100644 --- a/OF DL/Entities/Stories/Stories.cs +++ b/OF DL/Entities/Stories/Stories.cs @@ -9,8 +9,8 @@ namespace OF_DL.Entities.Stories { public class Stories { - public long id { get; set; } - public long userId { get; set; } + public int id { get; set; } + public int userId { get; set; } public bool isWatched { get; set; } public bool isReady { get; set; } public List media { get; set; } @@ -31,7 +31,7 @@ namespace OF_DL.Entities.Stories public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -51,7 +51,7 @@ namespace OF_DL.Entities.Stories public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } @@ -61,7 +61,7 @@ namespace OF_DL.Entities.Stories public int width { get; set; } public int height { get; set; } public int duration { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } @@ -81,7 +81,7 @@ namespace OF_DL.Entities.Stories public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public Sources sources { get; set; } } @@ -90,7 +90,7 @@ namespace OF_DL.Entities.Stories public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } } } diff --git a/OF DL/Entities/Streams/Streams.cs b/OF DL/Entities/Streams/Streams.cs index 2ad51e3..a822e97 100644 --- a/OF DL/Entities/Streams/Streams.cs +++ b/OF DL/Entities/Streams/Streams.cs @@ -17,7 +17,7 @@ namespace OF_DL.Entities.Streams public Counters counters { get; set; } public class Author { - public long id { get; set; } + public int id { get; set; } public string _view { get; set; } } @@ -46,7 +46,7 @@ namespace OF_DL.Entities.Streams public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public List sources { get; set; } } @@ -55,7 +55,7 @@ namespace OF_DL.Entities.Streams public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Thumb @@ -63,7 +63,7 @@ namespace OF_DL.Entities.Streams public string url { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } } public class Info @@ -154,7 +154,7 @@ namespace OF_DL.Entities.Streams { public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public string url { get; set; } } @@ -163,7 +163,7 @@ namespace OF_DL.Entities.Streams public string source { get; set; } public int width { get; set; } public int height { get; set; } - public long size { get; set; } + public int size { get; set; } public int duration { get; set; } } diff --git a/OF DL/Entities/Subscriptions.cs b/OF DL/Entities/Subscriptions.cs index f5bacdd..06cf9b0 100644 --- a/OF DL/Entities/Subscriptions.cs +++ b/OF DL/Entities/Subscriptions.cs @@ -36,7 +36,7 @@ namespace OF_DL.Entities public string header { get; set; } public HeaderSize headerSize { get; set; } public HeaderThumbs headerThumbs { get; set; } - public long id { get; set; } + public int id { get; set; } public string name { get; set; } public string username { get; set; } public bool? canLookStory { get; set; } @@ -96,7 +96,7 @@ namespace OF_DL.Entities public class Subscribe { public object id { get; set; } - public long? userId { get; set; } + public int? userId { get; set; } public int? subscriberId { get; set; } public DateTime? date { get; set; } public int? duration { get; set; } diff --git a/OF DL/Entities/User.cs b/OF DL/Entities/User.cs index e5dae37..ff95c8f 100644 --- a/OF DL/Entities/User.cs +++ b/OF DL/Entities/User.cs @@ -14,7 +14,7 @@ namespace OF_DL.Entities public string? header { get; set; } public HeaderSize headerSize { get; set; } public HeaderThumbs headerThumbs { get; set; } - public long? id { get; set; } + public int? id { get; set; } public string name { get; set; } public string username { get; set; } public bool? canLookStory { get; set; } @@ -124,7 +124,7 @@ namespace OF_DL.Entities public class Subscribe { public long? id { get; set; } - public long? userId { get; set; } + public int? userId { get; set; } public int? subscriberId { get; set; } public DateTime? date { get; set; } public int? duration { get; set; } diff --git a/OF DL/Helpers/APIHelper.cs b/OF DL/Helpers/APIHelper.cs index 84ce24e..80c595c 100644 --- a/OF DL/Helpers/APIHelper.cs +++ b/OF DL/Helpers/APIHelper.cs @@ -31,8 +31,6 @@ public class APIHelper : IAPIHelper private readonly Auth auth; private static DateTime? cachedDynamicRulesExpiration; private static DynamicRules? cachedDynamicRules; - private const int MaxAttempts = 30; - private const int DelayBetweenAttempts = 3000; static APIHelper() { @@ -295,11 +293,11 @@ public class APIHelper : IAPIHelper } - public async Task?> GetAllSubscriptions(Dictionary getParams, string endpoint, bool includeRestricted, IDownloadConfig config) + public async Task?> GetAllSubscriptions(Dictionary getParams, string endpoint, bool includeRestricted, IDownloadConfig config) { try { - Dictionary users = new(); + Dictionary users = new(); Subscriptions subscriptions = new(); Log.Debug("Calling GetAllSubscrptions"); @@ -359,7 +357,7 @@ public class APIHelper : IAPIHelper return null; } - public async Task?> GetActiveSubscriptions(string endpoint, bool includeRestricted, IDownloadConfig config) + public async Task?> GetActiveSubscriptions(string endpoint, bool includeRestricted, IDownloadConfig config) { Dictionary getParams = new() { @@ -373,7 +371,7 @@ public class APIHelper : IAPIHelper } - public async Task?> GetExpiredSubscriptions(string endpoint, bool includeRestricted, IDownloadConfig config) + public async Task?> GetExpiredSubscriptions(string endpoint, bool includeRestricted, IDownloadConfig config) { Dictionary getParams = new() @@ -390,7 +388,7 @@ public class APIHelper : IAPIHelper } - public async Task> GetLists(string endpoint, IDownloadConfig config) + public async Task> GetLists(string endpoint, IDownloadConfig config) { Log.Debug("Calling GetLists"); @@ -404,7 +402,7 @@ public class APIHelper : IAPIHelper { "limit", "50" }, { "format", "infinite" } }; - Dictionary lists = new(); + Dictionary lists = new(); while (true) { string? body = await BuildHeaderAndExecuteRequests(getParams, endpoint, new HttpClient()); @@ -2067,13 +2065,13 @@ public class APIHelper : IAPIHelper return null; } - public async Task> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary users) + public async Task> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary users) { Log.Debug($"Calling GetPurchasedTabUsers - {endpoint}"); try { - Dictionary purchasedTabUsers = new(); + Dictionary purchasedTabUsers = new(); Purchased purchased = new(); int post_limit = 50; Dictionary getParams = new() @@ -2240,7 +2238,7 @@ public class APIHelper : IAPIHelper return null; } - public async Task> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary users) + public async Task> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary users) { Log.Debug($"Calling GetPurchasedTab - {endpoint}"); @@ -2676,10 +2674,13 @@ public class APIHelper : IAPIHelper return DateTime.Now; } + public async Task GetDecryptionKeyCDRMProject(Dictionary drmHeaders, string licenceURL, string pssh) { Log.Debug("Calling GetDecryptionKey"); + const int maxAttempts = 30; + const int delayBetweenAttempts = 3000; int attempt = 0; try @@ -2700,7 +2701,7 @@ public class APIHelper : IAPIHelper Log.Debug($"Posting to CDRM Project: {json}"); - while (attempt < MaxAttempts) + while (attempt < maxAttempts) { attempt++; @@ -2726,19 +2727,19 @@ public class APIHelper : IAPIHelper } else { - Log.Debug($"CDRM response status not successful. Retrying... Attempt {attempt} of {MaxAttempts}"); - if (attempt < MaxAttempts) + Log.Debug($"CDRM response status not successful. Retrying... Attempt {attempt} of {maxAttempts}"); + if (attempt < maxAttempts) { - await Task.Delay(DelayBetweenAttempts); + await Task.Delay(delayBetweenAttempts); } } } else { - Log.Debug($"Status not in CDRM response. Retrying... Attempt {attempt} of {MaxAttempts}"); - if (attempt < MaxAttempts) + Log.Debug($"Status not in CDRM response. Retrying... Attempt {attempt} of {maxAttempts}"); + if (attempt < maxAttempts) { - await Task.Delay(DelayBetweenAttempts); + await Task.Delay(delayBetweenAttempts); } } } @@ -2763,10 +2764,11 @@ public class APIHelper : IAPIHelper { Log.Debug("Calling GetDecryptionOFDL"); + try { + string dcValue = string.Empty; HttpClient client = new(); - int attempt = 0; OFDLRequest ofdlRequest = new OFDLRequest { @@ -2779,27 +2781,17 @@ public class APIHelper : IAPIHelper Log.Debug($"Posting to ofdl.tools: {json}"); - while (attempt < MaxAttempts) + HttpRequestMessage request = new(HttpMethod.Post, "https://ofdl.tools/WV") { - attempt++; + Content = new StringContent(json, Encoding.UTF8, "application/json") + }; - HttpRequestMessage request = new(HttpMethod.Post, "https://ofdl.tools/WV") - { - Content = new StringContent(json, Encoding.UTF8, "application/json") - }; - - using var response = await client.SendAsync(request); - - if (!response.IsSuccessStatusCode) - continue; + using var response = await client.SendAsync(request); + if (response.IsSuccessStatusCode) + { string body = await response.Content.ReadAsStringAsync(); - - if (!body.TrimStart().StartsWith('{')) - return body; - - Log.Debug($"Received JSON object instead of string. Retrying... Attempt {attempt} of {MaxAttempts}"); - await Task.Delay(DelayBetweenAttempts); + return body; } } catch (Exception ex) @@ -2813,7 +2805,6 @@ public class APIHelper : IAPIHelper Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace); } } - return null; } diff --git a/OF DL/Helpers/DBHelper.cs b/OF DL/Helpers/DBHelper.cs index 697fa71..21e63a5 100644 --- a/OF DL/Helpers/DBHelper.cs +++ b/OF DL/Helpers/DBHelper.cs @@ -135,7 +135,7 @@ namespace OF_DL.Helpers } } - public async Task CreateUsersDB(Dictionary users) + public async Task CreateUsersDB(Dictionary users) { try { @@ -150,7 +150,7 @@ namespace OF_DL.Helpers } Log.Debug("Adding missing creators"); - foreach (KeyValuePair user in users) + foreach (KeyValuePair user in users) { using (SqliteCommand checkCmd = new($"SELECT user_id, username FROM users WHERE user_id = @userId;", connection)) { @@ -190,7 +190,7 @@ namespace OF_DL.Helpers } } - public async Task CheckUsername(KeyValuePair user, string path) + public async Task CheckUsername(KeyValuePair user, string path) { try { @@ -243,7 +243,7 @@ namespace OF_DL.Helpers } } - public async Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, long user_id) + public async Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, int user_id) { try { @@ -495,7 +495,7 @@ namespace OF_DL.Helpers FROM posts AS P INNER JOIN medias AS m ON P.post_id = m.post_id - WHERE m.downloaded = 0 + WHERE m.downloaded = 0 )", connection); var scalarValue = await cmd.ExecuteScalarAsync(); if(scalarValue != null && scalarValue != DBNull.Value) diff --git a/OF DL/Helpers/DownloadHelper.cs b/OF DL/Helpers/DownloadHelper.cs index 77460bf..82065f9 100644 --- a/OF DL/Helpers/DownloadHelper.cs +++ b/OF DL/Helpers/DownloadHelper.cs @@ -77,9 +77,9 @@ public class DownloadHelper : IDownloadHelper try { string customFileName = string.Empty; - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } string extension = Path.GetExtension(url.Split("?")[0]); @@ -164,7 +164,7 @@ public class DownloadHelper : IDownloadHelper object? postMedia, object? author, string username, - Dictionary users, + Dictionary users, IFileNameHelper fileNameHelper, CustomFileNameOption option) { @@ -628,38 +628,9 @@ public class DownloadHelper : IDownloadHelper // default: // tempFilename = $"{folder}{path}/{filename}_source.mp4"; // break; - //} + //} - // Configure ffmpeg log level and optional report file location - bool ffmpegDebugLogging = Log.IsEnabled(Serilog.Events.LogEventLevel.Debug); - - string logLevelArgs = ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug - ? "-loglevel debug -report" - : downloadConfig.LoggingLevel switch - { - LoggingLevel.Information => "-loglevel info", - LoggingLevel.Warning => "-loglevel warning", - LoggingLevel.Error => "-loglevel error", - LoggingLevel.Fatal => "-loglevel fatal", - _ => string.Empty - }; - - if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase)) - { - // Direct ffmpeg report files into the same logs directory Serilog uses (relative to current working directory) - string logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "logs")); - Directory.CreateDirectory(logDir); - string ffReportPath = Path.Combine(logDir, "ffmpeg-%p-%t.log"); // ffmpeg will replace %p/%t - Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32"); - Log.Debug("FFREPORT enabled at: {FFREPORT} (cwd: {Cwd})", Environment.GetEnvironmentVariable("FFREPORT"), Environment.CurrentDirectory); - } - else - { - Environment.SetEnvironmentVariable("FFREPORT", null); - Log.Debug("FFREPORT disabled (cwd: {Cwd})", Environment.CurrentDirectory); - } - - string parameters = $"{logLevelArgs} -cenc_decryption_key {decKey} -headers \"Cookie:CloudFront-Policy={policy}; CloudFront-Signature={signature}; CloudFront-Key-Pair-Id={kvp}; {sess} Origin: https://onlyfans.com Referer: https://onlyfans.com User-Agent: {user_agent}\" -y -i \"{url}\" -map 0:v:{streamIndex} -map 0:a? -codec copy \"{tempFilename}\"".Trim(); + string parameters = $"-cenc_decryption_key {decKey} -headers \"Cookie:CloudFront-Policy={policy}; CloudFront-Signature={signature}; CloudFront-Key-Pair-Id={kvp}; {sess} Origin: https://onlyfans.com Referer: https://onlyfans.com User-Agent: {user_agent}\" -y -i \"{url}\" -map 0:v:{streamIndex} -map 0:a? -codec copy \"{tempFilename}\""; Log.Debug($"Calling FFMPEG with Parameters: {parameters}"); @@ -690,7 +661,7 @@ public class DownloadHelper : IDownloadHelper #endregion #region normal posts - public async Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users) + public async Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users) { string path; if (downloadConfig.FolderPerPost && postInfo != null && postInfo?.id is not null && postInfo?.postedAt is not null) @@ -708,7 +679,7 @@ public class DownloadHelper : IDownloadHelper return await CreateDirectoriesAndDownloadMedia(path, url, folder, media_id, api_type, task, filename, resolvedFilename); } - public async Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia, SinglePost.Author? author, Dictionary users) + public async Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia, SinglePost.Author? author, Dictionary users) { string path; if (downloadConfig.FolderPerPost && postInfo != null && postInfo?.id is not null && postInfo?.postedAt is not null) @@ -726,7 +697,7 @@ public class DownloadHelper : IDownloadHelper return await CreateDirectoriesAndDownloadMedia(path, url, folder, media_id, api_type, task, filename, resolvedFilename); } - public async Task DownloadStreamMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users) + public async Task DownloadStreamMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users) { string path; if (downloadConfig.FolderPerPost && streamInfo != null && streamInfo?.id is not null && streamInfo?.postedAt is not null) @@ -746,7 +717,7 @@ public class DownloadHelper : IDownloadHelper } - public async Task DownloadMessageMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary users) + public async Task DownloadMessageMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary users) { string path; if (downloadConfig.FolderPerMessage && messageInfo != null && messageInfo?.id is not null && messageInfo?.createdAt is not null) @@ -764,7 +735,7 @@ public class DownloadHelper : IDownloadHelper } - public async Task DownloadArchivedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Archived.List? messageInfo, Archived.Medium? messageMedia, Archived.Author? author, Dictionary users) + public async Task DownloadArchivedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Archived.List? messageInfo, Archived.Medium? messageMedia, Archived.Author? author, Dictionary users) { string path = "/Archived/Posts/Free"; Uri uri = new(url); @@ -783,7 +754,7 @@ public class DownloadHelper : IDownloadHelper return await CreateDirectoriesAndDownloadMedia(path, url, folder, media_id, api_type, task, filename, filename); } - public async Task DownloadPurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary users) + public async Task DownloadPurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary users) { string path; if (downloadConfig.FolderPerPaidMessage && messageInfo != null && messageInfo?.id is not null && messageInfo?.createdAt is not null) @@ -800,7 +771,7 @@ public class DownloadHelper : IDownloadHelper return await CreateDirectoriesAndDownloadMedia(path, url, folder, media_id, api_type, task, filename, resolvedFilename); } - public async Task DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users) + public async Task DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users) { string path; if (downloadConfig.FolderPerPaidMessage && messageInfo != null && messageInfo?.id is not null && messageInfo?.createdAt is not null) @@ -826,7 +797,7 @@ public class DownloadHelper : IDownloadHelper Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, - Dictionary users) + Dictionary users) { string path; if (downloadConfig.FolderPerPaidPost && messageInfo != null && messageInfo?.id is not null && messageInfo?.postedAt is not null) @@ -848,19 +819,19 @@ public class DownloadHelper : IDownloadHelper { try { - string path = $"/Profile"; + string path = $"/Profile"; - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } if (!string.IsNullOrEmpty(avatarUrl)) { string avatarpath = $"{path}/Avatars"; - if (!Directory.Exists(folder + avatarpath)) + if (!Directory.Exists(folder + avatarpath)) { - Directory.CreateDirectory(folder + avatarpath); + Directory.CreateDirectory(folder + avatarpath); } List avatarMD5Hashes = WidevineClient.Utils.CalculateFolderMD5(folder + avatarpath); @@ -901,9 +872,9 @@ public class DownloadHelper : IDownloadHelper if (!string.IsNullOrEmpty(headerUrl)) { string headerpath = $"{path}/Headers"; - if (!Directory.Exists(folder + headerpath)) + if (!Directory.Exists(folder + headerpath)) { - Directory.CreateDirectory(folder + headerpath); + Directory.CreateDirectory(folder + headerpath); } List headerMD5Hashes = WidevineClient.Utils.CalculateFolderMD5(folder + headerpath); @@ -994,22 +965,12 @@ public class DownloadHelper : IDownloadHelper private void OnError(object sender, ConversionErrorEventArgs e) { - // Guard all fields to avoid NullReference exceptions from FFmpeg.NET - var input = e?.Input?.Name ?? ""; - var output = e?.Output?.Name ?? ""; - var exitCode = e?.Exception?.ExitCode.ToString() ?? ""; - var message = e?.Exception?.Message ?? ""; - var inner = e?.Exception?.InnerException?.Message ?? ""; - - Log.Error("FFmpeg failed. Input={Input} Output={Output} ExitCode={ExitCode} Message={Message} Inner={Inner}", - input, output, exitCode, message, inner); - + Log.Debug("[{0} => {1}]: Error: {2}\n{3}", e.Input.Name, e.Output.Name, e.Exception.ExitCode, e.Exception.InnerException); _completionSource?.TrySetResult(false); } - #region drm posts - public async Task DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary users) + public async Task DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary users) { try { @@ -1025,9 +986,9 @@ public class DownloadHelper : IDownloadHelper { path = "/Messages/Free/Videos"; } - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } @@ -1117,7 +1078,7 @@ public class DownloadHelper : IDownloadHelper } - public async Task DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary users) + public async Task DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary users) { try { @@ -1133,9 +1094,9 @@ public class DownloadHelper : IDownloadHelper { path = "/Messages/Paid/Videos"; } - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } if (!string.IsNullOrEmpty(filenameFormat) && messageInfo != null && messageMedia != null) @@ -1223,7 +1184,7 @@ public class DownloadHelper : IDownloadHelper return false; } - public async Task DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users) + public async Task DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users) { try { @@ -1330,7 +1291,7 @@ public class DownloadHelper : IDownloadHelper } - public async Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users) + public async Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users) { try { @@ -1346,9 +1307,9 @@ public class DownloadHelper : IDownloadHelper { path = "/Posts/Free/Videos"; } - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } if (!string.IsNullOrEmpty(filenameFormat) && postInfo != null && postMedia != null) @@ -1435,7 +1396,7 @@ public class DownloadHelper : IDownloadHelper } return false; } - public async Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author, Dictionary users) + public async Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author, Dictionary users) { try { @@ -1451,9 +1412,9 @@ public class DownloadHelper : IDownloadHelper { path = "/Posts/Free/Videos"; } - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } if (!string.IsNullOrEmpty(filenameFormat) && postInfo != null && postMedia != null) @@ -1514,7 +1475,7 @@ public class DownloadHelper : IDownloadHelper await m_DBHelper.UpdateMedia(folder, media_id, api_type, folder + path, customFileName + ".mp4", size, true, lastModified); } } - + if (downloadConfig.ShowScrapeSize) { long size = await m_DBHelper.GetStoredFileSize(folder, media_id, api_type); @@ -1540,7 +1501,7 @@ public class DownloadHelper : IDownloadHelper } return false; } - public async Task DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users) + public async Task DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users) { try { @@ -1646,7 +1607,7 @@ public class DownloadHelper : IDownloadHelper return false; } - public async Task DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? postInfo, Medium? postMedia, Purchased.FromUser? fromUser, Dictionary users) + public async Task DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Purchased.List? postInfo, Medium? postMedia, Purchased.FromUser? fromUser, Dictionary users) { try { @@ -1662,9 +1623,9 @@ public class DownloadHelper : IDownloadHelper { path = "/Posts/Paid/Videos"; } - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } @@ -1754,7 +1715,7 @@ public class DownloadHelper : IDownloadHelper } - public async Task DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Archived.List? postInfo, Archived.Medium? postMedia, Archived.Author? author, Dictionary users) + public async Task DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Archived.List? postInfo, Archived.Medium? postMedia, Archived.Author? author, Dictionary users) { try { @@ -1762,9 +1723,9 @@ public class DownloadHelper : IDownloadHelper Uri uri = new(url); string filename = System.IO.Path.GetFileName(uri.LocalPath).Split(".")[0]; string path = "/Archived/Posts/Free/Videos"; - if (!Directory.Exists(folder + path)) + if (!Directory.Exists(folder + path)) { - Directory.CreateDirectory(folder + path); + Directory.CreateDirectory(folder + path); } if (!string.IsNullOrEmpty(filenameFormat) && postInfo != null && postMedia != null) diff --git a/OF DL/Helpers/FileNameHelper.cs b/OF DL/Helpers/FileNameHelper.cs index 178a4e8..2d5a3a9 100644 --- a/OF DL/Helpers/FileNameHelper.cs +++ b/OF DL/Helpers/FileNameHelper.cs @@ -18,7 +18,7 @@ namespace OF_DL.Helpers this.auth = auth; } - public async Task> GetFilename(object obj1, object obj2, object obj3, List selectedProperties, string username, Dictionary users = null) + public async Task> GetFilename(object obj1, object obj2, object obj3, List selectedProperties, string username, Dictionary users = null) { Dictionary values = new(); Type type1 = obj1.GetType(); @@ -36,7 +36,7 @@ namespace OF_DL.Helpers { drmProperty = GetNestedPropertyValue(obj2, "files.drm"); } - + if(fileProperty != null && drmProperty != null && propertyName == "mediaCreatedAt") { object mpdurl = GetNestedPropertyValue(obj2, "files.drm.manifest.dash"); @@ -66,7 +66,7 @@ namespace OF_DL.Helpers continue; } } - + } PropertyInfo? property = Array.Find(properties2, p => p.Name.Equals(propertyName.Replace("media", ""), StringComparison.OrdinalIgnoreCase)); if (property != null) diff --git a/OF DL/Helpers/Interfaces/IAPIHelper.cs b/OF DL/Helpers/Interfaces/IAPIHelper.cs index d94d509..02c32a8 100644 --- a/OF DL/Helpers/Interfaces/IAPIHelper.cs +++ b/OF DL/Helpers/Interfaces/IAPIHelper.cs @@ -16,7 +16,7 @@ namespace OF_DL.Helpers Task GetDecryptionKeyCDM(Dictionary drmHeaders, string licenceURL, string pssh); Task GetDRMMPDLastModified(string mpdUrl, string policy, string signature, string kvp); Task GetDRMMPDPSSH(string mpdUrl, string policy, string signature, string kvp); - Task> GetLists(string endpoint, IDownloadConfig config); + Task> GetLists(string endpoint, IDownloadConfig config); Task> GetListUsers(string endpoint, IDownloadConfig config); Task> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, IDownloadConfig config, List paid_post_ids); Task GetPaidPosts(string endpoint, string folder, string username, IDownloadConfig config, List paid_post_ids, StatusContext ctx); @@ -26,13 +26,13 @@ namespace OF_DL.Helpers Task GetArchived(string endpoint, string folder, IDownloadConfig config, StatusContext ctx); Task GetMessages(string endpoint, string folder, IDownloadConfig config, StatusContext ctx); Task GetPaidMessages(string endpoint, string folder, string username, IDownloadConfig config, StatusContext ctx); - Task> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary users); - Task> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary users); + Task> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary users); + Task> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary users); Task GetUserInfo(string endpoint); Task GetUserInfoById(string endpoint); Dictionary GetDynamicHeaders(string path, string queryParam); - Task> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions, IDownloadConfig config); - Task> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions, IDownloadConfig config); + Task> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions, IDownloadConfig config); + Task> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions, IDownloadConfig config); Task GetDecryptionKeyOFDL(Dictionary drmHeaders, string licenceURL, string pssh); } } diff --git a/OF DL/Helpers/Interfaces/IDBHelper.cs b/OF DL/Helpers/Interfaces/IDBHelper.cs index ab55249..770b91d 100644 --- a/OF DL/Helpers/Interfaces/IDBHelper.cs +++ b/OF DL/Helpers/Interfaces/IDBHelper.cs @@ -2,12 +2,12 @@ namespace OF_DL.Helpers { public interface IDBHelper { - Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, long user_id); + Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, int user_id); Task AddPost(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at); Task AddStory(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at); Task CreateDB(string folder); - Task CreateUsersDB(Dictionary users); - Task CheckUsername(KeyValuePair user, string path); + Task CreateUsersDB(Dictionary users); + Task CheckUsername(KeyValuePair user, string path); Task AddMedia(string folder, long media_id, long post_id, string link, string? directory, string? filename, long? size, string api_type, string media_type, bool preview, bool downloaded, DateTime? created_at); Task UpdateMedia(string folder, long media_id, string api_type, string directory, string filename, long size, bool downloaded, DateTime created_at); Task GetStoredFileSize(string folder, long media_id, string api_type); diff --git a/OF DL/Helpers/Interfaces/IDownloadHelper.cs b/OF DL/Helpers/Interfaces/IDownloadHelper.cs index 72cc15b..cdc8147 100644 --- a/OF DL/Helpers/Interfaces/IDownloadHelper.cs +++ b/OF DL/Helpers/Interfaces/IDownloadHelper.cs @@ -12,25 +12,25 @@ namespace OF_DL.Helpers public interface IDownloadHelper { Task CalculateTotalFileSize(List urls); - Task DownloadArchivedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Archived.List messageInfo, Archived.Medium messageMedia, Archived.Author author, Dictionary users); - Task DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Archived.List postInfo, Archived.Medium postMedia, Archived.Author author, Dictionary users); - Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author, Dictionary users); + Task DownloadArchivedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Archived.List messageInfo, Archived.Medium messageMedia, Archived.Author author, Dictionary users); + Task DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Archived.List postInfo, Archived.Medium postMedia, Archived.Author author, Dictionary users); + Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author, Dictionary users); Task DownloadAvatarHeader(string? avatarUrl, string? headerUrl, string folder, string username); - Task DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Messages.List messageInfo, Messages.Medium messageMedia, Messages.FromUser fromUser, Dictionary users); - Task DownloadMessageMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Messages.List messageInfo, Messages.Medium messageMedia, Messages.FromUser fromUser, Dictionary users); - Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Post.List postInfo, Post.Medium postMedia, Post.Author author, Dictionary users); - Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users); - Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia, SinglePost.Author? author, Dictionary users); - Task DownloadPurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); + Task DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Messages.List messageInfo, Messages.Medium messageMedia, Messages.FromUser fromUser, Dictionary users); + Task DownloadMessageMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Messages.List messageInfo, Messages.Medium messageMedia, Messages.FromUser fromUser, Dictionary users); + Task DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Post.List postInfo, Post.Medium postMedia, Post.Author author, Dictionary users); + Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary users); + Task DownloadPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia, SinglePost.Author? author, Dictionary users); + Task DownloadPurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); - Task DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users); - Task DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); + Task DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users); + Task DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); - Task DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users); - Task DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List postInfo, Medium postMedia, Purchased.FromUser fromUser, Dictionary users); - Task DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); + Task DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary users); + Task DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List postInfo, Medium postMedia, Purchased.FromUser fromUser, Dictionary users); + Task DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string filenameFormat, Purchased.List messageInfo, Medium messageMedia, Purchased.FromUser fromUser, Dictionary users); Task DownloadStoryMedia(string url, string folder, long media_id, string api_type, ProgressTask task); - Task DownloadStreamMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users); - Task DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Streams.List streamInfo, Streams.Medium streamMedia, Streams.Author author, Dictionary users); + Task DownloadStreamMedia(string url, string folder, long media_id, string api_type, ProgressTask task, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary users); + Task DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string filenameFormat, Streams.List streamInfo, Streams.Medium streamMedia, Streams.Author author, Dictionary users); } } diff --git a/OF DL/Helpers/Interfaces/IFileNameHelper.cs b/OF DL/Helpers/Interfaces/IFileNameHelper.cs index a3cc701..aae3ba8 100644 --- a/OF DL/Helpers/Interfaces/IFileNameHelper.cs +++ b/OF DL/Helpers/Interfaces/IFileNameHelper.cs @@ -3,6 +3,6 @@ namespace OF_DL.Helpers public interface IFileNameHelper { Task BuildFilename(string fileFormat, Dictionary values); - Task> GetFilename(object obj1, object obj2, object obj3, List selectedProperties, string username, Dictionary users = null); + Task> GetFilename(object obj1, object obj2, object obj3, List selectedProperties, string username, Dictionary users = null); } } diff --git a/OF DL/Helpers/VersionHelper.cs b/OF DL/Helpers/VersionHelper.cs index dc2b163..c21d835 100644 --- a/OF DL/Helpers/VersionHelper.cs +++ b/OF DL/Helpers/VersionHelper.cs @@ -6,15 +6,14 @@ namespace OF_DL.Helpers; public static class VersionHelper { - private static readonly HttpClient httpClient = new HttpClient(); - private const string url = "https://git.ofdl.tools/api/v1/repos/sim0n00ps/OF-DL/releases/latest"; - - public static async Task GetLatestReleaseTag(CancellationToken cancellationToken = default) + public static string? GetLatestReleaseTag() { Log.Debug("Calling GetLatestReleaseTag"); try { - var response = await httpClient.GetAsync(url, cancellationToken); + HttpClient client = new(); + HttpRequestMessage request = new(HttpMethod.Get, "https://git.ofdl.tools/api/v1/repos/sim0n00ps/OF-DL/releases/latest"); + using var response = client.Send(request); if (!response.IsSuccessStatusCode) { @@ -22,7 +21,7 @@ public static class VersionHelper return null; } - var body = await response.Content.ReadAsStringAsync(); + var body = response.Content.ReadAsStringAsync().Result; Log.Debug("GetLatestReleaseTag API Response: "); Log.Debug(body); @@ -37,10 +36,6 @@ public static class VersionHelper return versionCheckResponse.TagName; } - catch (OperationCanceledException) - { - throw; // Rethrow timeout exceptions to be handled by the caller - } catch (Exception ex) { Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace); diff --git a/OF DL/Program.cs b/OF DL/Program.cs index f9a3a6b..70d66cd 100644 --- a/OF DL/Program.cs +++ b/OF DL/Program.cs @@ -116,8 +116,6 @@ public class Program .CreateLogger(); AnsiConsole.Write(new FigletText("Welcome to OF-DL").Color(Color.Red)); - AnsiConsole.Markup("Documentation: [link]https://docs.ofdl.tools/[/]\n"); - AnsiConsole.Markup("Discord server: [link]https://discord.com/invite/6bUW8EJ53j[/]\n\n"); //Remove config.json and convert to config.conf if (File.Exists("config.json")) @@ -131,10 +129,6 @@ public class Program if (jsonConfig != null) { var hoconConfig = new StringBuilder(); - hoconConfig.AppendLine("# Auth"); - hoconConfig.AppendLine("Auth {"); - hoconConfig.AppendLine($" DisableBrowserAuth = \"{jsonConfig.DisableBrowserAuth.ToString().ToLower()}\""); - hoconConfig.AppendLine("}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{jsonConfig.FFmpegPath}\""); @@ -259,7 +253,7 @@ public class Program config = new Entities.Config { //Auth - DisableBrowserAuth = hoconConfig.GetBoolean("Auth.DisableBrowserAuth"), + DisableBrowserAuth = hoconConfig.GetBoolean("DisableBrowserAuth"), // FFmpeg Settings FFmpegPath = hoconConfig.GetString("External.FFmpegPath"), @@ -379,9 +373,7 @@ public class Program Entities.Config jsonConfig = new Entities.Config(); var hoconConfig = new StringBuilder(); hoconConfig.AppendLine("# Auth"); - hoconConfig.AppendLine("Auth {"); - hoconConfig.AppendLine($" DisableBrowserAuth = \"{jsonConfig.DisableBrowserAuth.ToString().ToLower()}\""); - hoconConfig.AppendLine("}"); + hoconConfig.AppendLine($"DisableBrowserAuth = {jsonConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{jsonConfig.FFmpegPath}\""); @@ -534,50 +526,36 @@ public class Program // Only run the version check if not in DEBUG mode #if !DEBUG Version localVersion = Assembly.GetEntryAssembly()?.GetName().Version; //Only tested with numeric values. + String? latestReleaseTag = VersionHelper.GetLatestReleaseTag(); - // Create a cancellation token with 30 second timeout - using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - String? latestReleaseTag = null; + if (latestReleaseTag == null) + { + AnsiConsole.Markup("[yellow]Failed to verify that OF-DL is up-to-date.\n[/]"); + Log.Error("Failed to get the latest release tag."); + } + else + { + Version latestGiteaRelease = new Version(latestReleaseTag.Replace("OFDLV", "")); - try - { - latestReleaseTag = await VersionHelper.GetLatestReleaseTag(cts.Token); - } - catch (OperationCanceledException) - { - AnsiConsole.Markup("[yellow]Version check timed out after 30 seconds.\n[/]"); - Log.Warning("Version check timed out after 30 seconds"); - latestReleaseTag = null; - } - - if (latestReleaseTag == null) - { - AnsiConsole.Markup("[yellow]Failed to verify that OF-DL is up-to-date.\n[/]"); - Log.Error("Failed to get the latest release tag."); - } - else - { - Version latestGiteaRelease = new Version(latestReleaseTag.Replace("OFDLV", "")); - - // Compare the Versions - int versionComparison = localVersion.CompareTo(latestGiteaRelease); - if (versionComparison < 0) - { - // The version on GitHub is more up to date than this local release. - AnsiConsole.Markup("[red]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]"); - AnsiConsole.Markup("[red]Please update to the current release, " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}: [link=https://git.ofdl.tools/sim0n00ps/OF-DL/releases]https://git.ofdl.tools/sim0n00ps/OF-DL/releases[/]\n[/]"); - Log.Debug("Detected outdated client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}"); - Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}"); - } - else - { - // This local version is greater than the release version on GitHub. - AnsiConsole.Markup("[green]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]"); - AnsiConsole.Markup("[green]Latest Release version: " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}\n[/]"); - Log.Debug("Detected client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}"); - Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}"); - } - } + // Compare the Versions + int versionComparison = localVersion.CompareTo(latestGiteaRelease); + if (versionComparison < 0) + { + // The version on GitHub is more up to date than this local release. + AnsiConsole.Markup("[red]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]"); + AnsiConsole.Markup("[red]Please update to the current release, " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}: [link]https://git.ofdl.tools/sim0n00ps/OF-DL/releases[/]\n[/]"); + Log.Debug("Detected outdated client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}"); + Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}"); + } + else + { + // This local version is greater than the release version on GitHub. + AnsiConsole.Markup("[green]You are running OF-DL version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}\n[/]"); + AnsiConsole.Markup("[green]Latest Release version: " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}\n[/]"); + Log.Debug("Detected client running version " + $"{localVersion.Major}.{localVersion.Minor}.{localVersion.Build}"); + Log.Debug("Latest release version " + $"{latestGiteaRelease.Major}.{latestGiteaRelease.Minor}.{latestGiteaRelease.Build}"); + } + } #else AnsiConsole.Markup("[yellow]Running in Debug/Local mode. Version check skipped.\n[/]"); @@ -770,61 +748,6 @@ public class Program { config.FFmpegPath = config.FFmpegPath.Replace(@"\", @"\\"); } - - // Get FFmpeg version - try - { - var processStartInfo = new System.Diagnostics.ProcessStartInfo - { - FileName = config.FFmpegPath, - Arguments = "-version", - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - using (var process = System.Diagnostics.Process.Start(processStartInfo)) - { - if (process != null) - { - string output = await process.StandardOutput.ReadToEndAsync(); - await process.WaitForExitAsync(); - - // Log full output - Log.Information("FFmpeg version output:\n{Output}", output); - - // Parse first line for console output - string firstLine = output.Split('\n')[0].Trim(); - if (firstLine.StartsWith("ffmpeg version")) - { - // Extract version string (text between "ffmpeg version " and " Copyright") - int versionStart = "ffmpeg version ".Length; - int copyrightIndex = firstLine.IndexOf(" Copyright"); - if (copyrightIndex > versionStart) - { - string version = firstLine.Substring(versionStart, copyrightIndex - versionStart); - AnsiConsole.Markup($"[green]ffmpeg version detected as {version}[/]\n"); - } - else - { - // Fallback if Copyright not found - string version = firstLine.Substring(versionStart); - AnsiConsole.Markup($"[green]ffmpeg version detected as {version}[/]\n"); - } - } - else - { - AnsiConsole.Markup($"[yellow]ffmpeg version could not be parsed[/]\n"); - } - } - } - } - catch (Exception ex) - { - Log.Warning(ex, "Failed to get FFmpeg version"); - AnsiConsole.Markup($"[yellow]Could not retrieve ffmpeg version[/]\n"); - } } else { @@ -927,12 +850,12 @@ public class Program do { DateTime startTime = DateTime.Now; - Dictionary users = new(); - Dictionary activeSubs = await m_ApiHelper.GetActiveSubscriptions("/subscriptions/subscribes", Config.IncludeRestrictedSubscriptions, Config); + Dictionary users = new(); + Dictionary activeSubs = await m_ApiHelper.GetActiveSubscriptions("/subscriptions/subscribes", Config.IncludeRestrictedSubscriptions, Config); Log.Debug("Subscriptions: "); - foreach (KeyValuePair activeSub in activeSubs) + foreach (KeyValuePair activeSub in activeSubs) { if (!users.ContainsKey(activeSub.Key)) { @@ -944,8 +867,8 @@ public class Program { Log.Debug("Inactive Subscriptions: "); - Dictionary expiredSubs = await m_ApiHelper.GetExpiredSubscriptions("/subscriptions/subscribes", Config.IncludeRestrictedSubscriptions, Config); - foreach (KeyValuePair expiredSub in expiredSubs) + Dictionary expiredSubs = await m_ApiHelper.GetExpiredSubscriptions("/subscriptions/subscribes", Config.IncludeRestrictedSubscriptions, Config); + foreach (KeyValuePair expiredSub in expiredSubs) { if (!users.ContainsKey(expiredSub.Key)) { @@ -955,7 +878,7 @@ public class Program } } - Dictionary lists = await m_ApiHelper.GetLists("/lists", Config); + Dictionary lists = await m_ApiHelper.GetLists("/lists", Config); // Remove users from the list if they are in the ignored list if (!string.IsNullOrEmpty(Config.IgnoredUsersListName)) @@ -973,28 +896,28 @@ public class Program } await dBHelper.CreateUsersDB(users); - KeyValuePair> hasSelectedUsersKVP; + KeyValuePair> hasSelectedUsersKVP; if(Config.NonInteractiveMode && Config.NonInteractiveModePurchasedTab) { - hasSelectedUsersKVP = new KeyValuePair>(true, new Dictionary { { "PurchasedTab", 0 } }); + hasSelectedUsersKVP = new KeyValuePair>(true, new Dictionary { { "PurchasedTab", 0 } }); } else if (Config.NonInteractiveMode && string.IsNullOrEmpty(Config.NonInteractiveModeListName)) { - hasSelectedUsersKVP = new KeyValuePair>(true, users); + hasSelectedUsersKVP = new KeyValuePair>(true, users); } else if (Config.NonInteractiveMode && !string.IsNullOrEmpty(Config.NonInteractiveModeListName)) { var listId = lists[Config.NonInteractiveModeListName]; var listUsernames = await m_ApiHelper.GetListUsers($"/lists/{listId}/users", Config) ?? []; var selectedUsers = users.Where(x => listUsernames.Contains(x.Key)).Distinct().ToDictionary(x => x.Key, x => x.Value); - hasSelectedUsersKVP = new KeyValuePair>(true, selectedUsers); + hasSelectedUsersKVP = new KeyValuePair>(true, selectedUsers); } else { var userSelectionResult = await HandleUserSelection(m_ApiHelper, Config, users, lists); Config = userSelectionResult.updatedConfig; - hasSelectedUsersKVP = new KeyValuePair>(userSelectionResult.IsExit, userSelectionResult.selectedUsers); + hasSelectedUsersKVP = new KeyValuePair>(userSelectionResult.IsExit, userSelectionResult.selectedUsers); } if (hasSelectedUsersKVP.Key && hasSelectedUsersKVP.Value != null && hasSelectedUsersKVP.Value.ContainsKey("SinglePost")) @@ -1060,9 +983,9 @@ public class Program } else if (hasSelectedUsersKVP.Key && hasSelectedUsersKVP.Value != null && hasSelectedUsersKVP.Value.ContainsKey("PurchasedTab")) { - Dictionary purchasedTabUsers = await m_ApiHelper.GetPurchasedTabUsers("/posts/paid/all", Config, users); + Dictionary purchasedTabUsers = await m_ApiHelper.GetPurchasedTabUsers("/posts/paid/all", Config, users); AnsiConsole.Markup($"[red]Checking folders for Users in Purchased Tab\n[/]"); - foreach (KeyValuePair user in purchasedTabUsers) + foreach (KeyValuePair user in purchasedTabUsers) { string path = ""; if (!string.IsNullOrEmpty(Config.DownloadPath)) @@ -1220,7 +1143,7 @@ public class Program else if (hasSelectedUsersKVP.Key && !hasSelectedUsersKVP.Value.ContainsKey("ConfigChanged")) { //Iterate over each user in the list of users - foreach (KeyValuePair user in hasSelectedUsersKVP.Value) + foreach (KeyValuePair user in hasSelectedUsersKVP.Value) { int paidPostCount = 0; int postCount = 0; @@ -1378,7 +1301,7 @@ public class Program return combinedConfig; } - private static async Task DownloadPaidMessages(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int paidMessagesCount, string path) + private static async Task DownloadPaidMessages(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int paidMessagesCount, string path) { Log.Debug($"Calling DownloadPaidMessages - {user.Key}"); @@ -1511,7 +1434,7 @@ public class Program return paidMessagesCount; } - private static async Task DownloadMessages(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int messagesCount, string path) + private static async Task DownloadMessages(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int messagesCount, string path) { Log.Debug($"Calling DownloadMessages - {user.Key}"); @@ -1644,7 +1567,7 @@ public class Program return messagesCount; } - private static async Task DownloadHighlights(IDownloadContext downloadContext, KeyValuePair user, int highlightsCount, string path) + private static async Task DownloadHighlights(IDownloadContext downloadContext, KeyValuePair user, int highlightsCount, string path) { Log.Debug($"Calling DownloadHighlights - {user.Key}"); @@ -1701,7 +1624,7 @@ public class Program return highlightsCount; } - private static async Task DownloadStories(IDownloadContext downloadContext, KeyValuePair user, int storiesCount, string path) + private static async Task DownloadStories(IDownloadContext downloadContext, KeyValuePair user, int storiesCount, string path) { Log.Debug($"Calling DownloadStories - {user.Key}"); @@ -1758,7 +1681,7 @@ public class Program return storiesCount; } - private static async Task DownloadArchived(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int archivedCount, string path) + private static async Task DownloadArchived(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int archivedCount, string path) { Log.Debug($"Calling DownloadArchived - {user.Key}"); @@ -1891,7 +1814,7 @@ public class Program return archivedCount; } - private static async Task DownloadFreePosts(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int postCount, string path) + private static async Task DownloadFreePosts(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int postCount, string path) { Log.Debug($"Calling DownloadFreePosts - {user.Key}"); @@ -2031,7 +1954,7 @@ public class Program return postCount; } - private static async Task DownloadPaidPosts(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int paidPostCount, string path) + private static async Task DownloadPaidPosts(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int paidPostCount, string path) { Log.Debug($"Calling DownloadPaidPosts - {user.Key}"); @@ -2164,7 +2087,7 @@ public class Program return paidPostCount; } - private static async Task DownloadPaidPostsPurchasedTab(IDownloadContext downloadContext, PaidPostCollection purchasedPosts, KeyValuePair user, int paidPostCount, string path, Dictionary users) + private static async Task DownloadPaidPostsPurchasedTab(IDownloadContext downloadContext, PaidPostCollection purchasedPosts, KeyValuePair user, int paidPostCount, string path, Dictionary users) { int oldPaidPostCount = 0; int newPaidPostCount = 0; @@ -2288,7 +2211,7 @@ public class Program return paidPostCount; } - private static async Task DownloadPaidMessagesPurchasedTab(IDownloadContext downloadContext, PaidMessageCollection paidMessageCollection, KeyValuePair user, int paidMessagesCount, string path, Dictionary users) + private static async Task DownloadPaidMessagesPurchasedTab(IDownloadContext downloadContext, PaidMessageCollection paidMessageCollection, KeyValuePair user, int paidMessagesCount, string path, Dictionary users) { int oldPaidMessagesCount = 0; int newPaidMessagesCount = 0; @@ -2413,7 +2336,7 @@ public class Program return paidMessagesCount; } - private static async Task DownloadStreams(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int streamsCount, string path) + private static async Task DownloadStreams(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, KeyValuePair user, int streamsCount, string path) { Log.Debug($"Calling DownloadStreams - {user.Key}"); @@ -2552,7 +2475,7 @@ public class Program return streamsCount; } - private static async Task DownloadPaidMessage(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, string username, int paidMessagesCount, string path, long message_id) + private static async Task DownloadPaidMessage(IDownloadContext downloadContext, KeyValuePair> hasSelectedUsersKVP, string username, int paidMessagesCount, string path, long message_id) { Log.Debug($"Calling DownloadPaidMessage - {username}"); @@ -2682,7 +2605,7 @@ public class Program return paidMessagesCount; } - private static async Task DownloadSinglePost(IDownloadContext downloadContext, long post_id, string path, Dictionary users) + private static async Task DownloadSinglePost(IDownloadContext downloadContext, long post_id, string path, Dictionary users) { Log.Debug($"Calling DownloadSinglePost - {post_id.ToString()}"); @@ -2800,10 +2723,10 @@ public class Program } } - public static async Task<(bool IsExit, Dictionary? selectedUsers, Entities.Config? updatedConfig)> HandleUserSelection(APIHelper apiHelper, Entities.Config currentConfig, Dictionary users, Dictionary lists) + public static async Task<(bool IsExit, Dictionary? selectedUsers, Entities.Config? updatedConfig)> HandleUserSelection(APIHelper apiHelper, Entities.Config currentConfig, Dictionary users, Dictionary lists) { bool hasSelectedUsers = false; - Dictionary selectedUsers = new Dictionary(); + Dictionary selectedUsers = new Dictionary(); while (!hasSelectedUsers) { @@ -2844,7 +2767,7 @@ public class Program List listUsernames = new(); foreach (var item in listSelection) { - long listId = lists[item.Replace("[red]", "").Replace("[/]", "")]; + int listId = lists[item.Replace("[red]", "").Replace("[/]", "")]; List usernames = await apiHelper.GetListUsers($"/lists/{listId}/users", config); foreach (string user in usernames) { @@ -2884,11 +2807,11 @@ public class Program } break; case "[red]Download Single Post[/]": - return (true, new Dictionary { { "SinglePost", 0 } }, currentConfig); + return (true, new Dictionary { { "SinglePost", 0 } }, currentConfig); case "[red]Download Single Paid Message[/]": - return (true, new Dictionary { { "SingleMessage", 0 } }, currentConfig); + return (true, new Dictionary { { "SingleMessage", 0 } }, currentConfig); case "[red]Download Purchased Tab[/]": - return (true, new Dictionary { { "PurchasedTab", 0 } }, currentConfig); + return (true, new Dictionary { { "PurchasedTab", 0 } }, currentConfig); case "[red]Edit config.conf[/]": while (true) { @@ -2956,9 +2879,7 @@ public class Program var hoconConfig = new StringBuilder(); hoconConfig.AppendLine("# Auth"); - hoconConfig.AppendLine("Auth {"); - hoconConfig.AppendLine($" DisableBrowserAuth = \"{newConfig.DisableBrowserAuth.ToString().ToLower()}\""); - hoconConfig.AppendLine("}"); + hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\""); @@ -3060,7 +2981,7 @@ public class Program currentConfig = newConfig; if (configChanged) { - return (true, new Dictionary { { "ConfigChanged", 0 } }, currentConfig); + return (true, new Dictionary { { "ConfigChanged", 0 } }, currentConfig); } break; } @@ -3118,9 +3039,7 @@ public class Program var hoconConfig = new StringBuilder(); hoconConfig.AppendLine("# Auth"); - hoconConfig.AppendLine("Auth {"); - hoconConfig.AppendLine($" DisableBrowserAuth = \"{newConfig.DisableBrowserAuth.ToString().ToLower()}\""); - hoconConfig.AppendLine("}"); + hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}"); hoconConfig.AppendLine("# External Tools"); hoconConfig.AppendLine("External {"); hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\""); @@ -3216,7 +3135,7 @@ public class Program if (configChanged) { - return (true, new Dictionary { { "ConfigChanged", 0 } }, currentConfig); + return (true, new Dictionary { { "ConfigChanged", 0 } }, currentConfig); } break; @@ -3242,7 +3161,7 @@ public class Program return (true, selectedUsers, currentConfig); // Return true to indicate selected users } - public static List GetMainMenuOptions(Dictionary users, Dictionary lists) + public static List GetMainMenuOptions(Dictionary users, Dictionary lists) { if (lists.Count > 0) { diff --git a/docs/config/all-configuration-options.md b/docs/config/all-configuration-options.md index 6769362..60583a6 100644 --- a/docs/config/all-configuration-options.md +++ b/docs/config/all-configuration-options.md @@ -516,23 +516,3 @@ Allowed values: Any positive integer or `-1` Description: You won't need to set this, but if you see errors about the configured timeout of 100 seconds elapsing then you could set this to be more than 100. It is recommended that you leave this as the default value. - -## DisableTextSanitization - -Type: `boolean` - -Default: `false` - -Allowed values: `true`, `false` - -Description: When enabled, post/message text is stored as-is without XML stripping. - -## DownloadVideoResolution - -Type: `string` - -Default: `"source"` - -Allowed values: `"source"`, `"240"`, `"720"` - -Description: This allows you to download videos in alternative resolutions, by default videos are downloaded in source resolution but some people prefer smoother videos at a lower resolution. \ No newline at end of file diff --git a/docs/config/configuration.md b/docs/config/configuration.md index 6f87744..83b1ece 100644 --- a/docs/config/configuration.md +++ b/docs/config/configuration.md @@ -20,8 +20,6 @@ information about what it does, its default value, and the allowed values. - [DownloadDateSelection](/config/all-configuration-options#downloaddateselection) - [CustomDate](/config/all-configuration-options#customdate) - [ShowScrapeSize](/config/all-configuration-options#showscrapesize) - - [DisableTextSanitization](/config/all-configuration-options#disabletextsanitization) - - [DownloadVideoResolution](/config/all-configuration-options#downloadvideoresolution) - Media - [DownloadAvatarHeaderPhoto](/config/all-configuration-options#downloadavatarheaderphoto) - [DownloadPaidPosts](/config/all-configuration-options#downloadpaidposts)