Crunchy-Downloader/CRD/Utils/Structs/History/HistoryEpisode.cs
Elwador 4f6d0f2257 Add - Added --historyRefreshActive parameter
Add - Added **hardware acceleration options** for sync timings
Add - Added an **icon for episodes removed from Crunchyroll** or moved to a different season
Add - Added **highlighting for selected dubs/subs** in history
Add - Added **highlighting of episode titles** when all selected dubs/subs are available
Add - Added option to **set history series to inactive**
Add - Added **filter for Active and Inactive** series in history
Add - Added **download retry options** to settings, making retry variables editable
Chg - Changed **Sonarr missing filter** to respect the "Skip Unmonitored" setting
Chg - Changed to **show an error** if an episode wasn't added to the queue
Chg - Changed to show **dates for episodes** in the history
Chg - Changed **sync timings algorithm** to improve overall performance
Chg - Changed **sync timings algorithm** to more accurately synchronize dubs
Chg - Changed **series/season refresh messages** to indicate failure or success more clearly
Chg - Changed **error display frequency** to reduce repeated popups for the same message
Fix - Fixed **movie detection** to properly verify if the ID corresponds to a movie
Fix - Fixed **long option hiding remove buttons** for FFmpeg and MKVMerge additional options
Fix - Fixed **toast message timer** not updating correctly
Fix - Fixed **path length error**
Fix - Fixed a **rare crash when navigating history**
2025-04-23 22:36:05 +02:00

124 lines
No EOL
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using CRD.Downloader;
using CRD.Downloader.Crunchyroll;
using CRD.Utils.Files;
using Newtonsoft.Json;
namespace CRD.Utils.Structs.History;
public class HistoryEpisode : INotifyPropertyChanged{
[JsonProperty("episode_title")]
public string? EpisodeTitle{ get; set; }
[JsonProperty("episode_id")]
public string? EpisodeId{ get; set; }
[JsonProperty("episode_cr_episode_number")]
public string? Episode{ get; set; }
[JsonProperty("episode_cr_episode_description")]
public string? EpisodeDescription{ get; set; }
[JsonProperty("episode_cr_season_number")]
public string? EpisodeSeasonNum{ get; set; }
[JsonProperty("episode_cr_premium_air_date")]
public DateTime? EpisodeCrPremiumAirDate{ get; set; }
[JsonProperty("episode_was_downloaded")]
public bool WasDownloaded{ get; set; }
[JsonProperty("episode_special_episode")]
public bool SpecialEpisode{ get; set; }
[JsonProperty("episode_available_on_streaming_service")]
public bool IsEpisodeAvailableOnStreamingService{ get; set; }
[JsonProperty("episode_type")]
public EpisodeType EpisodeType{ get; set; } = EpisodeType.Unknown;
[JsonProperty("sonarr_episode_id")]
public string? SonarrEpisodeId{ get; set; }
[JsonProperty("sonarr_has_file")]
public bool SonarrHasFile{ get; set; }
[JsonProperty("sonarr_is_monitored")]
public bool SonarrIsMonitored{ get; set; }
[JsonProperty("sonarr_episode_number")]
public string? SonarrEpisodeNumber{ get; set; }
[JsonProperty("sonarr_season_number")]
public string? SonarrSeasonNumber{ get; set; }
[JsonProperty("sonarr_absolut_number")]
public string? SonarrAbsolutNumber{ get; set; }
[JsonProperty("history_episode_available_soft_subs")]
public List<string> HistoryEpisodeAvailableSoftSubs{ get; set; } =[];
[JsonProperty("history_episode_available_dub_lang")]
public List<string> HistoryEpisodeAvailableDubLang{ get; set; } =[];
[JsonIgnore]
public string ReleaseDateFormated{
get{
if (!EpisodeCrPremiumAirDate.HasValue ||
EpisodeCrPremiumAirDate.Value == DateTime.MinValue ||
EpisodeCrPremiumAirDate.Value.Date == new DateTime(1970, 1, 1))
return string.Empty;
var cultureInfo = System.Globalization.CultureInfo.InvariantCulture;
string monthAbbreviation = cultureInfo.DateTimeFormat.GetAbbreviatedMonthName(EpisodeCrPremiumAirDate.Value.Month);
return string.Format("{0:00}.{1}.{2}", EpisodeCrPremiumAirDate.Value.Day, monthAbbreviation, EpisodeCrPremiumAirDate.Value.Year);
}
}
public event PropertyChangedEventHandler? PropertyChanged;
public void ToggleWasDownloaded(){
WasDownloaded = !WasDownloaded;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(WasDownloaded)));
}
public void ToggleWasDownloadedSeries(HistorySeries? series){
WasDownloaded = !WasDownloaded;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(WasDownloaded)));
if (series?.Seasons != null){
foreach (var historySeason in series.Seasons){
historySeason.UpdateDownloadedSilent();
}
series.UpdateNewEpisodes();
}
CfgManager.UpdateHistoryFile();
}
public async Task DownloadEpisode(bool onlySubs = false){
switch (EpisodeType){
case EpisodeType.MusicVideo:
await QueueManager.Instance.CrAddMusicVideoToQueue(EpisodeId ?? string.Empty);
break;
case EpisodeType.Concert:
await QueueManager.Instance.CrAddConcertToQueue(EpisodeId ?? string.Empty);
break;
case EpisodeType.Episode:
case EpisodeType.Unknown:
default:
await QueueManager.Instance.CrAddEpisodeToQueue(EpisodeId ?? string.Empty,
string.IsNullOrEmpty(CrunchyrollManager.Instance.CrunOptions.HistoryLang) ? CrunchyrollManager.Instance.DefaultLocale : CrunchyrollManager.Instance.CrunOptions.HistoryLang,
CrunchyrollManager.Instance.CrunOptions.DubLang, false, onlySubs);
break;
}
}
}