From 49270824f24129fd2944266d3c27b584c975bb68 Mon Sep 17 00:00:00 2001 From: Elwador <75888166+Elwador@users.noreply.github.com> Date: Sat, 29 Jun 2024 22:15:34 +0200 Subject: [PATCH] Chg - FFmpeg command now also adds title and description if enabled Fix - Short freeze when matching large series with sonarr Fix - Stopped collapsing when refreshing seasons & series Fix - Switching between history sorting didn't update correctly --- CRD/Downloader/History.cs | 8 ++++++-- CRD/Utils/Muxing/Merger.cs | 14 +++++++++++++- CRD/Utils/Structs/History/HistorySeason.cs | 3 +++ CRD/Utils/Structs/History/HistorySeries.cs | 16 ++++++++++------ CRD/ViewModels/HistoryPageViewModel.cs | 3 ++- CRD/ViewModels/SeriesPageViewModel.cs | 2 ++ CRD/Views/HistoryPageView.axaml | 4 ++-- CRD/Views/SeriesPageView.axaml | 2 +- CRD/app.manifest | 18 ++++++++++++++++++ 9 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 CRD/app.manifest diff --git a/CRD/Downloader/History.cs b/CRD/Downloader/History.cs index ae993cc..f32a872 100644 --- a/CRD/Downloader/History.cs +++ b/CRD/Downloader/History.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -453,7 +453,11 @@ public class History(){ Parallel.ForEach(allHistoryEpisodes, historyEpisode => { if (updateAll || string.IsNullOrEmpty(historyEpisode.SonarrEpisodeId)){ - var episode = FindClosestMatchEpisodes(episodes, historyEpisode.EpisodeTitle); + + // Create a copy of the episodes list for each thread + var episodesCopy = new List(episodes); + + var episode = FindClosestMatchEpisodes(episodesCopy, historyEpisode.EpisodeTitle); if (episode != null){ historyEpisode.SonarrEpisodeId = episode.Id + ""; historyEpisode.SonarrEpisodeNumber = episode.EpisodeNumber + ""; diff --git a/CRD/Utils/Muxing/Merger.cs b/CRD/Utils/Muxing/Merger.cs index 18cc43e..34dee2e 100644 --- a/CRD/Utils/Muxing/Merger.cs +++ b/CRD/Utils/Muxing/Merger.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; +using System.Xml; using CRD.Utils.Structs; using DynamicData; @@ -86,7 +87,18 @@ public class Merger{ args.AddRange(options.Subtitles.Select((sub, subindex) => $"-metadata:s:s:{subindex} title=\"{sub.Language.Language ?? sub.Language.Name}{(sub.ClosedCaption == true ? $" {options.CcTag}" : "")}{(sub.Signs == true ? " Signs" : "")}\" -metadata:s:s:{subindex} language={sub.Language.Code}")); - + + if (!string.IsNullOrEmpty(options.VideoTitle)){ + + args.Add($"-metadata title=\"{options.VideoTitle}\""); + } + + if (options.Description is{ Count: > 0 }){ + XmlDocument doc = new XmlDocument(); + doc.Load(options.Description[0].Path); + XmlNode? node = doc.SelectSingleNode("//Tag/Simple[Name='DESCRIPTION']/String"); + args.Add($"-metadata comment=\"{node?.InnerText ?? string.Empty}\""); + } if (options.Options.ffmpeg?.Count > 0){ args.AddRange(options.Options.ffmpeg); diff --git a/CRD/Utils/Structs/History/HistorySeason.cs b/CRD/Utils/Structs/History/HistorySeason.cs index ce13038..6711300 100644 --- a/CRD/Utils/Structs/History/HistorySeason.cs +++ b/CRD/Utils/Structs/History/HistorySeason.cs @@ -30,6 +30,9 @@ public class HistorySeason : INotifyPropertyChanged{ [JsonProperty("series_download_path")] public string? SeasonDownloadPath{ get; set; } + + [JsonIgnore] + public bool IsExpanded{ get; set; } public event PropertyChangedEventHandler? PropertyChanged; diff --git a/CRD/Utils/Structs/History/HistorySeries.cs b/CRD/Utils/Structs/History/HistorySeries.cs index c41e094..cab8543 100644 --- a/CRD/Utils/Structs/History/HistorySeries.cs +++ b/CRD/Utils/Structs/History/HistorySeries.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Threading.Tasks; using Avalonia.Media.Imaging; using CRD.Downloader; +using CRD.Utils.CustomList; using Newtonsoft.Json; namespace CRD.Utils.Structs.History; @@ -26,7 +27,7 @@ public class HistorySeries : INotifyPropertyChanged{ [JsonProperty("sonarr_slug_title")] public string? SonarrSlugTitle{ get; set; } - + [JsonProperty("sonarr_next_air_date")] public string? SonarrNextAirDate{ get; set; } @@ -43,7 +44,7 @@ public class HistorySeries : INotifyPropertyChanged{ public Bitmap? ThumbnailImage{ get; set; } [JsonProperty("series_season_list")] - public required ObservableCollection Seasons{ get; set; } + public required RefreshableObservableCollection Seasons{ get; set; } [JsonProperty("series_download_path")] public string? SeriesDownloadPath{ get; set; } @@ -53,6 +54,9 @@ public class HistorySeries : INotifyPropertyChanged{ [JsonIgnore] public bool FetchingData{ get; set; } + [JsonIgnore] + public bool IsExpanded{ get; set; } + [JsonIgnore] public bool EditModeEnabled{ get => _editModeEnabled; @@ -145,21 +149,21 @@ public class HistorySeries : INotifyPropertyChanged{ FetchingData = true; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData))); await Crunchyroll.Instance.CrHistory.UpdateSeries(SeriesId, seasonId); - FetchingData = false; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SeriesTitle))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SeriesDescription))); Crunchyroll.Instance.CrHistory.MatchHistoryEpisodesWithSonarr(false, this); UpdateNewEpisodes(); + FetchingData = false; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData))); } - + public void RemoveSeason(string? season){ HistorySeason? objectToRemove = Seasons.FirstOrDefault(se => se.SeasonId == season) ?? null; if (objectToRemove != null){ Seasons.Remove(objectToRemove); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Seasons))); } - + CfgManager.WriteJsonToFile(CfgManager.PathCrHistory, Crunchyroll.Instance.HistoryList); } diff --git a/CRD/ViewModels/HistoryPageViewModel.cs b/CRD/ViewModels/HistoryPageViewModel.cs index ca1674c..f3be215 100644 --- a/CRD/ViewModels/HistoryPageViewModel.cs +++ b/CRD/ViewModels/HistoryPageViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; @@ -150,6 +150,7 @@ public partial class HistoryPageViewModel : ViewModelBase{ partial void OnSelectedSortingChanged(ComboBoxItem value){ if (TryParseEnum(value.Content + "", out var sortingType)){ currentSortingType = sortingType; + if (Crunchyroll.Instance.CrunOptions.HistoryPageProperties != null) Crunchyroll.Instance.CrunOptions.HistoryPageProperties.SelectedSorting = currentSortingType; Crunchyroll.Instance.CrHistory.SortItems(); } else{ Console.Error.WriteLine("Invalid viewtype selected"); diff --git a/CRD/ViewModels/SeriesPageViewModel.cs b/CRD/ViewModels/SeriesPageViewModel.cs index 846159d..fe54d8b 100644 --- a/CRD/ViewModels/SeriesPageViewModel.cs +++ b/CRD/ViewModels/SeriesPageViewModel.cs @@ -79,6 +79,8 @@ public partial class SeriesPageViewModel : ViewModelBase{ public async Task UpdateData(string? season){ await SelectedSeries.FetchData(season); + SelectedSeries.Seasons.Refresh(); + // MessageBus.Current.SendMessage(new NavigationMessage(typeof(SeriesPageViewModel), false, true)); } diff --git a/CRD/Views/HistoryPageView.axaml b/CRD/Views/HistoryPageView.axaml index a22265f..ee75fd3 100644 --- a/CRD/Views/HistoryPageView.axaml +++ b/CRD/Views/HistoryPageView.axaml @@ -240,7 +240,7 @@ + IsExpanded="{Binding IsExpanded}"> @@ -373,7 +373,7 @@ ItemsSource="{Binding EpisodesList}" Description="{Binding SeasonTitle}" - IsExpanded="False"> + IsExpanded="{Binding IsExpanded}"> diff --git a/CRD/Views/SeriesPageView.axaml b/CRD/Views/SeriesPageView.axaml index 41eb101..66804d4 100644 --- a/CRD/Views/SeriesPageView.axaml +++ b/CRD/Views/SeriesPageView.axaml @@ -96,7 +96,7 @@ ItemsSource="{Binding EpisodesList}" Description="{Binding SeasonTitle}" - IsExpanded="False"> + IsExpanded="{Binding IsExpanded}"> diff --git a/CRD/app.manifest b/CRD/app.manifest new file mode 100644 index 0000000..6fa9d2d --- /dev/null +++ b/CRD/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +