more cleanup
This commit is contained in:
parent
8ca0212db7
commit
2eb6a873a8
@ -1,12 +1,13 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Media file analyzer used to detect end credits that consist of text overlaid on a black background.
|
/// Media file analyzer used to detect end credits that consist of text overlaid on a black background.
|
||||||
/// Bisects the end of the video file to perform an efficient search.
|
/// Bisects the end of the video file to perform an efficient search.
|
||||||
@ -76,7 +77,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer
|
|||||||
/// <returns>Credits timestamp.</returns>
|
/// <returns>Credits timestamp.</returns>
|
||||||
public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum)
|
public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum)
|
||||||
{
|
{
|
||||||
var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration();
|
var config = Plugin.Instance?.Configuration ?? new PluginConfiguration();
|
||||||
|
|
||||||
// Start by analyzing the last N minutes of the file.
|
// Start by analyzing the last N minutes of the file.
|
||||||
var start = TimeSpan.FromSeconds(config.MaximumCreditsDuration);
|
var start = TimeSpan.FromSeconds(config.MaximumCreditsDuration);
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -7,9 +5,12 @@ using System.Globalization;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Chapter name analyzer.
|
/// Chapter name analyzer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -89,7 +90,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
|
|||||||
{
|
{
|
||||||
Intro? matchingChapter = null;
|
Intro? matchingChapter = null;
|
||||||
|
|
||||||
var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration();
|
var config = Plugin.Instance?.Configuration ?? new PluginConfiguration();
|
||||||
|
|
||||||
var minDuration = config.MinimumIntroDuration;
|
var minDuration = config.MinimumIntroDuration;
|
||||||
int maxDuration = mode == AnalysisMode.Introduction ?
|
int maxDuration = mode == AnalysisMode.Introduction ?
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Chromaprint audio analyzer.
|
/// Chromaprint audio analyzer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -38,7 +39,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer
|
|||||||
/// <param name="logger">Logger.</param>
|
/// <param name="logger">Logger.</param>
|
||||||
public ChromaprintAnalyzer(ILogger<ChromaprintAnalyzer> logger)
|
public ChromaprintAnalyzer(ILogger<ChromaprintAnalyzer> logger)
|
||||||
{
|
{
|
||||||
var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration();
|
var config = Plugin.Instance?.Configuration ?? new PluginConfiguration();
|
||||||
maximumDifferences = config.MaximumFingerprintPointDifferences;
|
maximumDifferences = config.MaximumFingerprintPointDifferences;
|
||||||
invertedIndexShift = config.InvertedIndexShift;
|
invertedIndexShift = config.InvertedIndexShift;
|
||||||
maximumTimeSkip = config.MaximumTimeSkip;
|
maximumTimeSkip = config.MaximumTimeSkip;
|
||||||
@ -277,8 +278,8 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer
|
|||||||
|
|
||||||
if (rhsIndex.TryGetValue(modifiedPoint, out var rhsModifiedPoint))
|
if (rhsIndex.TryGetValue(modifiedPoint, out var rhsModifiedPoint))
|
||||||
{
|
{
|
||||||
var lhsFirst = (int)lhsIndex[originalPoint];
|
var lhsFirst = lhsIndex[originalPoint];
|
||||||
var rhsFirst = (int)rhsModifiedPoint;
|
var rhsFirst = rhsModifiedPoint;
|
||||||
indexShifts.Add(rhsFirst - lhsFirst);
|
indexShifts.Add(rhsFirst - lhsFirst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Media file analyzer interface.
|
/// Media file analyzer interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Chapter name analyzer.
|
/// Chapter name analyzer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -12,6 +12,7 @@ using MediaBrowser.Model.Plugins;
|
|||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public class AutoSkip : IHostedService, IDisposable
|
|||||||
private ILogger<AutoSkip> _logger;
|
private ILogger<AutoSkip> _logger;
|
||||||
private IUserDataManager _userDataManager;
|
private IUserDataManager _userDataManager;
|
||||||
private ISessionManager _sessionManager;
|
private ISessionManager _sessionManager;
|
||||||
private System.Timers.Timer _playbackTimer = new(1000);
|
private Timer _playbackTimer = new(1000);
|
||||||
private Dictionary<string, bool> _sentSeekCommand;
|
private Dictionary<string, bool> _sentSeekCommand;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -152,7 +153,7 @@ public class AutoSkip : IHostedService, IDisposable
|
|||||||
_sessionManager.SendMessageCommand(
|
_sessionManager.SendMessageCommand(
|
||||||
session.Id,
|
session.Id,
|
||||||
session.Id,
|
session.Id,
|
||||||
new MessageCommand()
|
new MessageCommand
|
||||||
{
|
{
|
||||||
Header = string.Empty, // some clients require header to be a string instead of null
|
Header = string.Empty, // some clients require header to be a string instead of null
|
||||||
Text = notificationText,
|
Text = notificationText,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
@ -102,7 +103,7 @@ public class Intro
|
|||||||
var start = Math.Round(IntroStart, 2);
|
var start = Math.Round(IntroStart, 2);
|
||||||
var end = Math.Round(IntroEnd, 2);
|
var end = Math.Round(IntroEnd, 2);
|
||||||
|
|
||||||
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", start, end, (int)action);
|
return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", start, end, (int)action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Support bundle warning.
|
/// Support bundle warning.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update EDL files associated with a list of episodes.
|
/// Update EDL files associated with a list of episodes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -68,7 +68,8 @@ public static class EdlManager
|
|||||||
_logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id);
|
_logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (!intro.Valid)
|
|
||||||
|
if (!intro.Valid)
|
||||||
{
|
{
|
||||||
_logger?.LogDebug("Episode {Id} did not have a valid introduction, skipping", id);
|
_logger?.LogDebug("Episode {Id} did not have a valid introduction, skipping", id);
|
||||||
continue;
|
continue;
|
||||||
|
@ -206,7 +206,7 @@ public class Entrypoint : IHostedService, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unless user initiated, this is likely an overlap
|
// Unless user initiated, this is likely an overlap
|
||||||
if (Entrypoint.AutomaticTaskState == TaskState.Running)
|
if (AutomaticTaskState == TaskState.Running)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public class Entrypoint : IHostedService, IDisposable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void StartTimer()
|
private void StartTimer()
|
||||||
{
|
{
|
||||||
if (Entrypoint.AutomaticTaskState == TaskState.Running)
|
if (AutomaticTaskState == TaskState.Running)
|
||||||
{
|
{
|
||||||
_analyzeAgain = true; // Items added during a scan will be included later.
|
_analyzeAgain = true; // Items added during a scan will be included later.
|
||||||
}
|
}
|
||||||
@ -347,8 +347,6 @@ public class Entrypoint : IHostedService, IDisposable
|
|||||||
if (!dispose)
|
if (!dispose)
|
||||||
{
|
{
|
||||||
_queueTimer.Dispose();
|
_queueTimer.Dispose();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public static class FFmpegWrapper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Unknown analysis mode " + mode.ToString());
|
throw new ArgumentException("Unknown analysis mode " + mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Fingerprint(episode, mode, start, end);
|
return Fingerprint(episode, mode, start, end);
|
||||||
@ -642,14 +642,13 @@ public static class FFmpegWrapper
|
|||||||
{
|
{
|
||||||
return basePath;
|
return basePath;
|
||||||
}
|
}
|
||||||
else if (mode == AnalysisMode.Credits)
|
|
||||||
|
if (mode == AnalysisMode.Credits)
|
||||||
{
|
{
|
||||||
return basePath + "-credits";
|
return basePath + "-credits";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
throw new ArgumentException("Unknown analysis mode " + mode);
|
||||||
throw new ArgumentException("Unknown analysis mode " + mode.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FormatFFmpegLog(string key)
|
private static string FormatFFmpegLog(string key)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -9,9 +7,10 @@ using Jellyfin.Data.Enums;
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manages enqueuing library items for analysis.
|
/// Manages enqueuing library items for analysis.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -124,7 +123,7 @@ public class QueueManager
|
|||||||
{
|
{
|
||||||
_logger.LogDebug("Constructing anonymous internal query");
|
_logger.LogDebug("Constructing anonymous internal query");
|
||||||
|
|
||||||
var query = new InternalItemsQuery()
|
var query = new InternalItemsQuery
|
||||||
{
|
{
|
||||||
// Order by series name, season, and then episode number so that status updates are logged in order
|
// Order by series name, season, and then episode number so that status updates are logged in order
|
||||||
ParentId = id,
|
ParentId = id,
|
||||||
@ -203,7 +202,7 @@ public class QueueManager
|
|||||||
|
|
||||||
// Queue the episode for analysis
|
// Queue the episode for analysis
|
||||||
var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration;
|
var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration;
|
||||||
_queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode()
|
_queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode
|
||||||
{
|
{
|
||||||
SeriesName = episode.SeriesName,
|
SeriesName = episode.SeriesName,
|
||||||
SeasonNumber = episode.AiredSeasonNumber ?? 0,
|
SeasonNumber = episode.AiredSeasonNumber ?? 0,
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -7,6 +5,8 @@ using System.Threading.Tasks;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Common code shared by all media item analyzer tasks.
|
/// Common code shared by all media item analyzer tasks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -85,12 +85,12 @@ public class BaseItemAnalyzerTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
var totalProcessed = 0;
|
var totalProcessed = 0;
|
||||||
var options = new ParallelOptions()
|
var options = new ParallelOptions
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = Plugin.Instance.Configuration.MaxParallelism
|
MaxDegreeOfParallelism = Plugin.Instance.Configuration.MaxParallelism
|
||||||
};
|
};
|
||||||
|
|
||||||
Parallel.ForEach(queue, options, (season) =>
|
Parallel.ForEach(queue, options, season =>
|
||||||
{
|
{
|
||||||
var writeEdl = false;
|
var writeEdl = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user