Fix - Hotfix for Filter by Air date overwriting Hide Dubs
Fix - Crash when opening calendar for the first time
This commit is contained in:
parent
6b44dbf28c
commit
53158b261d
|
@ -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" },
|
||||||
|
@ -134,7 +135,7 @@ public class Crunchyroll{
|
||||||
PreferredContentSubtitleLanguage = "de-DE",
|
PreferredContentSubtitleLanguage = "de-DE",
|
||||||
HasPremium = false,
|
HasPremium = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
Console.WriteLine($"Can Decrypt: {_widevine.canDecrypt}");
|
Console.WriteLine($"Can Decrypt: {_widevine.canDecrypt}");
|
||||||
|
|
||||||
CrunOptions.AutoDownload = false;
|
CrunOptions.AutoDownload = false;
|
||||||
|
@ -158,18 +159,18 @@ 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";
|
||||||
CrunOptions.SubsAddScaledBorder = ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
CrunOptions.SubsAddScaledBorder = ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||||
CrunOptions.HistoryLang = "";
|
CrunOptions.HistoryLang = "";
|
||||||
|
|
||||||
|
|
||||||
CrunOptions.History = true;
|
CrunOptions.History = true;
|
||||||
|
|
||||||
CfgManager.UpdateSettingsFromFile();
|
CfgManager.UpdateSettingsFromFile();
|
||||||
|
|
||||||
if (CrunOptions.LogMode){
|
if (CrunOptions.LogMode){
|
||||||
CfgManager.EnableLogMode();
|
CfgManager.EnableLogMode();
|
||||||
} else{
|
} else{
|
||||||
|
@ -182,7 +183,7 @@ public class Crunchyroll{
|
||||||
} else{
|
} else{
|
||||||
await CrAuth.AuthAnonymous();
|
await CrAuth.AuthAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CrunOptions.History){
|
if (CrunOptions.History){
|
||||||
if (File.Exists(CfgManager.PathCrHistory)){
|
if (File.Exists(CfgManager.PathCrHistory)){
|
||||||
HistoryList = JsonConvert.DeserializeObject<ObservableCollection<HistorySeries>>(File.ReadAllText(CfgManager.PathCrHistory)) ??[];
|
HistoryList = JsonConvert.DeserializeObject<ObservableCollection<HistorySeries>>(File.ReadAllText(CfgManager.PathCrHistory)) ??[];
|
||||||
|
@ -190,9 +191,6 @@ public class Crunchyroll{
|
||||||
|
|
||||||
RefreshSonarr();
|
RefreshSonarr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void RefreshSonarr(){
|
public async void RefreshSonarr(){
|
||||||
|
@ -218,7 +216,7 @@ public class Crunchyroll{
|
||||||
|
|
||||||
UpdateDownloadListItems();
|
UpdateDownloadListItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDownloadListItems(){
|
public void UpdateDownloadListItems(){
|
||||||
var list = Queue;
|
var list = Queue;
|
||||||
|
|
||||||
|
@ -244,11 +242,14 @@ 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");
|
||||||
|
|
||||||
var response = await HttpClientReq.Instance.SendHttpRequest(request);
|
var response = await HttpClientReq.Instance.SendHttpRequest(request);
|
||||||
|
|
||||||
CalendarWeek week = new CalendarWeek();
|
CalendarWeek week = new CalendarWeek();
|
||||||
|
@ -338,9 +339,9 @@ 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){
|
||||||
if (selected.Data is{ Count: > 0 }){
|
if (selected.Data is{ Count: > 0 }){
|
||||||
var episode = await CrEpisode.ParseEpisodeById(selected.Data.First().MediaId, string.IsNullOrEmpty(CrunOptions.DescriptionLang) ? DefaultLocale : CrunOptions.DescriptionLang, true);
|
var episode = await CrEpisode.ParseEpisodeById(selected.Data.First().MediaId, string.IsNullOrEmpty(CrunOptions.DescriptionLang) ? DefaultLocale : CrunOptions.DescriptionLang, true);
|
||||||
|
@ -356,21 +357,21 @@ public class Crunchyroll{
|
||||||
if (!string.IsNullOrEmpty(historyEpisode.historyEpisode.SonarrEpisodeNumber)){
|
if (!string.IsNullOrEmpty(historyEpisode.historyEpisode.SonarrEpisodeNumber)){
|
||||||
selected.EpisodeNumber = historyEpisode.historyEpisode.SonarrEpisodeNumber;
|
selected.EpisodeNumber = historyEpisode.historyEpisode.SonarrEpisodeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(historyEpisode.historyEpisode.SonarrSeasonNumber)){
|
if (!string.IsNullOrEmpty(historyEpisode.historyEpisode.SonarrSeasonNumber)){
|
||||||
selected.Season = historyEpisode.historyEpisode.SonarrSeasonNumber;
|
selected.Season = historyEpisode.historyEpisode.SonarrSeasonNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(historyEpisode.downloadDirPath)){
|
if (!string.IsNullOrEmpty(historyEpisode.downloadDirPath)){
|
||||||
selected.DownloadPath = historyEpisode.downloadDirPath;
|
selected.DownloadPath = historyEpisode.downloadDirPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue.Add(selected);
|
Queue.Add(selected);
|
||||||
|
|
||||||
|
|
||||||
if (selected.Data.Count < dubLang.Count){
|
if (selected.Data.Count < dubLang.Count){
|
||||||
Console.WriteLine("Added Episode to Queue but couldn't find all selected dubs");
|
Console.WriteLine("Added Episode to Queue but couldn't find all selected dubs");
|
||||||
MessageBus.Current.SendMessage(new ToastMessage($"Added episode to the queue but couldn't find all selected dubs", ToastType.Warning, 2));
|
MessageBus.Current.SendMessage(new ToastMessage($"Added episode to the queue but couldn't find all selected dubs", ToastType.Warning, 2));
|
||||||
|
@ -410,7 +411,7 @@ public class Crunchyroll{
|
||||||
crunchyEpMeta.DownloadPath = historyEpisode.downloadDirPath;
|
crunchyEpMeta.DownloadPath = historyEpisode.downloadDirPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CrunOptions.IncludeVideoDescription){
|
if (CrunOptions.IncludeVideoDescription){
|
||||||
if (crunchyEpMeta.Data is{ Count: > 0 }){
|
if (crunchyEpMeta.Data is{ Count: > 0 }){
|
||||||
var episode = await CrEpisode.ParseEpisodeById(crunchyEpMeta.Data.First().MediaId, string.IsNullOrEmpty(CrunOptions.DescriptionLang) ? DefaultLocale : CrunOptions.DescriptionLang, true);
|
var episode = await CrEpisode.ParseEpisodeById(crunchyEpMeta.Data.First().MediaId, string.IsNullOrEmpty(CrunOptions.DescriptionLang) ? DefaultLocale : CrunOptions.DescriptionLang, true);
|
||||||
|
@ -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,
|
||||||
|
|
|
@ -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];
|
||||||
|
|
Loading…
Reference in New Issue