From 5e7c67d72cba7f76f90fc2dd9c418d8e9ab9b803 Mon Sep 17 00:00:00 2001 From: Elwador <75888166+Elwador@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:35:51 +0200 Subject: [PATCH] Add - Calendar language is now saved Chg - Subtitles don't get the index number and language added to the file name if only one subtitle is downloaded Fix - When setting folders in the file name folders were created in the application folder --- CRD/Downloader/Crunchyroll.cs | 5 +++-- CRD/Utils/Http/HttpClientReq.cs | 2 +- CRD/Utils/Structs/CrDownloadOptions.cs | 2 +- CRD/Utils/Structs/Languages.cs | 8 ++++++-- CRD/ViewModels/CalendarPageViewModel.cs | 2 ++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CRD/Downloader/Crunchyroll.cs b/CRD/Downloader/Crunchyroll.cs index 7dea7c9..2cb0122 100644 --- a/CRD/Downloader/Crunchyroll.cs +++ b/CRD/Downloader/Crunchyroll.cs @@ -1381,7 +1381,8 @@ public class Crunchyroll{ sxData.Language = langItem; var isSigns = langItem.Code == audDub && !subsItem.isCC; var isCc = subsItem.isCC; - sxData.File = Languages.SubsFile(fileName, index + "", langItem, isCc, options.CcTag, isSigns, subsItem.format); + + sxData.File = Languages.SubsFile(fileName, index + "", langItem, isCc, options.CcTag, isSigns, subsItem.format, !(options.DlSubs.Count == 1 && !options.DlSubs.Contains("all"))); sxData.Path = Path.Combine(fileDir, sxData.File); Helpers.EnsureDirectoriesExist(sxData.Path); @@ -1462,7 +1463,7 @@ public class Crunchyroll{ tsFile = Path.Combine(fileDir, outFile); } - Helpers.EnsureDirectoriesExist(outFile); + Helpers.EnsureDirectoriesExist(tsFile); M3U8Json videoJson = new M3U8Json{ Segments = chosenVideoSegments.segments.Cast().ToList() diff --git a/CRD/Utils/Http/HttpClientReq.cs b/CRD/Utils/Http/HttpClientReq.cs index cb16ae3..674dfe1 100644 --- a/CRD/Utils/Http/HttpClientReq.cs +++ b/CRD/Utils/Http/HttpClientReq.cs @@ -45,7 +45,7 @@ public class HttpClientReq{ client = new HttpClient(handler); // client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"); - client.DefaultRequestHeaders.UserAgent.ParseAdd("Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27"); + client.DefaultRequestHeaders.UserAgent.ParseAdd("Crunchyroll/1.9.0 Nintendo Switch/18.1.0.0 UE4/4.27"); } diff --git a/CRD/Utils/Structs/CrDownloadOptions.cs b/CRD/Utils/Structs/CrDownloadOptions.cs index 1aaed92..54e7bba 100644 --- a/CRD/Utils/Structs/CrDownloadOptions.cs +++ b/CRD/Utils/Structs/CrDownloadOptions.cs @@ -110,7 +110,7 @@ public class CrDownloadOptions{ [YamlMember(Alias = "accent_color", ApplyNamingConventions = false)] public string? AccentColor{ get; set; } - [YamlIgnore] + [YamlMember(Alias = "calendar_language", ApplyNamingConventions = false)] public string? SelectedCalendarLanguage{ get; set; } [YamlMember(Alias = "history", ApplyNamingConventions = false)] diff --git a/CRD/Utils/Structs/Languages.cs b/CRD/Utils/Structs/Languages.cs index 47398e6..b521dca 100644 --- a/CRD/Utils/Structs/Languages.cs +++ b/CRD/Utils/Structs/Languages.cs @@ -48,10 +48,14 @@ public class Languages{ return FindLang(str); } - public static string SubsFile(string fnOutput, string subsIndex, LanguageItem langItem, bool isCC, string ccTag, bool? isSigns = false, string? format = "ass"){ + public static string SubsFile(string fnOutput, string subsIndex, LanguageItem langItem, bool isCC, string ccTag , bool? isSigns = false, string? format = "ass", bool addIndexAndLangCode = true){ subsIndex = (int.Parse(subsIndex) + 1).ToString().PadLeft(2, '0'); - string fileName = $"{fnOutput}.{subsIndex}.{langItem.Code}"; + string fileName = $"{fnOutput}"; + if (addIndexAndLangCode){ + fileName += $".{subsIndex}.{langItem.Code}"; + } + //removed .{langItem.language} from file name at end if (isCC){ diff --git a/CRD/ViewModels/CalendarPageViewModel.cs b/CRD/ViewModels/CalendarPageViewModel.cs index 58e4970..081ed36 100644 --- a/CRD/ViewModels/CalendarPageViewModel.cs +++ b/CRD/ViewModels/CalendarPageViewModel.cs @@ -5,6 +5,7 @@ using Avalonia.Controls; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CRD.Downloader; +using CRD.Utils; using CRD.Utils.Structs; using DynamicData; @@ -136,6 +137,7 @@ public partial class CalendarPageViewModel : ViewModelBase{ if (value?.Content != null){ Crunchyroll.Instance.CrunOptions.SelectedCalendarLanguage = value.Content.ToString(); Refresh(); + CfgManager.WriteSettingsToFile(); } } } \ No newline at end of file