From 5cda547e22b0e894aa1f2107e3e01ca7d7bd2623 Mon Sep 17 00:00:00 2001 From: Elwador <75888166+Elwador@users.noreply.github.com> Date: Tue, 2 Sep 2025 16:05:15 +0200 Subject: [PATCH] Fix - Playback error probably only temporarily Fix - Dub/Sub sorting reset on restart --- .../Crunchyroll/CrunchyrollManager.cs | 19 +++++++++++------- .../CrunchyrollSettingsViewModel.cs | 20 +++++++++++++------ .../Views/CrunchyrollSettingsView.axaml | 4 ++-- CRD/Utils/Http/HttpClientReq.cs | 9 +++++---- CRD/Utils/UI/UiEmptyToDefaultConverter.cs | 14 +++++++++++++ CRD/Views/SeriesPageView.axaml | 14 ++++++++----- 6 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 CRD/Utils/UI/UiEmptyToDefaultConverter.cs diff --git a/CRD/Downloader/Crunchyroll/CrunchyrollManager.cs b/CRD/Downloader/Crunchyroll/CrunchyrollManager.cs index df400f5..794692a 100644 --- a/CRD/Downloader/Crunchyroll/CrunchyrollManager.cs +++ b/CRD/Downloader/Crunchyroll/CrunchyrollManager.cs @@ -199,11 +199,15 @@ public class CrunchyrollManager{ CfgManager.DisableLogMode(); } - var token = await GetBase64EncodedTokenAsync(); - - if (!string.IsNullOrEmpty(token)){ - ApiUrls.authBasicMob = "Basic " + token; - } + CrunOptions.StreamEndpoint = "tv/android_tv"; + CrunOptions.StreamEndpointSecondary = ""; + CfgManager.WriteCrSettings(); + + // var token = await GetBase64EncodedTokenAsync(); + // + // if (!string.IsNullOrEmpty(token)){ + // ApiUrls.authBasicMob = "Basic " + token; + // } var jsonFiles = Directory.Exists(CfgManager.PathENCODING_PRESETS_DIR) ? Directory.GetFiles(CfgManager.PathENCODING_PRESETS_DIR, "*.json") :[]; @@ -1995,12 +1999,12 @@ public class CrunchyrollManager{ if (matchingSubs.Count > 0){ isDuplicate = true; - if (!options.SubsDownloadDuplicate || matchingSubs.Any(a => a.RelatedVideoDownloadMedia?.Lang == videoDownloadMedia.Lang)){ + if (options is not{ KeepDubsSeperate: true, DlVideoOnce: false } || !options.SubsDownloadDuplicate || matchingSubs.Any(a => a.RelatedVideoDownloadMedia?.Lang == videoDownloadMedia.Lang)){ continue; } } - sxData.File = Languages.SubsFile(fileName, index + "", langItem, isDuplicate ? videoDownloadMedia.Lang.CrLocale : "", isCc, options.CcTag, isSigns, subsItem.format, + sxData.File = Languages.SubsFile(fileName, index + "", langItem, (isDuplicate || options is{ KeepDubsSeperate: true, DlVideoOnce: false }) ? videoDownloadMedia.Lang.CrLocale : "", isCc, options.CcTag, isSigns, subsItem.format, !(data.DownloadSubs.Count == 1 && !data.DownloadSubs.Contains("all"))); sxData.Path = Path.Combine(fileDir, sxData.File); @@ -2281,6 +2285,7 @@ public class CrunchyrollManager{ private async Task<(bool IsOk, string ResponseContent, string error)> SendPlaybackRequestAsync(string endpoint){ var request = HttpClientReq.CreateRequestMessage(endpoint, HttpMethod.Get, true, false, null); + request.Headers.UserAgent.ParseAdd("ANDROIDTV/3.42.1_22267 Android/16"); return await HttpClientReq.Instance.SendHttpRequest(request); } diff --git a/CRD/Downloader/Crunchyroll/ViewModels/CrunchyrollSettingsViewModel.cs b/CRD/Downloader/Crunchyroll/ViewModels/CrunchyrollSettingsViewModel.cs index 5f78f62..b665d86 100644 --- a/CRD/Downloader/Crunchyroll/ViewModels/CrunchyrollSettingsViewModel.cs +++ b/CRD/Downloader/Crunchyroll/ViewModels/CrunchyrollSettingsViewModel.cs @@ -222,7 +222,8 @@ public partial class CrunchyrollSettingsViewModel : ViewModelBase{ new(){ Content = "android/phone" }, new(){ Content = "android/tablet" }, new(){ Content = "tv/samsung" }, - new(){ Content = "tv/vidaa" } + new(){ Content = "tv/vidaa" }, + new(){ Content = "tv/android_tv" }, ]; public ObservableCollection StreamEndpointsSecondary{ get; } =[ @@ -238,7 +239,8 @@ public partial class CrunchyrollSettingsViewModel : ViewModelBase{ new(){ Content = "android/phone" }, new(){ Content = "android/tablet" }, new(){ Content = "tv/samsung" }, - new(){ Content = "tv/vidaa" } + new(){ Content = "tv/vidaa" }, + new(){ Content = "tv/android_tv" }, ]; public ObservableCollection FFmpegHWAccel{ get; } =[]; @@ -321,15 +323,21 @@ public partial class CrunchyrollSettingsViewModel : ViewModelBase{ SelectedFFmpegHWAccel = hwAccellFlag ?? FFmpegHWAccel[0]; - var softSubLang = SubLangList.Where(a => options.DlSubs.Contains(a.Content)).ToList(); - + var softSubLang = SubLangList + .Where(a => options.DlSubs.Contains(a.Content)) + .OrderBy(a => options.DlSubs.IndexOf(a.Content)) + .ToList(); + SelectedSubLang.Clear(); foreach (var listBoxItem in softSubLang){ SelectedSubLang.Add(listBoxItem); } - var dubLang = DubLangList.Where(a => options.DubLang.Contains(a.Content)).ToList(); - + var dubLang = DubLangList + .Where(a => options.DubLang.Contains(a.Content)) + .OrderBy(a => options.DubLang.IndexOf(a.Content)) + .ToList(); + SelectedDubLang.Clear(); foreach (var listBoxItem in dubLang){ SelectedDubLang.Add(listBoxItem); diff --git a/CRD/Downloader/Crunchyroll/Views/CrunchyrollSettingsView.axaml b/CRD/Downloader/Crunchyroll/Views/CrunchyrollSettingsView.axaml index 7fb0734..9862a7a 100644 --- a/CRD/Downloader/Crunchyroll/Views/CrunchyrollSettingsView.axaml +++ b/CRD/Downloader/Crunchyroll/Views/CrunchyrollSettingsView.axaml @@ -231,7 +231,7 @@ - + - + value!; +} \ No newline at end of file diff --git a/CRD/Views/SeriesPageView.axaml b/CRD/Views/SeriesPageView.axaml index 4d4cac5..449b87f 100644 --- a/CRD/Views/SeriesPageView.axaml +++ b/CRD/Views/SeriesPageView.axaml @@ -12,7 +12,7 @@ x:Class="CRD.Views.SeriesPageView"> - + @@ -139,7 +139,7 @@ - + - + Edit