forked from sim0n00ps/OF-DL
Added logic to save list of blocked users.
This commit is contained in:
parent
499f13dba9
commit
5effa47fac
@ -106,6 +106,8 @@ namespace OF_DL.Entities
|
||||
|
||||
public string[] NonInteractiveSpecificUsers { get; set; } = [];
|
||||
public string[] NonInteractiveSpecificLists { get; set; } = [];
|
||||
|
||||
public bool OutputBlockedUsers { get; set; }
|
||||
}
|
||||
|
||||
public class CreatorConfig : IFileNameFormatConfig
|
||||
|
@ -382,7 +382,6 @@ public class APIHelper : IAPIHelper
|
||||
|
||||
public async Task<Dictionary<string, int>?> GetExpiredSubscriptions(string endpoint, bool includeRestricted, IDownloadConfig config)
|
||||
{
|
||||
|
||||
Dictionary<string, string> getParams = new()
|
||||
{
|
||||
{ "offset", "0" },
|
||||
@ -396,6 +395,20 @@ public class APIHelper : IAPIHelper
|
||||
return await GetAllSubscriptions(getParams, endpoint, includeRestricted, config);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, int>?> GetBlockedUsers(string endpoint, IDownloadConfig config)
|
||||
{
|
||||
Dictionary<string, string> getParams = new()
|
||||
{
|
||||
{ "offset", "0" },
|
||||
{ "limit", "50" },
|
||||
{ "type", "expired" },
|
||||
{ "format", "infinite"}
|
||||
};
|
||||
|
||||
Log.Debug("Calling GetBlockedUsers");
|
||||
|
||||
return await GetAllSubscriptions(getParams, endpoint, true, config);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, int>> GetLists(string endpoint, IDownloadConfig config)
|
||||
{
|
||||
@ -2143,11 +2156,11 @@ public class APIHelper : IAPIHelper
|
||||
{
|
||||
JObject user = await GetUserInfoById($"/users/list?x[]={purchase.fromUser.id}");
|
||||
|
||||
if(user is null)
|
||||
if (user is null)
|
||||
{
|
||||
if (!config.BypassContentForCreatorsWhoNoLongerExist)
|
||||
{
|
||||
if(!purchasedTabUsers.ContainsKey($"Deleted User - {purchase.fromUser.id}"))
|
||||
if (!purchasedTabUsers.ContainsKey($"Deleted User - {purchase.fromUser.id}"))
|
||||
{
|
||||
purchasedTabUsers.Add($"Deleted User - {purchase.fromUser.id}", purchase.fromUser.id);
|
||||
}
|
||||
@ -2197,7 +2210,7 @@ public class APIHelper : IAPIHelper
|
||||
{
|
||||
if (!config.BypassContentForCreatorsWhoNoLongerExist)
|
||||
{
|
||||
if(!purchasedTabUsers.ContainsKey($"Deleted User - {purchase.author.id}"))
|
||||
if (!purchasedTabUsers.ContainsKey($"Deleted User - {purchase.author.id}"))
|
||||
{
|
||||
purchasedTabUsers.Add($"Deleted User - {purchase.author.id}", purchase.author.id);
|
||||
}
|
||||
|
@ -515,6 +515,14 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
const string OUTPUT_BLOCKED_USERS_ARG = "--output-blocked";
|
||||
|
||||
if (args.Any(a => OUTPUT_BLOCKED_USERS_ARG.Equals(a, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
config.NonInteractiveMode = true;
|
||||
config.OutputBlockedUsers = true;
|
||||
}
|
||||
|
||||
Log.Debug("Additional arguments:");
|
||||
foreach (string argument in args)
|
||||
{
|
||||
@ -810,6 +818,12 @@ public class Program
|
||||
|
||||
try
|
||||
{
|
||||
if (config.OutputBlockedUsers)
|
||||
{
|
||||
await DownloadBlockedUsers(apiHelper, config);
|
||||
return;
|
||||
}
|
||||
|
||||
await DownloadAllData(apiHelper, auth, config);
|
||||
}
|
||||
finally
|
||||
@ -836,8 +850,29 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task DownloadBlockedUsers(APIHelper m_ApiHelper, Entities.Config Config)
|
||||
{
|
||||
const string OUTPUT_FILE = "blocked-users.json";
|
||||
|
||||
private static async Task DownloadAllData(APIHelper m_ApiHelper, Auth Auth, Entities.Config Config)
|
||||
Log.Debug($"Calling GetBlockedUsers");
|
||||
|
||||
AnsiConsole.Markup($"[red]Getting Blocked Users\n[/]");
|
||||
|
||||
Dictionary<string, int>? blockedUsers = await m_ApiHelper.GetBlockedUsers("/users/blocked", Config);
|
||||
|
||||
if (blockedUsers is null || blockedUsers.Count == 0)
|
||||
{
|
||||
AnsiConsole.Markup($"[red]No Blocked Users found.\n[/]");
|
||||
}
|
||||
else
|
||||
{
|
||||
AnsiConsole.Markup($"[red]Found {blockedUsers.Count} Blocked Users, saving to '{OUTPUT_FILE}'\n[/]");
|
||||
string json = JsonConvert.SerializeObject(blockedUsers, Formatting.Indented);
|
||||
await File.WriteAllTextAsync(OUTPUT_FILE, json);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task DownloadAllData(APIHelper m_ApiHelper, Auth Auth, Entities.Config Config)
|
||||
{
|
||||
DBHelper dBHelper = new DBHelper(Config);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user