forked from sim0n00ps/OF-DL
Compare commits
2 Commits
1d587eeccb
...
5588619cf5
| Author | SHA1 | Date | |
|---|---|---|---|
| 5588619cf5 | |||
| 27ea6a7323 |
@ -893,7 +893,7 @@ public class APIHelper : IAPIHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx)
|
public async Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, int userId, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx)
|
||||||
{
|
{
|
||||||
Log.Debug($"Calling GetPaidPosts - {username}");
|
Log.Debug($"Calling GetPaidPosts - {username}");
|
||||||
|
|
||||||
@ -902,12 +902,14 @@ public class APIHelper : IAPIHelper
|
|||||||
Purchased paidPosts = new();
|
Purchased paidPosts = new();
|
||||||
PaidPostCollection paidPostCollection = new();
|
PaidPostCollection paidPostCollection = new();
|
||||||
int post_limit = 50;
|
int post_limit = 50;
|
||||||
|
int offset = 0;
|
||||||
Dictionary<string, string> getParams = new()
|
Dictionary<string, string> getParams = new()
|
||||||
{
|
{
|
||||||
{ "limit", post_limit.ToString() },
|
{ "limit", post_limit.ToString() },
|
||||||
{ "order", "publish_date_desc" },
|
{ "skip_users", "all" },
|
||||||
{ "format", "infinite" },
|
{ "format", "infinite" },
|
||||||
{ "user_id", username }
|
{ "offset", offset.ToString() },
|
||||||
|
{ "author", username },
|
||||||
};
|
};
|
||||||
|
|
||||||
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
||||||
@ -917,9 +919,10 @@ public class APIHelper : IAPIHelper
|
|||||||
ctx.SpinnerStyle(Style.Parse("blue"));
|
ctx.SpinnerStyle(Style.Parse("blue"));
|
||||||
if (paidPosts != null && paidPosts.hasMore)
|
if (paidPosts != null && paidPosts.hasMore)
|
||||||
{
|
{
|
||||||
getParams["offset"] = paidPosts.list.Count.ToString();
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
offset += post_limit;
|
||||||
|
getParams["offset"] = offset.ToString();
|
||||||
|
|
||||||
Purchased newPaidPosts = new();
|
Purchased newPaidPosts = new();
|
||||||
|
|
||||||
@ -934,7 +937,6 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getParams["offset"] = Convert.ToString(Convert.ToInt32(getParams["offset"]) + post_limit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -943,6 +945,9 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
if (purchase.responseType == "post" && purchase.media != null && purchase.media.Count > 0)
|
if (purchase.responseType == "post" && purchase.media != null && purchase.media.Count > 0)
|
||||||
{
|
{
|
||||||
|
if (purchase.fromUser.id != userId)
|
||||||
|
continue; // Ensures only posts from current model are included
|
||||||
|
|
||||||
List<long> previewids = new();
|
List<long> previewids = new();
|
||||||
if (purchase.previews != null)
|
if (purchase.previews != null)
|
||||||
{
|
{
|
||||||
@ -1691,7 +1696,8 @@ public class APIHelper : IAPIHelper
|
|||||||
Dictionary<string, string> getParams = new()
|
Dictionary<string, string> getParams = new()
|
||||||
{
|
{
|
||||||
{ "limit", post_limit.ToString() },
|
{ "limit", post_limit.ToString() },
|
||||||
{ "order", "desc" }
|
{ "order", "desc" },
|
||||||
|
{ "skip_users", "all" },
|
||||||
};
|
};
|
||||||
|
|
||||||
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
||||||
@ -1701,9 +1707,10 @@ public class APIHelper : IAPIHelper
|
|||||||
ctx.SpinnerStyle(Style.Parse("blue"));
|
ctx.SpinnerStyle(Style.Parse("blue"));
|
||||||
if (messages.hasMore)
|
if (messages.hasMore)
|
||||||
{
|
{
|
||||||
getParams["id"] = messages.list[^1].id.ToString();
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
getParams["id"] = messages.list[^1].id.ToString();
|
||||||
|
|
||||||
Messages newmessages = new();
|
Messages newmessages = new();
|
||||||
|
|
||||||
var loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
var loopbody = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
||||||
@ -1717,7 +1724,6 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getParams["id"] = newmessages.list[newmessages.list.Count - 1].id.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1993,7 +1999,7 @@ public class APIHelper : IAPIHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, IDownloadConfig config, StatusContext ctx)
|
public async Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, int userId, IDownloadConfig config, StatusContext ctx)
|
||||||
{
|
{
|
||||||
Log.Debug($"Calling GetPaidMessages - {username}");
|
Log.Debug($"Calling GetPaidMessages - {username}");
|
||||||
|
|
||||||
@ -2002,12 +2008,14 @@ public class APIHelper : IAPIHelper
|
|||||||
Purchased paidMessages = new();
|
Purchased paidMessages = new();
|
||||||
PaidMessageCollection paidMessageCollection = new();
|
PaidMessageCollection paidMessageCollection = new();
|
||||||
int post_limit = 50;
|
int post_limit = 50;
|
||||||
|
int offset = 0;
|
||||||
Dictionary<string, string> getParams = new()
|
Dictionary<string, string> getParams = new()
|
||||||
{
|
{
|
||||||
{ "limit", post_limit.ToString() },
|
{ "limit", post_limit.ToString() },
|
||||||
{ "order", "publish_date_desc" },
|
{ "skip_users", "all" },
|
||||||
{ "format", "infinite" },
|
{ "format", "infinite" },
|
||||||
{ "user_id", username }
|
{ "offset", offset.ToString() },
|
||||||
|
{ "author", username },
|
||||||
};
|
};
|
||||||
|
|
||||||
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
||||||
@ -2017,9 +2025,11 @@ public class APIHelper : IAPIHelper
|
|||||||
ctx.SpinnerStyle(Style.Parse("blue"));
|
ctx.SpinnerStyle(Style.Parse("blue"));
|
||||||
if (paidMessages != null && paidMessages.hasMore)
|
if (paidMessages != null && paidMessages.hasMore)
|
||||||
{
|
{
|
||||||
getParams["offset"] = paidMessages.list.Count.ToString();
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
offset += post_limit;
|
||||||
|
getParams["offset"] = offset.ToString();
|
||||||
|
|
||||||
string loopqueryParams = "?" + string.Join("&", getParams.Select(kvp => $"{kvp.Key}={kvp.Value}"));
|
string loopqueryParams = "?" + string.Join("&", getParams.Select(kvp => $"{kvp.Key}={kvp.Value}"));
|
||||||
Purchased newpaidMessages = new();
|
Purchased newpaidMessages = new();
|
||||||
Dictionary<string, string> loopheaders = GetDynamicHeaders("/api2/v2" + endpoint, loopqueryParams);
|
Dictionary<string, string> loopheaders = GetDynamicHeaders("/api2/v2" + endpoint, loopqueryParams);
|
||||||
@ -2031,12 +2041,14 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
looprequest.Headers.Add(keyValuePair.Key, keyValuePair.Value);
|
looprequest.Headers.Add(keyValuePair.Key, keyValuePair.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var loopresponse = await loopclient.SendAsync(looprequest))
|
using (var loopresponse = await loopclient.SendAsync(looprequest))
|
||||||
{
|
{
|
||||||
loopresponse.EnsureSuccessStatusCode();
|
loopresponse.EnsureSuccessStatusCode();
|
||||||
var loopbody = await loopresponse.Content.ReadAsStringAsync();
|
var loopbody = await loopresponse.Content.ReadAsStringAsync();
|
||||||
newpaidMessages = JsonConvert.DeserializeObject<Purchased>(loopbody, m_JsonSerializerSettings);
|
newpaidMessages = JsonConvert.DeserializeObject<Purchased>(loopbody, m_JsonSerializerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
paidMessages.list.AddRange(newpaidMessages.list);
|
paidMessages.list.AddRange(newpaidMessages.list);
|
||||||
ctx.Status($"[red]Getting Paid Messages\n[/] [red]Found {paidMessages.list.Count}[/]");
|
ctx.Status($"[red]Getting Paid Messages\n[/] [red]Found {paidMessages.list.Count}[/]");
|
||||||
ctx.Spinner(Spinner.Known.Dots);
|
ctx.Spinner(Spinner.Known.Dots);
|
||||||
@ -2045,16 +2057,21 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getParams["offset"] = Convert.ToString(Convert.ToInt32(getParams["offset"]) + post_limit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paidMessages.list != null && paidMessages.list.Count > 0)
|
if (paidMessages.list != null && paidMessages.list.Count > 0)
|
||||||
{
|
{
|
||||||
|
int ownUserId = Convert.ToInt32(auth.USER_ID);
|
||||||
|
int[] validUserIds = [ownUserId, userId];
|
||||||
|
|
||||||
foreach (Purchased.List purchase in paidMessages.list.Where(p => p.responseType == "message").OrderByDescending(p => p.postedAt ?? p.createdAt))
|
foreach (Purchased.List purchase in paidMessages.list.Where(p => p.responseType == "message").OrderByDescending(p => p.postedAt ?? p.createdAt))
|
||||||
{
|
{
|
||||||
if (!config.IgnoreOwnMessages || purchase.fromUser.id != Convert.ToInt32(auth.USER_ID))
|
if (!config.IgnoreOwnMessages || purchase.fromUser.id != ownUserId)
|
||||||
{
|
{
|
||||||
|
if (!validUserIds.Contains(purchase.fromUser.id))
|
||||||
|
continue; // Ensures only messages from current model (or self) are included
|
||||||
|
|
||||||
if (purchase.postedAt != null)
|
if (purchase.postedAt != null)
|
||||||
{
|
{
|
||||||
await m_DBHelper.AddMessage(folder, purchase.id, purchase.text != null ? purchase.text : string.Empty, purchase.price != null ? purchase.price : "0", true, false, purchase.postedAt.Value, purchase.fromUser.id);
|
await m_DBHelper.AddMessage(folder, purchase.id, purchase.text != null ? purchase.text : string.Empty, purchase.price != null ? purchase.price : "0", true, false, purchase.postedAt.Value, purchase.fromUser.id);
|
||||||
|
|||||||
@ -20,13 +20,13 @@ namespace OF_DL.Helpers
|
|||||||
Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config);
|
Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config);
|
||||||
Task<Dictionary<string, int>?> GetUsersFromList(string endpoint, bool includeRestricted, IDownloadConfig config);
|
Task<Dictionary<string, int>?> GetUsersFromList(string endpoint, bool includeRestricted, IDownloadConfig config);
|
||||||
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, IDownloadConfig config, List<long> paid_post_ids);
|
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, IDownloadConfig config, List<long> paid_post_ids);
|
||||||
Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, int userId, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
||||||
Task<PostCollection> GetPosts(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
Task<PostCollection> GetPosts(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
||||||
Task<SinglePostCollection> GetPost(string endpoint, string folder, IDownloadConfig config);
|
Task<SinglePostCollection> GetPost(string endpoint, string folder, IDownloadConfig config);
|
||||||
Task<StreamsCollection> GetStreams(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
Task<StreamsCollection> GetStreams(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
|
||||||
Task<ArchivedCollection> GetArchived(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
|
Task<ArchivedCollection> GetArchived(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
|
||||||
Task<MessageCollection> GetMessages(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
|
Task<MessageCollection> GetMessages(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
|
||||||
Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, IDownloadConfig config, StatusContext ctx);
|
Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, int userId, IDownloadConfig config, StatusContext ctx);
|
||||||
Task<Dictionary<string, int>> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary<string, int> users);
|
Task<Dictionary<string, int>> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary<string, int> users);
|
||||||
Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary<string, int> users);
|
Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary<string, int> users);
|
||||||
Task<User> GetUserInfo(string endpoint);
|
Task<User> GetUserInfo(string endpoint);
|
||||||
|
|||||||
@ -1356,15 +1356,15 @@ public class Program
|
|||||||
|
|
||||||
AnsiConsole.Markup("\n");
|
AnsiConsole.Markup("\n");
|
||||||
AnsiConsole.Write(new BreakdownChart()
|
AnsiConsole.Write(new BreakdownChart()
|
||||||
.FullSize()
|
.FullSize()
|
||||||
.AddItem("Paid Posts", paidPostCount, Color.Red)
|
.AddItem("Paid Posts", paidPostCount, Color.Red)
|
||||||
.AddItem("Posts", postCount, Color.Blue)
|
.AddItem("Posts", postCount, Color.Blue)
|
||||||
.AddItem("Archived", archivedCount, Color.Green)
|
.AddItem("Archived", archivedCount, Color.Green)
|
||||||
.AddItem("Streams", streamsCount, Color.Purple)
|
.AddItem("Streams", streamsCount, Color.Purple)
|
||||||
.AddItem("Stories", storiesCount, Color.Yellow)
|
.AddItem("Stories", storiesCount, Color.Yellow)
|
||||||
.AddItem("Highlights", highlightsCount, Color.Orange1)
|
.AddItem("Highlights", highlightsCount, Color.Orange1)
|
||||||
.AddItem("Messages", messagesCount, Color.LightGreen)
|
.AddItem("Messages", messagesCount, Color.LightGreen)
|
||||||
.AddItem("Paid Messages", paidMessagesCount, Color.Aqua));
|
.AddItem("Paid Messages", paidMessagesCount, Color.Aqua));
|
||||||
AnsiConsole.Markup("\n");
|
AnsiConsole.Markup("\n");
|
||||||
}
|
}
|
||||||
DateTime endTime = DateTime.Now;
|
DateTime endTime = DateTime.Now;
|
||||||
@ -1428,7 +1428,7 @@ public class Program
|
|||||||
await AnsiConsole.Status()
|
await AnsiConsole.Status()
|
||||||
.StartAsync("[red]Getting Paid Messages[/]", async ctx =>
|
.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, user.Value, downloadContext.DownloadConfig!, ctx);
|
||||||
});
|
});
|
||||||
int oldPaidMessagesCount = 0;
|
int oldPaidMessagesCount = 0;
|
||||||
int newPaidMessagesCount = 0;
|
int newPaidMessagesCount = 0;
|
||||||
@ -2091,7 +2091,7 @@ public class Program
|
|||||||
await AnsiConsole.Status()
|
await AnsiConsole.Status()
|
||||||
.StartAsync("[red]Getting Paid Posts[/]", async ctx =>
|
.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, user.Value, downloadContext.DownloadConfig!, paid_post_ids, ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
int oldPaidPostCount = 0;
|
int oldPaidPostCount = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user