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