From 27ea6a7323ed7d3682272bdc46068c736879e643 Mon Sep 17 00:00:00 2001 From: Casper Sparre Date: Mon, 6 Oct 2025 20:04:31 +0200 Subject: [PATCH] Fixed lookup for Paid Posts and Messages, due to API changes --- OF DL/Helpers/APIHelper.cs | 30 +++++++++++++++++++----------- OF DL/Program.cs | 4 ++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/OF DL/Helpers/APIHelper.cs b/OF DL/Helpers/APIHelper.cs index 6449549..9b790af 100644 --- a/OF DL/Helpers/APIHelper.cs +++ b/OF DL/Helpers/APIHelper.cs @@ -902,12 +902,14 @@ public class APIHelper : IAPIHelper Purchased paidPosts = new(); PaidPostCollection paidPostCollection = new(); int post_limit = 50; + int offset = 0; Dictionary getParams = new() { { "limit", post_limit.ToString() }, - { "order", "publish_date_desc" }, + { "skip_users", "all" }, { "format", "infinite" }, - { "user_id", username } + { "offset", offset.ToString() }, + { "author", username }, }; var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config)); @@ -917,9 +919,10 @@ public class APIHelper : IAPIHelper ctx.SpinnerStyle(Style.Parse("blue")); if (paidPosts != null && paidPosts.hasMore) { - getParams["offset"] = paidPosts.list.Count.ToString(); while (true) { + offset += post_limit; + getParams["offset"] = offset.ToString(); Purchased newPaidPosts = new(); @@ -934,7 +937,6 @@ public class APIHelper : IAPIHelper { break; } - getParams["offset"] = Convert.ToString(Convert.ToInt32(getParams["offset"]) + post_limit); } } @@ -1691,7 +1693,8 @@ public class APIHelper : IAPIHelper Dictionary getParams = new() { { "limit", post_limit.ToString() }, - { "order", "desc" } + { "order", "desc" }, + { "skip_users", "all" }, }; var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config)); @@ -1701,9 +1704,10 @@ public class APIHelper : IAPIHelper ctx.SpinnerStyle(Style.Parse("blue")); if (messages.hasMore) { - getParams["id"] = messages.list[^1].id.ToString(); while (true) { + getParams["id"] = messages.list[^1].id.ToString(); + Messages newmessages = new(); var loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config)); @@ -1717,7 +1721,6 @@ public class APIHelper : IAPIHelper { break; } - getParams["id"] = newmessages.list[newmessages.list.Count - 1].id.ToString(); } } @@ -2002,12 +2005,14 @@ public class APIHelper : IAPIHelper Purchased paidMessages = new(); PaidMessageCollection paidMessageCollection = new(); int post_limit = 50; + int offset = 0; Dictionary getParams = new() { { "limit", post_limit.ToString() }, - { "order", "publish_date_desc" }, + { "skip_users", "all" }, { "format", "infinite" }, - { "user_id", username } + { "offset", offset.ToString() }, + { "author", username }, }; var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config)); @@ -2017,9 +2022,11 @@ public class APIHelper : IAPIHelper ctx.SpinnerStyle(Style.Parse("blue")); if (paidMessages != null && paidMessages.hasMore) { - getParams["offset"] = paidMessages.list.Count.ToString(); while (true) { + offset += post_limit; + getParams["offset"] = offset.ToString(); + string loopqueryParams = "?" + string.Join("&", getParams.Select(kvp => $"{kvp.Key}={kvp.Value}")); Purchased newpaidMessages = new(); Dictionary loopheaders = GetDynamicHeaders("/api2/v2" + endpoint, loopqueryParams); @@ -2031,12 +2038,14 @@ public class APIHelper : IAPIHelper { looprequest.Headers.Add(keyValuePair.Key, keyValuePair.Value); } + using (var loopresponse = await loopclient.SendAsync(looprequest)) { loopresponse.EnsureSuccessStatusCode(); var loopbody = await loopresponse.Content.ReadAsStringAsync(); newpaidMessages = JsonConvert.DeserializeObject(loopbody, m_JsonSerializerSettings); } + paidMessages.list.AddRange(newpaidMessages.list); ctx.Status($"[red]Getting Paid Messages\n[/] [red]Found {paidMessages.list.Count}[/]"); ctx.Spinner(Spinner.Known.Dots); @@ -2045,7 +2054,6 @@ public class APIHelper : IAPIHelper { break; } - getParams["offset"] = Convert.ToString(Convert.ToInt32(getParams["offset"]) + post_limit); } } diff --git a/OF DL/Program.cs b/OF DL/Program.cs index 58ddc88..20d068a 100644 --- a/OF DL/Program.cs +++ b/OF DL/Program.cs @@ -1428,7 +1428,7 @@ public class Program await AnsiConsole.Status() .StartAsync("[red]Getting Paid Messages[/]", async ctx => { - paidMessageCollection = await downloadContext.ApiHelper.GetPaidMessages("/posts/paid", path, user.Key, downloadContext.DownloadConfig!, ctx); + paidMessageCollection = await downloadContext.ApiHelper.GetPaidMessages("/posts/paid/chat", path, user.Key, downloadContext.DownloadConfig!, ctx); }); int oldPaidMessagesCount = 0; int newPaidMessagesCount = 0; @@ -2091,7 +2091,7 @@ public class Program await AnsiConsole.Status() .StartAsync("[red]Getting Paid Posts[/]", async ctx => { - purchasedPosts = await downloadContext.ApiHelper.GetPaidPosts("/posts/paid", path, user.Key, downloadContext.DownloadConfig!, paid_post_ids, ctx); + purchasedPosts = await downloadContext.ApiHelper.GetPaidPosts("/posts/paid/post", path, user.Key, downloadContext.DownloadConfig!, paid_post_ids, ctx); }); int oldPaidPostCount = 0;