Chg - Allow multiple Dub languages to be selected
Fix - Invalidate stream token
This commit is contained in:
parent
fbd16274a6
commit
d769e5e75e
|
@ -145,6 +145,7 @@ public class Crunchyroll{
|
|||
CrunOptions.AccentColor = Colors.SlateBlue.ToString();
|
||||
CrunOptions.Theme = "System";
|
||||
CrunOptions.SelectedCalendarLanguage = "de";
|
||||
CrunOptions.DlVideoOnce = true;
|
||||
|
||||
CrunOptions.History = true;
|
||||
|
||||
|
@ -868,14 +869,7 @@ public class Crunchyroll{
|
|||
|
||||
if (options.DlVideoOnce && dlVideoOnce){
|
||||
Console.WriteLine("Already downloaded video, skipping video download...");
|
||||
return new DownloadResponse{
|
||||
Data = files,
|
||||
Error = dlFailed,
|
||||
FileName = fileName.Length > 0 ? (Path.IsPathRooted(fileName) ? fileName : Path.Combine(CfgManager.PathVIDEOS_DIR, fileName)) : "./unknown"
|
||||
};
|
||||
}
|
||||
|
||||
if (options.Novids){
|
||||
}else if (options.Novids){
|
||||
Console.WriteLine("Skipping video download...");
|
||||
} else{
|
||||
var videoDownloadResult = await DownloadVideo(chosenVideoSegments, options, outFile, tsFile, tempTsFile, data);
|
||||
|
@ -1088,6 +1082,7 @@ public class Crunchyroll{
|
|||
}
|
||||
} else if (!options.Novids){
|
||||
//TODO
|
||||
MainWindow.ShowError("Requested Video with the current settings not implemented");
|
||||
} else if (options.Novids){
|
||||
fileName = Path.Combine(FileNameManager.ParseFileName(options.FileName, variables, options.Numbers, options.Override).ToArray());
|
||||
Console.WriteLine("Downloading skipped!");
|
||||
|
@ -1405,6 +1400,10 @@ public class Crunchyroll{
|
|||
CrunchyNoDrmStream? playStream = JsonConvert.DeserializeObject<CrunchyNoDrmStream>(playbackRequestNonDrmResponse.ResponseContent, SettingsJsonSerializerSettings);
|
||||
CrunchyStreams derivedPlayCrunchyStreams = new CrunchyStreams();
|
||||
if (playStream != null){
|
||||
|
||||
var deauthVideoToken = HttpClientReq.CreateRequestMessage($"https://cr-play-service.prd.crunchyrollsvc.com/v1/token/{currentMediaId}/{playStream.Token}/inactive", HttpMethod.Patch, true, false, null);
|
||||
var deauthVideoTokenResponse = await HttpClientReq.Instance.SendHttpRequest(deauthVideoToken);
|
||||
|
||||
if (playStream.HardSubs != null)
|
||||
foreach (var hardsub in playStream.HardSubs){
|
||||
var stream = hardsub.Value;
|
||||
|
|
|
@ -107,7 +107,9 @@ public class FontsManager{
|
|||
|
||||
foreach (var s in subs){
|
||||
foreach (var keyValuePair in s.Fonts){
|
||||
fontsNameList.Add(keyValuePair.Key,keyValuePair.Value);
|
||||
if (!fontsNameList.ContainsKey(keyValuePair.Key)){
|
||||
fontsNameList.Add(keyValuePair.Key,keyValuePair.Value);
|
||||
}
|
||||
}
|
||||
subsList.Add(s.Language.Locale);
|
||||
}
|
||||
|
|
|
@ -33,35 +33,78 @@ public class Merger{
|
|||
|
||||
if (!options.mp3){
|
||||
foreach (var vid in options.VideoAndAudio){
|
||||
if (vid.Delay != null && hasVideo){
|
||||
args.Add($"-itsoffset -{Math.Ceiling((double)vid.Delay * 1000)}ms");
|
||||
}
|
||||
if (vid.Delay != null && hasVideo){
|
||||
args.Add($"-itsoffset -{Math.Ceiling((double)vid.Delay * 1000)}ms");
|
||||
}
|
||||
|
||||
args.Add($"-i \"{vid.Path}\"");
|
||||
if (!hasVideo || options.KeepAllVideos == true){
|
||||
metaData.Add($"-map {index}:a -map {index}:v");
|
||||
metaData.Add($"-metadata:s:a:{audioIndex} language={vid.Language.Code}");
|
||||
metaData.Add($"-metadata:s:v:{index} title=\"{options.VideoTitle}\"");
|
||||
hasVideo = true;
|
||||
} else{
|
||||
metaData.Add($"-map {index}:a");
|
||||
metaData.Add($"-metadata:s:a:{audioIndex} language={vid.Language.Code}");
|
||||
}
|
||||
|
||||
audioIndex++;
|
||||
index++;
|
||||
}
|
||||
|
||||
foreach (var vid in options.OnlyVid){
|
||||
if (!hasVideo || options.KeepAllVideos == true){
|
||||
args.Add($"-i \"{vid.Path}\"");
|
||||
metaData.Add($"-map {index} -map -{index}:a");
|
||||
metaData.Add($"-metadata:s:v:{index} title=\"{options.VideoTitle}\"");
|
||||
hasVideo = true;
|
||||
if (!hasVideo || options.KeepAllVideos == true){
|
||||
metaData.Add($"-map {index}:a -map {index}:v");
|
||||
metaData.Add($"-metadata:s:a:{audioIndex} language={vid.Language.Code}");
|
||||
metaData.Add($"-metadata:s:v:{index} title=\"{options.VideoTitle}\"");
|
||||
hasVideo = true;
|
||||
} else{
|
||||
metaData.Add($"-map {index}:a");
|
||||
metaData.Add($"-metadata:s:a:{audioIndex} language={vid.Language.Code}");
|
||||
}
|
||||
|
||||
audioIndex++;
|
||||
index++;
|
||||
}
|
||||
|
||||
foreach (var vid in options.OnlyVid){
|
||||
if (!hasVideo || options.KeepAllVideos == true){
|
||||
args.Add($"-i \"{vid.Path}\"");
|
||||
metaData.Add($"-map {index} -map -{index}:a");
|
||||
metaData.Add($"-metadata:s:v:{index} title=\"{options.VideoTitle}\"");
|
||||
hasVideo = true;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var aud in options.OnlyAudio){
|
||||
args.Add($"-i \"{aud.Path}\"");
|
||||
metaData.Add($"-map {index}");
|
||||
metaData.Add($"-metadata:s:a:{audioIndex} language={aud.Language.Code}");
|
||||
index++;
|
||||
audioIndex++;
|
||||
}
|
||||
|
||||
foreach (var sub in options.Subtitles.Select((value, i) => new{ value, i })){
|
||||
if (sub.value.Delay != null){
|
||||
args.Add($"-itsoffset -{Math.Ceiling((double)sub.value.Delay * 1000)}ms");
|
||||
}
|
||||
|
||||
args.Add($"-i \"{sub.value.File}\"");
|
||||
}
|
||||
|
||||
if (options.Output.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)){
|
||||
if (options.Fonts != null){
|
||||
int fontIndex = 0;
|
||||
foreach (var font in options.Fonts){
|
||||
args.Add($"-attach {font.Path} -metadata:s:t:{fontIndex} mimetype={font.Mime}");
|
||||
fontIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
args.AddRange(metaData);
|
||||
args.AddRange(options.Subtitles.Select((sub, subIndex) => $"-map {subIndex + index}"));
|
||||
args.Add("-c:v copy");
|
||||
args.Add("-c:a copy");
|
||||
args.Add(options.Output.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) ? "-c:s mov_text" : "-c:s ass");
|
||||
args.AddRange(options.Subtitles.Select((sub, subindex) =>
|
||||
$"-metadata:s:s:{subindex} title=\"{sub.Language.Language ?? sub.Language.Name}{(sub.ClosedCaption == true ? $" {options.CcTag}" : "")}{(sub.Signs == true ? " Signs" : "")}\" -metadata:s:s:{subindex} language={sub.Language.Code}"));
|
||||
if (options.Options.ffmpeg?.Count > 0){
|
||||
args.AddRange(options.Options.ffmpeg);
|
||||
}
|
||||
|
||||
args.Add($"\"{options.Output}\"");
|
||||
|
||||
return string.Join(" ", args);
|
||||
}
|
||||
|
||||
|
||||
foreach (var aud in options.OnlyAudio){
|
||||
args.Add($"-i \"{aud.Path}\"");
|
||||
metaData.Add($"-map {index}");
|
||||
|
@ -70,41 +113,6 @@ public class Merger{
|
|||
audioIndex++;
|
||||
}
|
||||
|
||||
foreach (var sub in options.Subtitles.Select((value, i) => new{ value, i })){
|
||||
if (sub.value.Delay != null){
|
||||
args.Add($"-itsoffset -{Math.Ceiling((double)sub.value.Delay * 1000)}ms");
|
||||
}
|
||||
|
||||
args.Add($"-i \"{sub.value.File}\"");
|
||||
}
|
||||
|
||||
if (options.Output.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)){
|
||||
if (options.Fonts != null){
|
||||
int fontIndex = 0;
|
||||
foreach (var font in options.Fonts){
|
||||
args.Add($"-attach {font.Path} -metadata:s:t:{fontIndex} mimetype={font.Mime}");
|
||||
fontIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
args.AddRange(metaData);
|
||||
args.AddRange(options.Subtitles.Select((sub, subIndex) => $"-map {subIndex + index}"));
|
||||
args.Add("-c:v copy");
|
||||
args.Add("-c:a copy");
|
||||
args.Add(options.Output.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) ? "-c:s mov_text" : "-c:s ass");
|
||||
args.AddRange(options.Subtitles.Select((sub, subindex) =>
|
||||
$"-metadata:s:s:{subindex} title=\"{sub.Language.Language ?? sub.Language.Name}{(sub.ClosedCaption == true ? $" {options.CcTag}" : "")}{(sub.Signs == true ? " Signs" : "")}\" -metadata:s:s:{subindex} language={sub.Language.Code}"));
|
||||
if (options.Options.ffmpeg?.Count > 0){
|
||||
args.AddRange(options.Options.ffmpeg);
|
||||
}
|
||||
args.Add($"\"{options.Output}\"");
|
||||
|
||||
return string.Join(" ", args);
|
||||
}
|
||||
|
||||
|
||||
args.Add($"-i \"{options.OnlyAudio[0].Path}\"");
|
||||
args.Add("-acodec libmp3lame");
|
||||
args.Add("-ab 192k");
|
||||
args.Add($"\"{options.Output}\"");
|
||||
|
|
|
@ -18,49 +18,73 @@ using FluentAvalonia.Styling;
|
|||
namespace CRD.ViewModels;
|
||||
|
||||
public partial class SettingsPageViewModel : ViewModelBase{
|
||||
[ObservableProperty] private string _currentVersion = "v1.1";
|
||||
[ObservableProperty]
|
||||
private string _currentVersion;
|
||||
|
||||
[ObservableProperty] private bool _downloadVideo = true;
|
||||
[ObservableProperty]
|
||||
private bool _downloadVideo = true;
|
||||
|
||||
[ObservableProperty] private bool _downloadAudio = true;
|
||||
[ObservableProperty]
|
||||
private bool _downloadAudio = true;
|
||||
|
||||
[ObservableProperty] private bool _downloadChapters = true;
|
||||
[ObservableProperty]
|
||||
private bool _downloadChapters = true;
|
||||
|
||||
[ObservableProperty] private bool _muxToMp4 = false;
|
||||
[ObservableProperty]
|
||||
private bool _muxToMp4 = false;
|
||||
|
||||
[ObservableProperty] private bool _history = false;
|
||||
[ObservableProperty]
|
||||
private bool _history = false;
|
||||
|
||||
[ObservableProperty] private int _leadingNumbers = 0;
|
||||
[ObservableProperty]
|
||||
private int _leadingNumbers = 0;
|
||||
|
||||
[ObservableProperty] private int _simultaneousDownloads = 0;
|
||||
[ObservableProperty]
|
||||
private int _simultaneousDownloads = 0;
|
||||
|
||||
[ObservableProperty] private string _fileName = "";
|
||||
[ObservableProperty]
|
||||
private string _fileName = "";
|
||||
|
||||
[ObservableProperty] private string _mkvMergeOptions = "";
|
||||
[ObservableProperty]
|
||||
private string _mkvMergeOptions = "";
|
||||
|
||||
[ObservableProperty] private string _ffmpegOptions = "";
|
||||
[ObservableProperty]
|
||||
private string _ffmpegOptions = "";
|
||||
|
||||
[ObservableProperty] private string _selectedSubs = "all";
|
||||
[ObservableProperty]
|
||||
private string _selectedSubs = "all";
|
||||
|
||||
[ObservableProperty] private ComboBoxItem _selectedHSLang;
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem _selectedHSLang;
|
||||
|
||||
[ObservableProperty] private ComboBoxItem? _selectedDubLang;
|
||||
[ObservableProperty]
|
||||
private string _selectedDubs = "ja-JP";
|
||||
|
||||
[ObservableProperty] private ComboBoxItem? _selectedVideoQuality;
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ListBoxItem> _selectedDubLang = new();
|
||||
|
||||
[ObservableProperty] private ComboBoxItem? _selectedAudioQuality;
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem? _selectedVideoQuality;
|
||||
|
||||
[ObservableProperty] private ComboBoxItem? _currentAppTheme;
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem? _selectedAudioQuality;
|
||||
|
||||
[ObservableProperty] private ObservableCollection<ListBoxItem> _selectedSubLang = new();
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem? _currentAppTheme;
|
||||
|
||||
[ObservableProperty] private bool _useCustomAccent = false;
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ListBoxItem> _selectedSubLang = new();
|
||||
|
||||
[ObservableProperty] private Color _listBoxColor ;
|
||||
[ObservableProperty] private Color _customAccentColor = Colors.SlateBlue;
|
||||
[ObservableProperty]
|
||||
private bool _useCustomAccent = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private Color _listBoxColor;
|
||||
|
||||
[ObservableProperty]
|
||||
private Color _customAccentColor = Colors.SlateBlue;
|
||||
|
||||
public ObservableCollection<Color> PredefinedColors{ get; } = new(){
|
||||
|
||||
Color.FromRgb(255, 185, 0),
|
||||
Color.FromRgb(255, 140, 0),
|
||||
Color.FromRgb(247, 99, 12),
|
||||
|
@ -153,7 +177,6 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
private bool settingsLoaded = false;
|
||||
|
||||
public SettingsPageViewModel(){
|
||||
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
_currentVersion = $"{version?.Major}.{version?.Minor}.{version?.Build}";
|
||||
|
||||
|
@ -187,8 +210,25 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
ComboBoxItem? hsLang = HardSubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.Hslang) ?? null;
|
||||
SelectedHSLang = hsLang ?? HardSubLangList[0];
|
||||
|
||||
ComboBoxItem? dubLang = DubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.DubLang[0]) ?? null;
|
||||
SelectedDubLang = dubLang ?? DubLangList[0];
|
||||
// ComboBoxItem? dubLang = DubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.DubLang[0]) ?? null;
|
||||
// SelectedDubLang = dubLang ?? DubLangList[0];
|
||||
|
||||
var dubLang = DubLangList.Where(a => options.DubLang.Contains(a.Content)).ToList();
|
||||
|
||||
SelectedDubLang.Clear();
|
||||
foreach (var listBoxItem in dubLang){
|
||||
SelectedDubLang.Add(listBoxItem);
|
||||
}
|
||||
|
||||
if (SelectedDubLang.Count == 0){
|
||||
SelectedDubs = "none";
|
||||
} else{
|
||||
SelectedDubs = SelectedDubLang[0].Content.ToString();
|
||||
for (var i = 1; i < SelectedDubLang.Count; i++){
|
||||
SelectedDubs += "," + SelectedDubLang[i].Content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DownloadVideo = !options.Novids;
|
||||
DownloadAudio = !options.Noaudio;
|
||||
|
@ -216,12 +256,12 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
//TODO - Mux Options
|
||||
|
||||
SelectedSubLang.CollectionChanged += Changes;
|
||||
SelectedDubLang.CollectionChanged += Changes;
|
||||
|
||||
settingsLoaded = true;
|
||||
}
|
||||
|
||||
private void UpdateSettings(){
|
||||
|
||||
if (!settingsLoaded){
|
||||
return;
|
||||
}
|
||||
|
@ -235,6 +275,15 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
}
|
||||
}
|
||||
|
||||
if (SelectedDubLang.Count == 0){
|
||||
SelectedDubs = "none";
|
||||
} else{
|
||||
SelectedDubs = SelectedDubLang[0].Content.ToString();
|
||||
for (var i = 1; i < SelectedDubLang.Count; i++){
|
||||
SelectedDubs += "," + SelectedDubLang[i].Content;
|
||||
}
|
||||
}
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.Novids = !DownloadVideo;
|
||||
Crunchyroll.Instance.CrunOptions.Noaudio = !DownloadAudio;
|
||||
Crunchyroll.Instance.CrunOptions.Chapters = DownloadChapters;
|
||||
|
@ -254,12 +303,15 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
|
||||
Crunchyroll.Instance.CrunOptions.Hslang = hslang != "none" ? Languages.FindLang(hslang).Locale : hslang;
|
||||
|
||||
if (SelectedDubLang != null){
|
||||
string dublang = SelectedDubLang.Content + "";
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.DubLang = new List<string>{ dublang };
|
||||
List<string> dubLangs = new List<string>();
|
||||
foreach (var listBoxItem in SelectedDubLang){
|
||||
dubLangs.Add(listBoxItem.Content + "");
|
||||
}
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.DubLang = dubLangs;
|
||||
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.SimultaneousDownloads = SimultaneousDownloads;
|
||||
|
||||
|
||||
|
@ -329,9 +381,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
}
|
||||
|
||||
|
||||
partial void OnSelectedDubLangChanged(ComboBoxItem? value){
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
|
||||
private void Changes(object? sender, NotifyCollectionChangedEventArgs e){
|
||||
UpdateSettings();
|
||||
|
|
|
@ -21,10 +21,41 @@
|
|||
IconSource="Speaker2"
|
||||
Description="Change the selected dub language">
|
||||
<controls:SettingsExpander.Footer>
|
||||
<ComboBox HorizontalContentAlignment="Center" MinWidth="210" MaxDropDownHeight="400"
|
||||
ItemsSource="{Binding DubLangList}"
|
||||
SelectedItem="{Binding SelectedDubLang}">
|
||||
</ComboBox>
|
||||
<!-- <ComboBox HorizontalContentAlignment="Center" MinWidth="210" MaxDropDownHeight="400" -->
|
||||
<!-- -->
|
||||
<!-- ItemsSource="{Binding DubLangList}" -->
|
||||
<!-- SelectedItem="{Binding SelectedDubLang}"> -->
|
||||
<!-- </ComboBox> -->
|
||||
|
||||
|
||||
<StackPanel>
|
||||
<ToggleButton x:Name="DropdownButtonDub" Width="210" HorizontalContentAlignment="Stretch">
|
||||
<ToggleButton.Content>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock HorizontalAlignment="Center" Text="{Binding SelectedDubs}"
|
||||
VerticalAlignment="Center" />
|
||||
<Path Grid.Column="1" Data="M 0,1 L 4,4 L 8,1" Stroke="White" StrokeThickness="1"
|
||||
VerticalAlignment="Center" Margin="5,0,5,0" Stretch="Uniform" Width="8" />
|
||||
</Grid>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<Popup IsLightDismissEnabled="True"
|
||||
IsOpen="{Binding IsChecked, ElementName=DropdownButtonDub, Mode=TwoWay}" Placement="Bottom"
|
||||
PlacementTarget="{Binding ElementName=DropdownButtonDub}">
|
||||
<Border BorderThickness="1" Background="{DynamicResource ComboBoxDropDownBackground}">
|
||||
<ListBox x:Name="ListBoxDubsSelection" SelectionMode="Multiple,Toggle" Width="210"
|
||||
MaxHeight="400"
|
||||
ItemsSource="{Binding DubLangList}" SelectedItems="{Binding SelectedDubLang}">
|
||||
</ListBox>
|
||||
</Border>
|
||||
</Popup>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</controls:SettingsExpander.Footer>
|
||||
|
||||
</controls:SettingsExpander>
|
||||
|
|
Loading…
Reference in New Issue