forked from sim0n00ps/OF-DL
Add CLI flag for hiding private info for demo use
This commit is contained in:
parent
162811b267
commit
7667939eba
@ -7,8 +7,13 @@ namespace OF_DL.Gui;
|
|||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
|
public static bool HidePrivateInfo { get; private set; }
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
// Parse command line arguments
|
||||||
|
HidePrivateInfo = args.Contains("--hide-private-info", StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
ServiceCollection services = new();
|
ServiceCollection services = new();
|
||||||
services.AddSingleton<ILoggingService, LoggingService>();
|
services.AddSingleton<ILoggingService, LoggingService>();
|
||||||
ServiceProvider tempProvider = services.BuildServiceProvider();
|
ServiceProvider tempProvider = services.BuildServiceProvider();
|
||||||
|
|||||||
@ -158,12 +158,19 @@ public partial class ConfigFieldViewModel : ViewModelBase
|
|||||||
|
|
||||||
[ObservableProperty] private decimal? _numericValue;
|
[ObservableProperty] private decimal? _numericValue;
|
||||||
|
|
||||||
[ObservableProperty] private string _textValue = string.Empty;
|
private string _actualTextValue = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _textValue = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[NotifyCanExecuteChangedFor(nameof(InsertSelectedFileNameVariableCommand))]
|
[NotifyCanExecuteChangedFor(nameof(InsertSelectedFileNameVariableCommand))]
|
||||||
private string? _selectedFileNameVariable;
|
private string? _selectedFileNameVariable;
|
||||||
|
|
||||||
|
private bool IsPathField =>
|
||||||
|
string.Equals(PropertyName, nameof(Config.FFmpegPath), StringComparison.Ordinal) ||
|
||||||
|
string.Equals(PropertyName, nameof(Config.DownloadPath), StringComparison.Ordinal);
|
||||||
|
|
||||||
[ObservableProperty] private ConfigSelectOptionViewModel? _selectedIgnoredUsersListOption;
|
[ObservableProperty] private ConfigSelectOptionViewModel? _selectedIgnoredUsersListOption;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@ -217,7 +224,9 @@ public partial class ConfigFieldViewModel : ViewModelBase
|
|||||||
|
|
||||||
if (PropertyType == typeof(string))
|
if (PropertyType == typeof(string))
|
||||||
{
|
{
|
||||||
value = TextValue.Trim();
|
// Use actual value for path fields when privacy mode is enabled
|
||||||
|
string textToUse = (Program.HidePrivateInfo && IsPathField) ? _actualTextValue : TextValue;
|
||||||
|
value = textToUse.Trim();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +360,12 @@ public partial class ConfigFieldViewModel : ViewModelBase
|
|||||||
|
|
||||||
partial void OnTextValueChanged(string value)
|
partial void OnTextValueChanged(string value)
|
||||||
{
|
{
|
||||||
|
// Store actual value if not the privacy placeholder
|
||||||
|
if (value != "[Hidden for Privacy]")
|
||||||
|
{
|
||||||
|
_actualTextValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsFileNameFormatField)
|
if (!IsFileNameFormatField)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -424,7 +439,18 @@ public partial class ConfigFieldViewModel : ViewModelBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextValue = initialValue?.ToString() ?? string.Empty;
|
string initialText = initialValue?.ToString() ?? string.Empty;
|
||||||
|
_actualTextValue = initialText;
|
||||||
|
|
||||||
|
// Show privacy placeholder for path fields if flag is set
|
||||||
|
if (Program.HidePrivateInfo && IsPathField && !string.IsNullOrWhiteSpace(initialText))
|
||||||
|
{
|
||||||
|
TextValue = "[Hidden for Privacy]";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextValue = initialText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetAllowedFileNameVariables() =>
|
private IEnumerable<string> GetAllowedFileNameVariables() =>
|
||||||
|
|||||||
@ -163,12 +163,17 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
[ObservableProperty] private string _errorMessage = string.Empty;
|
[ObservableProperty] private string _errorMessage = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty] private string _ffmpegPath = string.Empty;
|
private string _actualFfmpegPath = string.Empty;
|
||||||
|
private string _actualDownloadPath = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty] [NotifyPropertyChangedFor(nameof(FfmpegPathDisplay))]
|
||||||
|
private string _ffmpegPath = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasFfmpegPathError))]
|
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasFfmpegPathError))]
|
||||||
private string _ffmpegPathError = string.Empty;
|
private string _ffmpegPathError = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty] private string _downloadPath = string.Empty;
|
[ObservableProperty] [NotifyPropertyChangedFor(nameof(DownloadPathDisplay))]
|
||||||
|
private string _downloadPath = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasDownloadPathError))]
|
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasDownloadPathError))]
|
||||||
private string _downloadPathError = string.Empty;
|
private string _downloadPathError = string.Empty;
|
||||||
@ -183,6 +188,8 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
[ObservableProperty] private bool _isAuthenticated;
|
[ObservableProperty] private bool _isAuthenticated;
|
||||||
|
|
||||||
|
public bool HidePrivateInfo { get; } = Program.HidePrivateInfo;
|
||||||
|
|
||||||
[ObservableProperty] private string? _selectedListName;
|
[ObservableProperty] private string? _selectedListName;
|
||||||
|
|
||||||
[ObservableProperty] private bool _hasInitialized;
|
[ObservableProperty] private bool _hasInitialized;
|
||||||
@ -217,6 +224,10 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
public bool HasMediaSourcesError => !string.IsNullOrWhiteSpace(MediaSourcesError);
|
public bool HasMediaSourcesError => !string.IsNullOrWhiteSpace(MediaSourcesError);
|
||||||
|
|
||||||
|
public string FfmpegPathDisplay => HidePrivateInfo && !string.IsNullOrWhiteSpace(FfmpegPath) ? "[Hidden for Privacy]" : FfmpegPath;
|
||||||
|
|
||||||
|
public string DownloadPathDisplay => HidePrivateInfo && !string.IsNullOrWhiteSpace(DownloadPath) ? "[Hidden for Privacy]" : DownloadPath;
|
||||||
|
|
||||||
public string FfmpegPathHelpText => GetConfigHelpText(nameof(Config.FFmpegPath));
|
public string FfmpegPathHelpText => GetConfigHelpText(nameof(Config.FFmpegPath));
|
||||||
|
|
||||||
public string DownloadPathHelpText => GetConfigHelpText(nameof(Config.DownloadPath));
|
public string DownloadPathHelpText => GetConfigHelpText(nameof(Config.DownloadPath));
|
||||||
@ -297,13 +308,17 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
public void SetFfmpegPath(string? path)
|
public void SetFfmpegPath(string? path)
|
||||||
{
|
{
|
||||||
FfmpegPath = NormalizePathForDisplay(path);
|
string normalizedPath = NormalizePathForDisplay(path);
|
||||||
|
_actualFfmpegPath = normalizedPath;
|
||||||
|
FfmpegPath = HidePrivateInfo && !string.IsNullOrWhiteSpace(normalizedPath) ? "[Hidden for Privacy]" : normalizedPath;
|
||||||
FfmpegPathError = string.Empty;
|
FfmpegPathError = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDownloadPath(string? path)
|
public void SetDownloadPath(string? path)
|
||||||
{
|
{
|
||||||
DownloadPath = NormalizePathForDisplay(path);
|
string normalizedPath = NormalizePathForDisplay(path);
|
||||||
|
_actualDownloadPath = normalizedPath;
|
||||||
|
DownloadPath = HidePrivateInfo && !string.IsNullOrWhiteSpace(normalizedPath) ? "[Hidden for Privacy]" : normalizedPath;
|
||||||
DownloadPathError = string.Empty;
|
DownloadPathError = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,9 +756,23 @@ public partial class MainWindowViewModel(
|
|||||||
_ = SelectUsersFromListAsync();
|
_ = SelectUsersFromListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnFfmpegPathChanged(string value) => FfmpegPathError = string.Empty;
|
partial void OnFfmpegPathChanged(string value)
|
||||||
|
{
|
||||||
|
if (value != "[Hidden for Privacy]")
|
||||||
|
{
|
||||||
|
_actualFfmpegPath = value;
|
||||||
|
}
|
||||||
|
FfmpegPathError = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnDownloadPathChanged(string value) => DownloadPathError = string.Empty;
|
partial void OnDownloadPathChanged(string value)
|
||||||
|
{
|
||||||
|
if (value != "[Hidden for Privacy]")
|
||||||
|
{
|
||||||
|
_actualDownloadPath = value;
|
||||||
|
}
|
||||||
|
DownloadPathError = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task BeginStartupAsync()
|
private async Task BeginStartupAsync()
|
||||||
{
|
{
|
||||||
@ -861,9 +890,19 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
string displayName = !string.IsNullOrWhiteSpace(user.Name) ? user.Name : "Unknown Name";
|
string displayName = !string.IsNullOrWhiteSpace(user.Name) ? user.Name : "Unknown Name";
|
||||||
string displayUsername = !string.IsNullOrWhiteSpace(user.Username) ? user.Username : "Unknown Username";
|
string displayUsername = !string.IsNullOrWhiteSpace(user.Username) ? user.Username : "Unknown Username";
|
||||||
|
|
||||||
|
if (HidePrivateInfo)
|
||||||
|
{
|
||||||
|
AuthenticatedUserDisplay = "[Hidden for Privacy]";
|
||||||
|
AppendLog("Authenticated as [Hidden for Privacy].");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
AuthenticatedUserDisplay = $"{displayName} ({displayUsername})";
|
AuthenticatedUserDisplay = $"{displayName} ({displayUsername})";
|
||||||
IsAuthenticated = true;
|
|
||||||
AppendLog($"Authenticated as {AuthenticatedUserDisplay}.");
|
AppendLog($"Authenticated as {AuthenticatedUserDisplay}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
IsAuthenticated = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,8 +1121,15 @@ public partial class MainWindowViewModel(
|
|||||||
private void BuildSpecialConfigInputs(Config config)
|
private void BuildSpecialConfigInputs(Config config)
|
||||||
{
|
{
|
||||||
UnsubscribeSpecialSelectionEvents();
|
UnsubscribeSpecialSelectionEvents();
|
||||||
FfmpegPath = NormalizePathForDisplay(config.FFmpegPath);
|
|
||||||
DownloadPath = ResolveDownloadPathForDisplay(config.DownloadPath);
|
string ffmpegPath = NormalizePathForDisplay(config.FFmpegPath);
|
||||||
|
_actualFfmpegPath = ffmpegPath;
|
||||||
|
FfmpegPath = HidePrivateInfo && !string.IsNullOrWhiteSpace(ffmpegPath) ? "[Hidden for Privacy]" : ffmpegPath;
|
||||||
|
|
||||||
|
string downloadPath = ResolveDownloadPathForDisplay(config.DownloadPath);
|
||||||
|
_actualDownloadPath = downloadPath;
|
||||||
|
DownloadPath = HidePrivateInfo && !string.IsNullOrWhiteSpace(downloadPath) ? "[Hidden for Privacy]" : downloadPath;
|
||||||
|
|
||||||
ClearSpecialConfigErrors();
|
ClearSpecialConfigErrors();
|
||||||
|
|
||||||
PopulateSelectionOptions(MediaTypeOptions, s_mediaTypeOptions, config);
|
PopulateSelectionOptions(MediaTypeOptions, s_mediaTypeOptions, config);
|
||||||
@ -1118,12 +1164,14 @@ public partial class MainWindowViewModel(
|
|||||||
|
|
||||||
private void ApplySpecialConfigValues(Config config)
|
private void ApplySpecialConfigValues(Config config)
|
||||||
{
|
{
|
||||||
string normalizedFfmpegPath = NormalizePathForDisplay(FfmpegPath);
|
string pathToUse = HidePrivateInfo ? _actualFfmpegPath : FfmpegPath;
|
||||||
|
string normalizedFfmpegPath = NormalizePathForDisplay(pathToUse);
|
||||||
config.FFmpegPath = string.IsNullOrWhiteSpace(normalizedFfmpegPath)
|
config.FFmpegPath = string.IsNullOrWhiteSpace(normalizedFfmpegPath)
|
||||||
? string.Empty
|
? string.Empty
|
||||||
: EscapePathForConfig(normalizedFfmpegPath);
|
: EscapePathForConfig(normalizedFfmpegPath);
|
||||||
|
|
||||||
string normalizedDownloadPath = NormalizePathForDisplay(DownloadPath);
|
string downloadPathToUse = HidePrivateInfo ? _actualDownloadPath : DownloadPath;
|
||||||
|
string normalizedDownloadPath = NormalizePathForDisplay(downloadPathToUse);
|
||||||
config.DownloadPath = string.IsNullOrWhiteSpace(normalizedDownloadPath)
|
config.DownloadPath = string.IsNullOrWhiteSpace(normalizedDownloadPath)
|
||||||
? EscapePathForConfig(s_defaultDownloadPath)
|
? EscapePathForConfig(s_defaultDownloadPath)
|
||||||
: EscapePathForConfig(normalizedDownloadPath);
|
: EscapePathForConfig(normalizedDownloadPath);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user