forked from sim0n00ps/OF-DL
Fixed lookup for Paid Posts and Messages, due to API changes
This commit is contained in:
parent
1d587eeccb
commit
27ea6a7323
@ -902,12 +902,14 @@ public class APIHelper : IAPIHelper
|
||||
Purchased paidPosts = new();
|
||||
PaidPostCollection paidPostCollection = new();
|
||||
int post_limit = 50;
|
||||
int offset = 0;
|
||||
Dictionary<string, string> 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<string, string> 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<string, string> 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<string, string> 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<Purchased>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user