mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 21:33:02 +02:00
Add config option to disable dummy chapter generation (#9410)
This commit is contained in:
parent
28562bcadd
commit
21dcf775be
|
@ -243,16 +243,10 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public bool AllowClientLogUpload { get; set; } = true;
|
public bool AllowClientLogUpload { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the dummy chapters duration in seconds.
|
/// Gets or sets the dummy chapter duration in seconds, use 0 (zero) or less to disable generation alltogether.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The dummy chapters duration.</value>
|
/// <value>The dummy chapters duration.</value>
|
||||||
public int DummyChapterDuration { get; set; } = 300;
|
public int DummyChapterDuration { get; set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the dummy chapter count.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The dummy chapter count.</value>
|
|
||||||
public int DummyChapterCount { get; set; } = 100;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the chapter image resolution.
|
/// Gets or sets the chapter image resolution.
|
||||||
|
|
|
@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
|
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
|
||||||
options.MetadataRefreshMode == MetadataRefreshMode.Default)
|
options.MetadataRefreshMode == MetadataRefreshMode.Default)
|
||||||
{
|
{
|
||||||
if (chapters.Length == 0 && mediaStreams.Any(i => i.Type == MediaStreamType.Video))
|
if (_config.Configuration.DummyChapterDuration > 0 && chapters.Length == 0 && mediaStreams.Any(i => i.Type == MediaStreamType.Video))
|
||||||
{
|
{
|
||||||
chapters = CreateDummyChapters(video);
|
chapters = CreateDummyChapters(video);
|
||||||
}
|
}
|
||||||
|
@ -662,25 +662,22 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
private ChapterInfo[] CreateDummyChapters(Video video)
|
private ChapterInfo[] CreateDummyChapters(Video video)
|
||||||
{
|
{
|
||||||
var runtime = video.RunTimeTicks ?? 0;
|
var runtime = video.RunTimeTicks ?? 0;
|
||||||
long dummyChapterDuration = TimeSpan.FromSeconds(_config.Configuration.DummyChapterDuration).Ticks;
|
|
||||||
|
|
||||||
if (runtime < 0)
|
// Only process files with a runtime higher than 0 and lower than 12h. The latter are likely corrupted.
|
||||||
|
if (runtime < 0 || runtime > TimeSpan.FromHours(12).Ticks)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
string.Format(
|
string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"{0} has invalid runtime of {1}",
|
"{0} has an invalid runtime of {1} minutes",
|
||||||
video.Name,
|
video.Name,
|
||||||
runtime));
|
TimeSpan.FromTicks(runtime).Minutes));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime < dummyChapterDuration)
|
long dummyChapterDuration = TimeSpan.FromSeconds(_config.Configuration.DummyChapterDuration).Ticks;
|
||||||
|
if (runtime > dummyChapterDuration)
|
||||||
{
|
{
|
||||||
return Array.Empty<ChapterInfo>();
|
int chapterCount = (int)(runtime / dummyChapterDuration);
|
||||||
}
|
|
||||||
|
|
||||||
// Limit the chapters just in case there's some incorrect metadata here
|
|
||||||
int chapterCount = (int)Math.Min(runtime / dummyChapterDuration, _config.Configuration.DummyChapterCount);
|
|
||||||
var chapters = new ChapterInfo[chapterCount];
|
var chapters = new ChapterInfo[chapterCount];
|
||||||
|
|
||||||
long currentChapterTicks = 0;
|
long currentChapterTicks = 0;
|
||||||
|
@ -696,5 +693,8 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
|
|
||||||
return chapters;
|
return chapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Array.Empty<ChapterInfo>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue