Add - Added setting to also include specials in the history operations
Fix - Fixed delay for ffmpeg mp4 Fix - Fixed delay for forced subtitles
This commit is contained in:
parent
e554bf85ec
commit
7e39a1f88e
|
@ -357,13 +357,13 @@ public class CrunchyrollManager{
|
|||
var delay = await merger.ProcessVideo(basePath, syncVideo.Path);
|
||||
var audio = merger.options.OnlyAudio.FirstOrDefault(audio => audio.Language.CrLocale == syncVideo.Lang.CrLocale);
|
||||
if (audio != null){
|
||||
audio.Delay = (int)delay * 1000;
|
||||
audio.Delay = (int)(delay * 1000);
|
||||
}
|
||||
|
||||
var subtitles = merger.options.Subtitles.Where(a => a.RelatedVideoDownloadMedia == syncVideo).ToList();
|
||||
if (subtitles.Count > 0){
|
||||
foreach (var subMergerInput in subtitles){
|
||||
subMergerInput.Delay = (int)delay * 1000;
|
||||
subMergerInput.Delay = (int)(delay * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -47,7 +48,8 @@ public class Merger{
|
|||
|
||||
foreach (var aud in options.OnlyAudio){
|
||||
if (aud.Delay != null && aud.Delay != 0){
|
||||
args.Add($"-itsoffset {aud.Delay}");
|
||||
double delay = aud.Delay / 1000.0 ?? 0;
|
||||
args.Add($"-itsoffset {delay.ToString(CultureInfo.InvariantCulture)}");
|
||||
}
|
||||
|
||||
args.Add($"-i \"{aud.Path}\"");
|
||||
|
@ -66,8 +68,9 @@ public class Merger{
|
|||
}
|
||||
|
||||
foreach (var sub in options.Subtitles.Select((value, i) => new{ value, i })){
|
||||
if (sub.value.Delay != null){
|
||||
args.Add($"-itsoffset -{Math.Ceiling((double)sub.value.Delay * 1000)}ms");
|
||||
if (sub.value.Delay != null && sub.value.Delay != 0){
|
||||
double delay = sub.value.Delay / 1000.0 ?? 0;
|
||||
args.Add($"-itsoffset {delay.ToString(CultureInfo.InvariantCulture)}");
|
||||
}
|
||||
|
||||
args.Add($"-i \"{sub.value.File}\"");
|
||||
|
@ -178,7 +181,7 @@ public class Merger{
|
|||
foreach (var subObj in options.Subtitles){
|
||||
if (subObj.Delay.HasValue){
|
||||
double delay = subObj.Delay ?? 0;
|
||||
args.Add($"--sync 0:-{Math.Ceiling(delay * 1000)}");
|
||||
args.Add($"--sync 0:{delay}");
|
||||
}
|
||||
|
||||
string trackNameExtra = subObj.ClosedCaption == true ? $" {options.CcTag}" : "";
|
||||
|
@ -243,14 +246,12 @@ public class Merger{
|
|||
return 0;
|
||||
}
|
||||
|
||||
var baseFrames = Directory.GetFiles(baseFramesDir).Select(fp => new FrameData
|
||||
{
|
||||
var baseFrames = Directory.GetFiles(baseFramesDir).Select(fp => new FrameData{
|
||||
FilePath = fp,
|
||||
Time = GetTimeFromFileName(fp, extractFramesBase.frameRate)
|
||||
}).ToList();
|
||||
|
||||
var compareFrames = Directory.GetFiles(compareFramesDir).Select(fp => new FrameData
|
||||
{
|
||||
var compareFrames = Directory.GetFiles(compareFramesDir).Select(fp => new FrameData{
|
||||
FilePath = fp,
|
||||
Time = GetTimeFromFileName(fp, extractFramesBase.frameRate)
|
||||
}).ToList();
|
||||
|
@ -320,8 +321,6 @@ public class Merger{
|
|||
// Delete subtitle files
|
||||
options.Subtitles.ForEach(subtitle => Helpers.DeleteFile(subtitle.File));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class MergerInput{
|
||||
|
|
|
@ -150,6 +150,9 @@ public class CrDownloadOptions{
|
|||
[YamlMember(Alias = "history_lang", ApplyNamingConventions = false)]
|
||||
public string? HistoryLang{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "history_add_specials", ApplyNamingConventions = false)]
|
||||
public bool HistoryAddSpecials{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "sonarr_properties", ApplyNamingConventions = false)]
|
||||
public SonarrProperties? SonarrProperties{ get; set; }
|
||||
|
||||
|
|
|
@ -186,25 +186,49 @@ public class HistorySeries : INotifyPropertyChanged{
|
|||
public void UpdateNewEpisodes(){
|
||||
int count = 0;
|
||||
bool foundWatched = false;
|
||||
var historyAddSpecials = CrunchyrollManager.Instance.CrunOptions.HistoryAddSpecials;
|
||||
|
||||
for (int i = Seasons.Count - 1; i >= 0; i--){
|
||||
var season = Seasons[i];
|
||||
|
||||
if (season.SpecialSeason == true){
|
||||
if (historyAddSpecials){
|
||||
var episodes = season.EpisodesList;
|
||||
for (int j = episodes.Count - 1; j >= 0; j--){
|
||||
if (!episodes[j].WasDownloaded){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over the Seasons list from the end to the beginning
|
||||
for (int i = Seasons.Count - 1; i >= 0 && !foundWatched; i--){
|
||||
if (Seasons[i].SpecialSeason == true){
|
||||
continue;
|
||||
}
|
||||
|
||||
// Iterate over the Episodes from the end to the beginning
|
||||
for (int j = Seasons[i].EpisodesList.Count - 1; j >= 0 && !foundWatched; j--){
|
||||
if (Seasons[i].EpisodesList[j].SpecialEpisode){
|
||||
var episodesList = season.EpisodesList;
|
||||
for (int j = episodesList.Count - 1; j >= 0; j--){
|
||||
var episode = episodesList[j];
|
||||
|
||||
if (episode.SpecialEpisode){
|
||||
if (historyAddSpecials && !episode.WasDownloaded){
|
||||
count++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Seasons[i].EpisodesList[j].WasDownloaded){
|
||||
if (!episode.WasDownloaded && !foundWatched){
|
||||
count++;
|
||||
} else{
|
||||
foundWatched = true;
|
||||
if (!historyAddSpecials){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundWatched && !historyAddSpecials){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NewEpisodes = count;
|
||||
|
@ -218,26 +242,49 @@ public class HistorySeries : INotifyPropertyChanged{
|
|||
|
||||
public async Task AddNewMissingToDownloads(){
|
||||
bool foundWatched = false;
|
||||
var historyAddSpecials = CrunchyrollManager.Instance.CrunOptions.HistoryAddSpecials;
|
||||
|
||||
for (int i = Seasons.Count - 1; i >= 0; i--){
|
||||
var season = Seasons[i];
|
||||
|
||||
if (season.SpecialSeason == true){
|
||||
if (historyAddSpecials){
|
||||
var episodes = season.EpisodesList;
|
||||
for (int j = episodes.Count - 1; j >= 0; j--){
|
||||
if (!episodes[j].WasDownloaded){
|
||||
await Seasons[i].EpisodesList[j].DownloadEpisode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over the Seasons list from the end to the beginning
|
||||
for (int i = Seasons.Count - 1; i >= 0 && !foundWatched; i--){
|
||||
if (Seasons[i].SpecialSeason == true){
|
||||
continue;
|
||||
}
|
||||
|
||||
// Iterate over the Episodes from the end to the beginning
|
||||
for (int j = Seasons[i].EpisodesList.Count - 1; j >= 0 && !foundWatched; j--){
|
||||
if (Seasons[i].EpisodesList[j].SpecialEpisode){
|
||||
var episodesList = season.EpisodesList;
|
||||
for (int j = episodesList.Count - 1; j >= 0; j--){
|
||||
var episode = episodesList[j];
|
||||
|
||||
if (episode.SpecialEpisode){
|
||||
if (historyAddSpecials && !episode.WasDownloaded){
|
||||
await Seasons[i].EpisodesList[j].DownloadEpisode();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Seasons[i].EpisodesList[j].WasDownloaded){
|
||||
//ADD to download queue
|
||||
if (!episode.WasDownloaded && !foundWatched){
|
||||
await Seasons[i].EpisodesList[j].DownloadEpisode();
|
||||
} else{
|
||||
foundWatched = true;
|
||||
if (!historyAddSpecials){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundWatched && !historyAddSpecials){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
[ObservableProperty]
|
||||
private bool _history;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _historyAddSpecials;
|
||||
|
||||
[ObservableProperty]
|
||||
private double? _leadingNumbers;
|
||||
|
||||
|
@ -377,6 +380,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
AddScaledBorderAndShadow = options.SubsAddScaledBorder is ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo or ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||
SelectedScaledBorderAndShadow = GetScaledBorderAndShadowFromOptions(options);
|
||||
|
||||
HistoryAddSpecials = options.HistoryAddSpecials;
|
||||
DownloadSpeed = options.DownloadSpeedLimit;
|
||||
IncludeEpisodeDescription = options.IncludeVideoDescription;
|
||||
FileTitle = options.VideoTitle ?? "";
|
||||
|
@ -443,6 +447,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
}
|
||||
|
||||
CrunchyrollManager.Instance.CrunOptions.IncludeVideoDescription = IncludeEpisodeDescription;
|
||||
CrunchyrollManager.Instance.CrunOptions.HistoryAddSpecials = HistoryAddSpecials;
|
||||
CrunchyrollManager.Instance.CrunOptions.VideoTitle = FileTitle;
|
||||
CrunchyrollManager.Instance.CrunOptions.Novids = !DownloadVideo;
|
||||
CrunchyrollManager.Instance.CrunOptions.Noaudio = !DownloadAudio;
|
||||
|
|
|
@ -144,6 +144,12 @@
|
|||
</controls:SettingsExpanderItem.Footer>
|
||||
</controls:SettingsExpanderItem>
|
||||
|
||||
<controls:SettingsExpanderItem Content="History Add Specials" Description="Add specials to the queue if they weren't downloaded before">
|
||||
<controls:SettingsExpanderItem.Footer>
|
||||
<CheckBox IsChecked="{Binding HistoryAddSpecials}"> </CheckBox>
|
||||
</controls:SettingsExpanderItem.Footer>
|
||||
</controls:SettingsExpanderItem>
|
||||
|
||||
</controls:SettingsExpander>
|
||||
|
||||
<controls:SettingsExpander Header="Download Settings"
|
||||
|
|
Loading…
Reference in New Issue