forked from sim0n00ps/OF-DL
Add a warning about missing CDM keys before starting downloads
This commit is contained in:
parent
d662d9be4d
commit
35bde51e7d
@ -92,6 +92,8 @@ public class Config : IFileNameFormatConfig
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Theme Theme { get; set; } = Theme.light;
|
||||
|
||||
[ToggleableConfig] public bool HideMissingCdmKeysWarning { get; set; }
|
||||
|
||||
[ToggleableConfig] public bool IgnoreOwnMessages { get; set; }
|
||||
|
||||
[ToggleableConfig] public bool DisableBrowserAuth { get; set; }
|
||||
|
||||
@ -238,6 +238,9 @@ public class ConfigService(ILoggingService loggingService) : IConfigService
|
||||
|
||||
// Appearance Settings
|
||||
Theme = ParseTheme(hoconConfig.GetString("Appearance.Theme", "light")),
|
||||
HideMissingCdmKeysWarning =
|
||||
bool.TryParse(hoconConfig.GetString("Appearance.HideMissingCdmKeysWarning", "false"),
|
||||
out bool hideMissingCdmKeysWarning) && hideMissingCdmKeysWarning,
|
||||
|
||||
// Logging/Debug Settings
|
||||
LoggingLevel = Enum.Parse<LoggingLevel>(hoconConfig.GetString("Logging.LoggingLevel"), true)
|
||||
@ -413,6 +416,7 @@ public class ConfigService(ILoggingService loggingService) : IConfigService
|
||||
hocon.AppendLine("# Appearance Settings");
|
||||
hocon.AppendLine("Appearance {");
|
||||
hocon.AppendLine($" Theme = \"{config.Theme.ToString().ToLower()}\"");
|
||||
hocon.AppendLine($" HideMissingCdmKeysWarning = {config.HideMissingCdmKeysWarning.ToString().ToLower()}");
|
||||
hocon.AppendLine("}");
|
||||
|
||||
hocon.AppendLine("# Logging/Debug Settings");
|
||||
|
||||
@ -57,7 +57,8 @@ public partial class ConfigFieldViewModel : ViewModelBase
|
||||
[nameof(Config.IgnoredUsersListName)] = "Ignored Users List",
|
||||
[nameof(Config.RenameExistingFilesWhenCustomFormatIsSelected)] =
|
||||
"Rename Existing Files with Custom Formats",
|
||||
[nameof(Config.DownloadPath)] = "Download Folder"
|
||||
[nameof(Config.DownloadPath)] = "Download Folder",
|
||||
[nameof(Config.HideMissingCdmKeysWarning)] = "Hide Missing CDM Keys Warning"
|
||||
};
|
||||
|
||||
public ConfigFieldViewModel(
|
||||
|
||||
@ -40,6 +40,7 @@ public partial class MainWindowViewModel(
|
||||
long? UserId);
|
||||
|
||||
private const string UnknownToolVersion = "Not detected";
|
||||
|
||||
private static readonly Regex s_singlePostUrlRegex = new(
|
||||
@"^https://onlyfans\.com/(?<postId>\d+)/(?<username>[A-Za-z0-9_.-]+)/?$",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
@ -154,6 +155,8 @@ public partial class MainWindowViewModel(
|
||||
"Download rate limit in MB/s when rate limiting is enabled.",
|
||||
[nameof(Config.Theme)] =
|
||||
"GUI theme for the configuration and download screens.",
|
||||
[nameof(Config.HideMissingCdmKeysWarning)] =
|
||||
"Hide the missing CDM keys warning before downloads start.",
|
||||
[nameof(Config.LoggingLevel)] =
|
||||
"Log verbosity written to logs/OFDL.txt."
|
||||
};
|
||||
@ -319,14 +322,23 @@ public partial class MainWindowViewModel(
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenSinglePostOrMessageModalCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(DownloadSelectedCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(DownloadPurchasedTabCommand))]
|
||||
private bool _isSinglePostOrMessageModalOpen;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenSinglePostOrMessageModalCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(DownloadSelectedCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(DownloadPurchasedTabCommand))]
|
||||
private bool _isMissingCdmWarningModalOpen;
|
||||
|
||||
[ObservableProperty] private string _missingCdmWarningMessage = string.Empty;
|
||||
|
||||
[ObservableProperty] [NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))]
|
||||
private string _singlePostOrMessageUrl = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(HasSinglePostOrMessageUrlError))]
|
||||
[ObservableProperty] [NotifyPropertyChangedFor(nameof(HasSinglePostOrMessageUrlError))]
|
||||
private string _singlePostOrMessageUrlError = string.Empty;
|
||||
|
||||
public bool IsLoadingScreen => CurrentScreen == AppScreen.Loading;
|
||||
@ -432,6 +444,7 @@ public partial class MainWindowViewModel(
|
||||
}
|
||||
|
||||
private bool _isUpdatingAllUsersSelected;
|
||||
private TaskCompletionSource<bool>? _missingCdmWarningCompletionSource;
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
@ -752,6 +765,20 @@ public partial class MainWindowViewModel(
|
||||
IsSinglePostOrMessageModalOpen = false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ConfirmMissingCdmWarning()
|
||||
{
|
||||
IsMissingCdmWarningModalOpen = false;
|
||||
_missingCdmWarningCompletionSource?.TrySetResult(true);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void CancelMissingCdmWarning()
|
||||
{
|
||||
IsMissingCdmWarningModalOpen = false;
|
||||
_missingCdmWarningCompletionSource?.TrySetResult(false);
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanStopWork))]
|
||||
private void StopWork()
|
||||
{
|
||||
@ -779,6 +806,11 @@ public partial class MainWindowViewModel(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await EnsureMissingCdmWarningConfirmedAsync())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsDownloading = true;
|
||||
_workCancellationSource?.Dispose();
|
||||
_workCancellationSource = new CancellationTokenSource();
|
||||
@ -871,20 +903,24 @@ public partial class MainWindowViewModel(
|
||||
private bool CanDownloadSelected() =>
|
||||
CurrentScreen == AppScreen.UserSelection &&
|
||||
AvailableUsers.Any(user => user.IsSelected) &&
|
||||
!IsMissingCdmWarningModalOpen &&
|
||||
!IsDownloading;
|
||||
|
||||
private bool CanDownloadPurchasedTab() =>
|
||||
CurrentScreen == AppScreen.UserSelection &&
|
||||
_allUsers.Count > 0 &&
|
||||
!IsMissingCdmWarningModalOpen &&
|
||||
!IsDownloading;
|
||||
|
||||
private bool CanOpenSinglePostOrMessageModal() =>
|
||||
CurrentScreen == AppScreen.UserSelection &&
|
||||
!IsDownloading &&
|
||||
!IsMissingCdmWarningModalOpen &&
|
||||
!IsSinglePostOrMessageModalOpen;
|
||||
|
||||
private bool CanSubmitSinglePostOrMessage() =>
|
||||
IsSinglePostOrMessageModalOpen &&
|
||||
!IsMissingCdmWarningModalOpen &&
|
||||
!IsDownloading &&
|
||||
!string.IsNullOrWhiteSpace(SinglePostOrMessageUrl);
|
||||
|
||||
@ -951,10 +987,7 @@ public partial class MainWindowViewModel(
|
||||
_ = SelectUsersFromListAsync();
|
||||
}
|
||||
|
||||
partial void OnSinglePostOrMessageUrlChanged(string value)
|
||||
{
|
||||
SinglePostOrMessageUrlError = string.Empty;
|
||||
}
|
||||
partial void OnSinglePostOrMessageUrlChanged(string value) => SinglePostOrMessageUrlError = string.Empty;
|
||||
|
||||
partial void OnFfmpegPathChanged(string value)
|
||||
{
|
||||
@ -1024,6 +1057,11 @@ public partial class MainWindowViewModel(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await EnsureMissingCdmWarningConfirmedAsync())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsDownloading = true;
|
||||
_workCancellationSource?.Dispose();
|
||||
_workCancellationSource = new CancellationTokenSource();
|
||||
@ -1134,6 +1172,55 @@ public partial class MainWindowViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> EnsureMissingCdmWarningConfirmedAsync()
|
||||
{
|
||||
bool hasMissingCdmKeys = _startupResult.ClientIdBlobMissing || _startupResult.DevicePrivateKeyMissing;
|
||||
if (!hasMissingCdmKeys || configService.CurrentConfig.HideMissingCdmKeysWarning)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
List<string> missingFiles = [];
|
||||
if (_startupResult.ClientIdBlobMissing)
|
||||
{
|
||||
missingFiles.Add("device_client_id_blob");
|
||||
}
|
||||
|
||||
if (_startupResult.DevicePrivateKeyMissing)
|
||||
{
|
||||
missingFiles.Add("device_private_key");
|
||||
}
|
||||
|
||||
string missingSummary = string.Join(" and ", missingFiles);
|
||||
MissingCdmWarningMessage =
|
||||
$"Missing CDM key file(s): {missingSummary}\n\n" +
|
||||
"CDM keys are recommended to decrypt DRM-protected videos. Without these keys, the application will use a fallback online decryption service, which may be slower and less reliable.\n\n" +
|
||||
"You can hide this warning in the future by enabling \"Hide Missing CDM Keys Warning\" in the configuration settings.\n\n";
|
||||
|
||||
_missingCdmWarningCompletionSource =
|
||||
new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
IsMissingCdmWarningModalOpen = true;
|
||||
|
||||
bool confirmed;
|
||||
try
|
||||
{
|
||||
confirmed = await _missingCdmWarningCompletionSource.Task;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_missingCdmWarningCompletionSource = null;
|
||||
IsMissingCdmWarningModalOpen = false;
|
||||
}
|
||||
|
||||
if (!confirmed)
|
||||
{
|
||||
StatusMessage = "Download canceled.";
|
||||
AppendLog("Download canceled after missing CDM keys warning.");
|
||||
}
|
||||
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
private static bool TryParseSinglePostOrMessageUrl(
|
||||
string url,
|
||||
out SingleDownloadRequest request,
|
||||
@ -1254,7 +1341,7 @@ public partial class MainWindowViewModel(
|
||||
if (_startupResult.ClientIdBlobMissing || _startupResult.DevicePrivateKeyMissing)
|
||||
{
|
||||
AppendLog(
|
||||
"Widevine device files are missing. Fallback decrypt services will be used for DRM protected videos.");
|
||||
"CDM key files are missing. Fallback decrypt services will be used for DRM protected videos.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1472,9 +1559,10 @@ public partial class MainWindowViewModel(
|
||||
List<ConfigCategoryViewModel> orderedCategories = [];
|
||||
foreach (IGrouping<string, ConfigFieldViewModel> group in grouped)
|
||||
{
|
||||
IEnumerable<ConfigFieldViewModel> orderedFields = group.Key is "File Naming" or "Download Behavior"
|
||||
? group.OrderBy(field => GetFieldOrder(group.Key, field.PropertyName))
|
||||
: group.OrderBy(field => field.DisplayName);
|
||||
IEnumerable<ConfigFieldViewModel> orderedFields =
|
||||
group.Key is "File Naming" or "Download Behavior" or "Appearance"
|
||||
? group.OrderBy(field => GetFieldOrder(group.Key, field.PropertyName))
|
||||
: group.OrderBy(field => field.DisplayName);
|
||||
|
||||
ConfigCategoryViewModel category = new(group.Key, orderedFields);
|
||||
orderedCategories.Add(category);
|
||||
@ -1534,6 +1622,16 @@ public partial class MainWindowViewModel(
|
||||
};
|
||||
}
|
||||
|
||||
if (categoryName == "Appearance")
|
||||
{
|
||||
return propertyName switch
|
||||
{
|
||||
nameof(Config.Theme) => 0,
|
||||
nameof(Config.HideMissingCdmKeysWarning) => 1,
|
||||
_ => 100
|
||||
};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1882,10 +1980,7 @@ public partial class MainWindowViewModel(
|
||||
return JsonConvert.DeserializeObject<Config>(json) ?? new Config();
|
||||
}
|
||||
|
||||
private static void EnforceGuiOnlyConfigValues(Config config)
|
||||
{
|
||||
config.ShowScrapeSize = false;
|
||||
}
|
||||
private static void EnforceGuiOnlyConfigValues(Config config) => config.ShowScrapeSize = false;
|
||||
|
||||
private static bool IsHiddenConfigField(string propertyName) =>
|
||||
propertyName is nameof(Config.NonInteractiveMode)
|
||||
@ -1962,6 +2057,7 @@ public partial class MainWindowViewModel(
|
||||
nameof(Config.DownloadLimitInMbPerSec) => "Performance",
|
||||
|
||||
nameof(Config.Theme) => "Appearance",
|
||||
nameof(Config.HideMissingCdmKeysWarning) => "Appearance",
|
||||
|
||||
nameof(Config.LoggingLevel) => "Logging",
|
||||
|
||||
|
||||
@ -1442,5 +1442,43 @@
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="0" Grid.RowSpan="3"
|
||||
IsVisible="{Binding IsMissingCdmWarningModalOpen}"
|
||||
Background="{DynamicResource OverlayBackgroundBrush}"
|
||||
ZIndex="1002"
|
||||
PointerPressed="OnModalOverlayClicked">
|
||||
<Border Background="{DynamicResource ModalBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource ModalBorderBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="16"
|
||||
Padding="28"
|
||||
Width="680"
|
||||
MaxHeight="500"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
BoxShadow="0 20 25 -5 #19000000, 0 10 10 -5 #0F000000"
|
||||
PointerPressed="OnModalContentClicked">
|
||||
<StackPanel Spacing="16">
|
||||
<TextBlock FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
Text="Missing CDM Keys" />
|
||||
|
||||
<TextBlock Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding MissingCdmWarningMessage}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right">
|
||||
<Button Content="Cancel"
|
||||
Classes="secondary"
|
||||
Command="{Binding CancelMissingCdmWarningCommand}" />
|
||||
<Button Content="Continue Download"
|
||||
Classes="primary"
|
||||
Command="{Binding ConfirmMissingCdmWarningCommand}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -186,6 +186,7 @@ public partial class MainWindow : Window
|
||||
// Execute cancel command on any open modal
|
||||
vm.CreatorConfigEditor.ModalViewModel?.CancelCommand?.Execute(null);
|
||||
vm.CancelSinglePostOrMessageCommand.Execute(null);
|
||||
vm.CancelMissingCdmWarningCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnModalContentClicked(object? sender, PointerPressedEventArgs e) =>
|
||||
|
||||
@ -24,6 +24,7 @@ public class ConfigServiceTests
|
||||
Assert.Equal("", service.CurrentConfig.FFprobePath);
|
||||
Assert.Equal(0.98, service.CurrentConfig.DrmVideoDurationMatchThreshold, 3);
|
||||
Assert.Equal(Theme.light, service.CurrentConfig.Theme);
|
||||
Assert.False(service.CurrentConfig.HideMissingCdmKeysWarning);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -100,6 +101,25 @@ public class ConfigServiceTests
|
||||
Assert.Equal(Theme.dark, service.CurrentConfig.Theme);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LoadConfigurationAsync_ParsesHideMissingCdmKeysWarning()
|
||||
{
|
||||
using TempFolder temp = new();
|
||||
using CurrentDirectoryScope _ = new(temp.Path);
|
||||
FakeLoggingService loggingService = new();
|
||||
ConfigService service = new(loggingService);
|
||||
await service.SaveConfigurationAsync();
|
||||
|
||||
string hocon = await File.ReadAllTextAsync("config.conf");
|
||||
hocon = hocon.Replace("HideMissingCdmKeysWarning = false", "HideMissingCdmKeysWarning = true");
|
||||
await File.WriteAllTextAsync("config.conf", hocon);
|
||||
|
||||
bool result = await service.LoadConfigurationAsync([]);
|
||||
|
||||
Assert.True(result);
|
||||
Assert.True(service.CurrentConfig.HideMissingCdmKeysWarning);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyToggleableSelections_UpdatesConfigAndReturnsChange()
|
||||
{
|
||||
|
||||
@ -387,6 +387,18 @@ Allowed values: `true`, `false`
|
||||
Description: A folder will be created for each post (containing all the media for that post) if set to `true`.
|
||||
When set to `false`, post media will be downloaded into the `Posts/Free` folder.
|
||||
|
||||
## HideMissingCdmKeysWarning
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Default: `false`
|
||||
|
||||
Allowed values: `true`, `false`
|
||||
|
||||
Description: If set to `false`, OF-DL will show a warning and ask for confirmation before starting downloads when
|
||||
`device_client_id_blob` and/or `device_private_key` is missing.
|
||||
If set to `true`, this warning is hidden and downloads start immediately.
|
||||
|
||||
## IgnoreOwnMessages
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
@ -70,6 +70,7 @@ information about what it does, its default value, and the allowed values.
|
||||
|
||||
- Appearance
|
||||
- [Theme](/config/all-configuration-options#theme)
|
||||
- [HideMissingCdmKeysWarning](/config/all-configuration-options#hidemissingcdmkeyswarning)
|
||||
|
||||
- Logging
|
||||
- [LoggingLevel](/config/all-configuration-options#logginglevel)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user