forked from sim0n00ps/OF-DL
Changed config parsing to download all subscriptions by default
This commit is contained in:
parent
21efebe74f
commit
8d783b512c
@ -5,7 +5,5 @@ public class CajetanConfig
|
|||||||
public string[] NonInteractiveSpecificLists { get; set; } = [];
|
public string[] NonInteractiveSpecificLists { get; set; } = [];
|
||||||
public string[] NonInteractiveSpecificUsers { get; set; } = [];
|
public string[] NonInteractiveSpecificUsers { get; set; } = [];
|
||||||
|
|
||||||
public EMode Mode { get; set; } = EMode.None;
|
public EMode Mode { get; set; } = EMode.DownloadCreatorContent;
|
||||||
|
|
||||||
public string ErrorMessage { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ namespace OF_DL.Models;
|
|||||||
|
|
||||||
public enum EMode
|
public enum EMode
|
||||||
{
|
{
|
||||||
None,
|
|
||||||
DownloadCreatorContent,
|
DownloadCreatorContent,
|
||||||
OutputBlockedUsers,
|
OutputBlockedUsers,
|
||||||
UpdateAllUserInfo
|
UpdateAllUserInfo
|
||||||
|
|||||||
@ -49,14 +49,7 @@ static async Task<ServiceCollection> ConfigureServices(string[] args)
|
|||||||
|
|
||||||
AnsiConsole.Markup("[green]config.conf located successfully!\n[/]");
|
AnsiConsole.Markup("[green]config.conf located successfully!\n[/]");
|
||||||
|
|
||||||
if (!ParseCommandlineArgs(args, configService.CurrentConfig, out CajetanConfig cajetanConfig))
|
CajetanConfig cajetanConfig = ParseCommandlineArgs(args, configService.CurrentConfig);
|
||||||
{
|
|
||||||
AnsiConsole.MarkupLine($"\n[red]{cajetanConfig.ErrorMessage}[/]\n");
|
|
||||||
AnsiConsole.MarkupLine("[red]Press any key to exit.[/]");
|
|
||||||
Console.ReadKey();
|
|
||||||
|
|
||||||
exitHelper.ExitWithCode(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up full dependency injection with loaded config
|
// Set up full dependency injection with loaded config
|
||||||
services = [];
|
services = [];
|
||||||
@ -90,26 +83,26 @@ static async Task<ServiceCollection> ConfigureServices(string[] args)
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseCommandlineArgs(string[] args, Config currentConfig, out CajetanConfig parsedConfig)
|
static CajetanConfig ParseCommandlineArgs(string[] args, Config currentConfig)
|
||||||
{
|
{
|
||||||
const string SPECIFIC_LISTS_ARG = "--specific-lists";
|
const string SPECIFIC_LISTS_ARG = "--specific-lists";
|
||||||
const string SPECIFIC_USERS_ARG = "--specific-users";
|
const string SPECIFIC_USERS_ARG = "--specific-users";
|
||||||
const string OUTPUT_BLOCKED_USERS_ARG = "--output-blocked";
|
const string OUTPUT_BLOCKED_USERS_ARG = "--output-blocked";
|
||||||
const string UPDATE_ALL_USER_INFO_ARG = "--update-userinfo";
|
const string UPDATE_ALL_USER_INFO_ARG = "--update-userinfo";
|
||||||
|
|
||||||
parsedConfig = new();
|
CajetanConfig parsedConfig = new();
|
||||||
|
|
||||||
if (ParseListAndUserArguments(ref parsedConfig))
|
if (ParseListAndUserArguments(ref parsedConfig))
|
||||||
return true;
|
return parsedConfig;
|
||||||
|
|
||||||
if (ParseFlagArgument(OUTPUT_BLOCKED_USERS_ARG, EMode.OutputBlockedUsers, ref parsedConfig))
|
if (ParseFlagArgument(OUTPUT_BLOCKED_USERS_ARG, EMode.OutputBlockedUsers, ref parsedConfig))
|
||||||
return true;
|
return parsedConfig;
|
||||||
|
|
||||||
if (ParseFlagArgument(UPDATE_ALL_USER_INFO_ARG, EMode.UpdateAllUserInfo, ref parsedConfig))
|
if (ParseFlagArgument(UPDATE_ALL_USER_INFO_ARG, EMode.UpdateAllUserInfo, ref parsedConfig))
|
||||||
return true;
|
return parsedConfig;
|
||||||
|
|
||||||
parsedConfig.ErrorMessage = "No mode argument provided!";
|
// Will process all active subscriptions
|
||||||
return false;
|
return parsedConfig;
|
||||||
|
|
||||||
bool ParseListAndUserArguments(ref CajetanConfig parsedConfig)
|
bool ParseListAndUserArguments(ref CajetanConfig parsedConfig)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -134,7 +134,7 @@ internal class Worker(IServiceProvider serviceProvider)
|
|||||||
DateTime startTime = DateTime.Now;
|
DateTime startTime = DateTime.Now;
|
||||||
|
|
||||||
UserListResult allUsersAndLists = await GetAvailableUsersAsync();
|
UserListResult allUsersAndLists = await GetAvailableUsersAsync();
|
||||||
Dictionary<string, long> usersToDownload = [];
|
Dictionary<string, long> usersToDownload = allUsersAndLists.Users;
|
||||||
|
|
||||||
if (_cajetanConfig.NonInteractiveSpecificLists is not null && _cajetanConfig.NonInteractiveSpecificLists.Length > 0)
|
if (_cajetanConfig.NonInteractiveSpecificLists is not null && _cajetanConfig.NonInteractiveSpecificLists.Length > 0)
|
||||||
usersToDownload = await GetUsersFromSpecificListsAsync(allUsersAndLists, _cajetanConfig.NonInteractiveSpecificLists);
|
usersToDownload = await GetUsersFromSpecificListsAsync(allUsersAndLists, _cajetanConfig.NonInteractiveSpecificLists);
|
||||||
@ -142,9 +142,6 @@ internal class Worker(IServiceProvider serviceProvider)
|
|||||||
else if (_cajetanConfig.NonInteractiveSpecificUsers is not null && _cajetanConfig.NonInteractiveSpecificUsers.Length > 0)
|
else if (_cajetanConfig.NonInteractiveSpecificUsers is not null && _cajetanConfig.NonInteractiveSpecificUsers.Length > 0)
|
||||||
usersToDownload = GetUsersFromSpecificUsernames(allUsersAndLists, [.. _cajetanConfig.NonInteractiveSpecificUsers]);
|
usersToDownload = GetUsersFromSpecificUsernames(allUsersAndLists, [.. _cajetanConfig.NonInteractiveSpecificUsers]);
|
||||||
|
|
||||||
if (usersToDownload.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int userNum = 0;
|
int userNum = 0;
|
||||||
int userCount = usersToDownload.Count;
|
int userCount = usersToDownload.Count;
|
||||||
CajetanDownloadEventHandler eventHandler = new();
|
CajetanDownloadEventHandler eventHandler = new();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user