Skip to content

Commit

Permalink
支持配置是否跳过 AI 字幕下载 (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Sep 15, 2024
1 parent 1f2ad89 commit 3660ddd
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ public enum SettingNames
ExternalPlayer,
LastSelectedAIService,
AppVersion,
FilterAISubtitle,
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<community:SettingsCard Header="{ext:Locale Name=DownloadWithDanmaku}">
<ToggleSwitch IsOn="{x:Bind ViewModel.DownloadWithDanmaku, Mode=TwoWay}" />
</community:SettingsCard>
<community:SettingsCard Header="{ext:Locale Name=SkipAISubtitle}">
<ToggleSwitch IsOn="{x:Bind ViewModel.FilterAISubtitle, Mode=TwoWay}" />
</community:SettingsCard>
<community:SettingsCard Header="{ext:Locale Name=OpenFolderWhenDownloaded}">
<ToggleSwitch IsOn="{x:Bind ViewModel.OpenFolderAfterDownload, Mode=TwoWay}" />
</community:SettingsCard>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2669,4 +2669,7 @@
<data name="NewWindow" xml:space="preserve">
<value>新窗口</value>
</data>
<data name="SkipAISubtitle" xml:space="preserve">
<value>跳过 AI 字幕下载</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ private void DownloadDanmaku()
[RelayCommand]
private void DownloadSubtitle()
{
var command = $"{GetBasicCommand(false)} --sub-only \"{_currentUrl}\"";
var isAISubtitleFiltered = SettingsToolkit.ReadLocalSetting(SettingNames.FilterAISubtitle, true);
var subCommand = isAISubtitleFiltered ? "--sub-only" : "--sub-only --skip-ai False";
var command = $"{GetBasicCommand(false)} {subCommand} \"{_currentUrl}\"";
LaunchDownloadProcess(command);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public sealed partial class SettingsPageViewModel
[ObservableProperty]
private bool _withoutCredentialWhenGenDownloadCommand;

[ObservableProperty]
private bool _filterAISubtitle;

[ObservableProperty]
private bool _isWebDavEnabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void Initialize()
OnlyCopyCommandWhenDownload = SettingsToolkit.ReadLocalSetting(SettingNames.OnlyCopyCommandWhenDownload, false);
WithoutCredentialWhenGenDownloadCommand = SettingsToolkit.ReadLocalSetting(SettingNames.WithoutCredentialWhenGenDownloadCommand, false);
IsExternalPlayerType = PlayerType == PlayerType.External;
FilterAISubtitle = SettingsToolkit.ReadLocalSetting(SettingNames.FilterAISubtitle, true);
if (string.IsNullOrEmpty(DefaultDownloadPath))
{
DefaultDownloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "Bili Downloads");
Expand Down Expand Up @@ -228,4 +229,7 @@ partial void OnSelectedWebDavChanged(WebDavConfig value)
SettingsToolkit.WriteLocalSetting(SettingNames.SelectedWebDavConfigId, value.Id);
}
}

partial void OnFilterAISubtitleChanged(bool value)
=> SettingsToolkit.WriteLocalSetting(SettingNames.FilterAISubtitle, value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,8 @@ private void ReloadPart()
}

private void SyncDownloadAndSubtitle()
=> Downloader.HasAvailableSubtitle = Subtitle.IsAvailable && Subtitle.Metas.Any(p => !p.IsAI);
{
var isAISubtitleFiltered = SettingsToolkit.ReadLocalSetting(SettingNames.FilterAISubtitle, true);
Downloader.HasAvailableSubtitle = Subtitle.IsAvailable && (isAISubtitleFiltered ? Subtitle.Metas.Any(p => !p.IsAI) : true);
}
}

0 comments on commit 3660ddd

Please sign in to comment.