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