Fix - Hotfix for Filter by Air date overwriting Hide Dubs

Fix - Crash when opening calendar for the first time
This commit is contained in:
Elwador 2024-07-13 14:08:58 +02:00
parent 6b44dbf28c
commit 53158b261d
2 changed files with 25 additions and 22 deletions

View File

@ -51,6 +51,7 @@ public class Crunchyroll{
#region Calendar Variables #region Calendar Variables
private Dictionary<string, CalendarWeek> calendar = new(); private Dictionary<string, CalendarWeek> calendar = new();
private Dictionary<string, string> calendarLanguage = new(){ private Dictionary<string, string> calendarLanguage = new(){
{ "en-us", "https://www.crunchyroll.com/simulcastcalendar" }, { "en-us", "https://www.crunchyroll.com/simulcastcalendar" },
{ "es", "https://www.crunchyroll.com/es/simulcastcalendar" }, { "es", "https://www.crunchyroll.com/es/simulcastcalendar" },
@ -158,7 +159,7 @@ public class Crunchyroll{
CrunOptions.SimultaneousDownloads = 2; CrunOptions.SimultaneousDownloads = 2;
CrunOptions.AccentColor = Colors.SlateBlue.ToString(); CrunOptions.AccentColor = Colors.SlateBlue.ToString();
CrunOptions.Theme = "System"; CrunOptions.Theme = "System";
CrunOptions.SelectedCalendarLanguage = "default"; CrunOptions.SelectedCalendarLanguage = "en-us";
CrunOptions.CalendarDubFilter = "none"; CrunOptions.CalendarDubFilter = "none";
CrunOptions.DlVideoOnce = true; CrunOptions.DlVideoOnce = true;
CrunOptions.StreamEndpoint = "web/firefox"; CrunOptions.StreamEndpoint = "web/firefox";
@ -190,9 +191,6 @@ public class Crunchyroll{
RefreshSonarr(); RefreshSonarr();
} }
} }
public async void RefreshSonarr(){ public async void RefreshSonarr(){
@ -244,7 +242,10 @@ public class Crunchyroll{
return forDate; return forDate;
} }
var request = HttpClientReq.CreateRequestMessage($"{calendarLanguage[CrunOptions.SelectedCalendarLanguage ?? "de"]}?filter=premium&date={weeksMondayDate}", HttpMethod.Get, false, false, null); var request = calendarLanguage.ContainsKey(CrunOptions.SelectedCalendarLanguage ?? "de")
? HttpClientReq.CreateRequestMessage($"{calendarLanguage[CrunOptions.SelectedCalendarLanguage ?? "de"]}?filter=premium&date={weeksMondayDate}", HttpMethod.Get, false, false, null)
: HttpClientReq.CreateRequestMessage($"{calendarLanguage["en-us"]}?filter=premium&date={weeksMondayDate}", HttpMethod.Get, false, false, null);
request.Headers.Accept.ParseAdd("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"); request.Headers.Accept.ParseAdd("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8");
request.Headers.AcceptEncoding.ParseAdd("gzip, deflate, br"); request.Headers.AcceptEncoding.ParseAdd("gzip, deflate, br");
@ -338,7 +339,7 @@ public class Crunchyroll{
return; return;
} }
var sList = await CrEpisode.EpisodeData((CrunchyEpisode)episodeL,updateHistory); var sList = await CrEpisode.EpisodeData((CrunchyEpisode)episodeL, updateHistory);
var selected = CrEpisode.EpisodeMeta(sList, dubLang); var selected = CrEpisode.EpisodeMeta(sList, dubLang);
if (CrunOptions.IncludeVideoDescription){ if (CrunOptions.IncludeVideoDescription){
@ -1210,7 +1211,7 @@ public class Crunchyroll{
Doing = "Decrypting video" Doing = "Decrypting video"
}; };
Queue.Refresh(); Queue.Refresh();
var decryptVideo = await Helpers.ExecuteCommandAsyncWorkDir("mp4decrypt", CfgManager.PathMP4Decrypt, commandVideo,tempTsFileWorkDir); var decryptVideo = await Helpers.ExecuteCommandAsyncWorkDir("mp4decrypt", CfgManager.PathMP4Decrypt, commandVideo, tempTsFileWorkDir);
if (!decryptVideo.IsOk){ if (!decryptVideo.IsOk){
Console.Error.WriteLine($"Decryption failed with exit code {decryptVideo.ErrorCode}"); Console.Error.WriteLine($"Decryption failed with exit code {decryptVideo.ErrorCode}");
@ -1220,6 +1221,7 @@ public class Crunchyroll{
} catch (IOException ex){ } catch (IOException ex){
Console.WriteLine($"An error occurred: {ex.Message}"); Console.WriteLine($"An error occurred: {ex.Message}");
} }
return new DownloadResponse{ return new DownloadResponse{
Data = files, Data = files,
Error = dlFailed, Error = dlFailed,
@ -1274,7 +1276,7 @@ public class Crunchyroll{
Doing = "Decrypting audio" Doing = "Decrypting audio"
}; };
Queue.Refresh(); Queue.Refresh();
var decryptAudio = await Helpers.ExecuteCommandAsyncWorkDir("mp4decrypt", CfgManager.PathMP4Decrypt, commandAudio,tempTsFileWorkDir); var decryptAudio = await Helpers.ExecuteCommandAsyncWorkDir("mp4decrypt", CfgManager.PathMP4Decrypt, commandAudio, tempTsFileWorkDir);
if (!decryptAudio.IsOk){ if (!decryptAudio.IsOk){
Console.Error.WriteLine($"Decryption failed with exit code {decryptAudio.ErrorCode}"); Console.Error.WriteLine($"Decryption failed with exit code {decryptAudio.ErrorCode}");
@ -1283,6 +1285,7 @@ public class Crunchyroll{
} catch (IOException ex){ } catch (IOException ex){
Console.WriteLine($"An error occurred: {ex.Message}"); Console.WriteLine($"An error occurred: {ex.Message}");
} }
return new DownloadResponse{ return new DownloadResponse{
Data = files, Data = files,
Error = dlFailed, Error = dlFailed,

View File

@ -65,7 +65,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
CustomCalendar = Crunchyroll.Instance.CrunOptions.CustomCalendar; CustomCalendar = Crunchyroll.Instance.CrunOptions.CustomCalendar;
HideDubs = Crunchyroll.Instance.CrunOptions.CalendarHideDubs; HideDubs = Crunchyroll.Instance.CrunOptions.CalendarHideDubs;
HideDubs = Crunchyroll.Instance.CrunOptions.CalendarFilterByAirDate; FilterByAirDate = Crunchyroll.Instance.CrunOptions.CalendarFilterByAirDate;
ComboBoxItem? dubfilter = CalendarDubFilter.FirstOrDefault(a => a.Content != null && (string)a.Content == Crunchyroll.Instance.CrunOptions.CalendarDubFilter) ?? null; ComboBoxItem? dubfilter = CalendarDubFilter.FirstOrDefault(a => a.Content != null && (string)a.Content == Crunchyroll.Instance.CrunOptions.CalendarDubFilter) ?? null;
CurrentCalendarDubFilter = dubfilter ?? CalendarDubFilter[0]; CurrentCalendarDubFilter = dubfilter ?? CalendarDubFilter[0];