forked from sim0n00ps/OF-DL
Compare commits
2 Commits
a142c43b45
...
4b16455440
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b16455440 | |||
| 202558dd88 |
@ -726,7 +726,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}");
|
||||||
|
|
||||||
@ -735,12 +735,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));
|
||||||
@ -750,9 +752,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();
|
||||||
|
|
||||||
@ -767,7 +770,6 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getParams["offset"] = Convert.ToString(Convert.ToInt32(getParams["offset"]) + post_limit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -776,6 +778,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)
|
||||||
{
|
{
|
||||||
@ -1524,7 +1529,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));
|
||||||
@ -1534,9 +1540,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));
|
||||||
@ -1550,7 +1557,6 @@ public class APIHelper : IAPIHelper
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getParams["id"] = newmessages.list[newmessages.list.Count - 1].id.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,7 +1832,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}");
|
||||||
|
|
||||||
@ -1835,12 +1841,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));
|
||||||
@ -1850,9 +1858,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);
|
||||||
@ -1864,12 +1874,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);
|
||||||
@ -1878,16 +1890,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);
|
||||||
|
|||||||
@ -19,13 +19,13 @@ namespace OF_DL.Helpers
|
|||||||
Task<Dictionary<string, int>> GetLists(string endpoint, IDownloadConfig config);
|
Task<Dictionary<string, int>> GetLists(string endpoint, IDownloadConfig config);
|
||||||
Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config);
|
Task<List<string>> GetListUsers(string endpoint, 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);
|
||||||
|
|||||||
@ -1231,15 +1231,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;
|
||||||
@ -1303,7 +1303,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;
|
||||||
@ -1956,7 +1956,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