Changed config parsing to download all subscriptions by default

This commit is contained in:
Casper Sparre 2026-02-21 00:29:40 +01:00
parent 0f277c05ad
commit 120e09df8c
4 changed files with 10 additions and 23 deletions

View File

@ -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;
} }

View File

@ -2,7 +2,6 @@ namespace OF_DL.Models;
public enum EMode public enum EMode
{ {
None,
DownloadCreatorContent, DownloadCreatorContent,
OutputBlockedUsers, OutputBlockedUsers,
UpdateAllUserInfo UpdateAllUserInfo

View File

@ -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)
{ {

View File

@ -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();