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
This commit is contained in:
Elwador 2024-06-29 22:15:34 +02:00
parent 36f06e7c5a
commit 49270824f2
9 changed files with 57 additions and 13 deletions

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
@ -453,7 +453,11 @@ public class History(){
Parallel.ForEach(allHistoryEpisodes, historyEpisode => Parallel.ForEach(allHistoryEpisodes, historyEpisode =>
{ {
if (updateAll || string.IsNullOrEmpty(historyEpisode.SonarrEpisodeId)){ 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<SonarrEpisode>(episodes);
var episode = FindClosestMatchEpisodes(episodesCopy, historyEpisode.EpisodeTitle);
if (episode != null){ if (episode != null){
historyEpisode.SonarrEpisodeId = episode.Id + ""; historyEpisode.SonarrEpisodeId = episode.Id + "";
historyEpisode.SonarrEpisodeNumber = episode.EpisodeNumber + ""; historyEpisode.SonarrEpisodeNumber = episode.EpisodeNumber + "";

View File

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml;
using CRD.Utils.Structs; using CRD.Utils.Structs;
using DynamicData; using DynamicData;
@ -86,7 +87,18 @@ public class Merger{
args.AddRange(options.Subtitles.Select((sub, subindex) => 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}")); $"-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){ if (options.Options.ffmpeg?.Count > 0){
args.AddRange(options.Options.ffmpeg); args.AddRange(options.Options.ffmpeg);

View File

@ -30,6 +30,9 @@ public class HistorySeason : INotifyPropertyChanged{
[JsonProperty("series_download_path")] [JsonProperty("series_download_path")]
public string? SeasonDownloadPath{ get; set; } public string? SeasonDownloadPath{ get; set; }
[JsonIgnore]
public bool IsExpanded{ get; set; }
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Media.Imaging; using Avalonia.Media.Imaging;
using CRD.Downloader; using CRD.Downloader;
using CRD.Utils.CustomList;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace CRD.Utils.Structs.History; namespace CRD.Utils.Structs.History;
@ -26,7 +27,7 @@ public class HistorySeries : INotifyPropertyChanged{
[JsonProperty("sonarr_slug_title")] [JsonProperty("sonarr_slug_title")]
public string? SonarrSlugTitle{ get; set; } public string? SonarrSlugTitle{ get; set; }
[JsonProperty("sonarr_next_air_date")] [JsonProperty("sonarr_next_air_date")]
public string? SonarrNextAirDate{ get; set; } public string? SonarrNextAirDate{ get; set; }
@ -43,7 +44,7 @@ public class HistorySeries : INotifyPropertyChanged{
public Bitmap? ThumbnailImage{ get; set; } public Bitmap? ThumbnailImage{ get; set; }
[JsonProperty("series_season_list")] [JsonProperty("series_season_list")]
public required ObservableCollection<HistorySeason> Seasons{ get; set; } public required RefreshableObservableCollection<HistorySeason> Seasons{ get; set; }
[JsonProperty("series_download_path")] [JsonProperty("series_download_path")]
public string? SeriesDownloadPath{ get; set; } public string? SeriesDownloadPath{ get; set; }
@ -53,6 +54,9 @@ public class HistorySeries : INotifyPropertyChanged{
[JsonIgnore] [JsonIgnore]
public bool FetchingData{ get; set; } public bool FetchingData{ get; set; }
[JsonIgnore]
public bool IsExpanded{ get; set; }
[JsonIgnore] [JsonIgnore]
public bool EditModeEnabled{ public bool EditModeEnabled{
get => _editModeEnabled; get => _editModeEnabled;
@ -145,21 +149,21 @@ public class HistorySeries : INotifyPropertyChanged{
FetchingData = true; FetchingData = true;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData)));
await Crunchyroll.Instance.CrHistory.UpdateSeries(SeriesId, seasonId); 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(SeriesTitle)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SeriesDescription))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SeriesDescription)));
Crunchyroll.Instance.CrHistory.MatchHistoryEpisodesWithSonarr(false, this); Crunchyroll.Instance.CrHistory.MatchHistoryEpisodesWithSonarr(false, this);
UpdateNewEpisodes(); UpdateNewEpisodes();
FetchingData = false;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FetchingData)));
} }
public void RemoveSeason(string? season){ public void RemoveSeason(string? season){
HistorySeason? objectToRemove = Seasons.FirstOrDefault(se => se.SeasonId == season) ?? null; HistorySeason? objectToRemove = Seasons.FirstOrDefault(se => se.SeasonId == season) ?? null;
if (objectToRemove != null){ if (objectToRemove != null){
Seasons.Remove(objectToRemove); Seasons.Remove(objectToRemove);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Seasons))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Seasons)));
} }
CfgManager.WriteJsonToFile(CfgManager.PathCrHistory, Crunchyroll.Instance.HistoryList); CfgManager.WriteJsonToFile(CfgManager.PathCrHistory, Crunchyroll.Instance.HistoryList);
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@ -150,6 +150,7 @@ public partial class HistoryPageViewModel : ViewModelBase{
partial void OnSelectedSortingChanged(ComboBoxItem value){ partial void OnSelectedSortingChanged(ComboBoxItem value){
if (TryParseEnum<SortingType>(value.Content + "", out var sortingType)){ if (TryParseEnum<SortingType>(value.Content + "", out var sortingType)){
currentSortingType = sortingType; currentSortingType = sortingType;
if (Crunchyroll.Instance.CrunOptions.HistoryPageProperties != null) Crunchyroll.Instance.CrunOptions.HistoryPageProperties.SelectedSorting = currentSortingType;
Crunchyroll.Instance.CrHistory.SortItems(); Crunchyroll.Instance.CrHistory.SortItems();
} else{ } else{
Console.Error.WriteLine("Invalid viewtype selected"); Console.Error.WriteLine("Invalid viewtype selected");

View File

@ -79,6 +79,8 @@ public partial class SeriesPageViewModel : ViewModelBase{
public async Task UpdateData(string? season){ public async Task UpdateData(string? season){
await SelectedSeries.FetchData(season); await SelectedSeries.FetchData(season);
SelectedSeries.Seasons.Refresh();
// MessageBus.Current.SendMessage(new NavigationMessage(typeof(SeriesPageViewModel), false, true)); // MessageBus.Current.SendMessage(new NavigationMessage(typeof(SeriesPageViewModel), false, true));
} }

View File

@ -240,7 +240,7 @@
<controls:SettingsExpander <controls:SettingsExpander
Header="{Binding .}" Header="{Binding .}"
ItemsSource="{Binding .}" ItemsSource="{Binding .}"
IsExpanded="False"> IsExpanded="{Binding IsExpanded}">
<controls:SettingsExpander.HeaderTemplate> <controls:SettingsExpander.HeaderTemplate>
<DataTemplate DataType="{x:Type history:HistorySeries}"> <DataTemplate DataType="{x:Type history:HistorySeries}">
@ -373,7 +373,7 @@
ItemsSource="{Binding EpisodesList}" ItemsSource="{Binding EpisodesList}"
Description="{Binding SeasonTitle}" Description="{Binding SeasonTitle}"
IsExpanded="False"> IsExpanded="{Binding IsExpanded}">
<controls:SettingsExpander.ItemTemplate> <controls:SettingsExpander.ItemTemplate>

View File

@ -96,7 +96,7 @@
ItemsSource="{Binding EpisodesList}" ItemsSource="{Binding EpisodesList}"
Description="{Binding SeasonTitle}" Description="{Binding SeasonTitle}"
IsExpanded="False"> IsExpanded="{Binding IsExpanded}">
<controls:SettingsExpander.ItemTemplate> <controls:SettingsExpander.ItemTemplate>

18
CRD/app.manifest Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="CRD.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>