mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
add custom intros path
This commit is contained in:
parent
1afb28b487
commit
99dba814f4
@ -10,10 +10,10 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
public bool EnableIntrosFromMoviesInLibrary { get; set; }
|
public bool EnableIntrosFromMoviesInLibrary { get; set; }
|
||||||
public bool EnableCustomIntro { get; set; }
|
public bool EnableCustomIntro { get; set; }
|
||||||
public bool EnableIntrosParentalControl { get; set; }
|
public bool EnableIntrosParentalControl { get; set; }
|
||||||
|
public string CustomIntroPath { get; set; }
|
||||||
|
|
||||||
public CinemaModeConfiguration()
|
public CinemaModeConfiguration()
|
||||||
{
|
{
|
||||||
EnableIntrosForMovies = true;
|
|
||||||
EnableCustomIntro = true;
|
EnableCustomIntro = true;
|
||||||
EnableIntrosFromMoviesInLibrary = true;
|
EnableIntrosFromMoviesInLibrary = true;
|
||||||
EnableIntrosFromUpcomingTrailers = true;
|
EnableIntrosFromUpcomingTrailers = true;
|
||||||
|
@ -6,11 +6,13 @@ using MediaBrowser.Controller.Entities.Movies;
|
|||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Model.Channels;
|
using MediaBrowser.Model.Channels;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -55,11 +57,6 @@ namespace MediaBrowser.Server.Implementations.Intros
|
|||||||
return new List<IntroInfo>();
|
return new List<IntroInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsSupporter)
|
|
||||||
{
|
|
||||||
return new List<IntroInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
var ratingLevel = string.IsNullOrWhiteSpace(item.OfficialRating)
|
var ratingLevel = string.IsNullOrWhiteSpace(item.OfficialRating)
|
||||||
? (int?)null
|
? (int?)null
|
||||||
: _localization.GetRatingLevel(item.OfficialRating);
|
: _localization.GetRatingLevel(item.OfficialRating);
|
||||||
@ -98,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.EnableIntrosFromUpcomingTrailers)
|
if (config.EnableIntrosFromUpcomingTrailers && IsSupporter)
|
||||||
{
|
{
|
||||||
var channelTrailers = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
|
var channelTrailers = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
|
||||||
{
|
{
|
||||||
@ -137,7 +134,6 @@ namespace MediaBrowser.Server.Implementations.Intros
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var currentUser = user;
|
|
||||||
return candidates.Where(i =>
|
return candidates.Where(i =>
|
||||||
{
|
{
|
||||||
if (config.EnableIntrosParentalControl && !FilterByParentalRating(ratingLevel, i.Item))
|
if (config.EnableIntrosParentalControl && !FilterByParentalRating(ratingLevel, i.Item))
|
||||||
@ -166,7 +162,33 @@ namespace MediaBrowser.Server.Implementations.Intros
|
|||||||
|
|
||||||
private List<IntroInfo> GetCustomIntros(BaseItem item)
|
private List<IntroInfo> GetCustomIntros(BaseItem item)
|
||||||
{
|
{
|
||||||
return new List<IntroInfo>();
|
try
|
||||||
|
{
|
||||||
|
return GetCustomIntroFiles()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Select(i => new IntroInfo
|
||||||
|
{
|
||||||
|
Path = i
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
return new List<IntroInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<string> GetCustomIntroFiles(CinemaModeConfiguration options = null)
|
||||||
|
{
|
||||||
|
options = options ?? GetOptions();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(options.CustomIntroPath))
|
||||||
|
{
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Directory.EnumerateFiles(options.CustomIntroPath, "*", SearchOption.AllDirectories)
|
||||||
|
.Where(EntityResolutionHelper.IsVideoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FilterByParentalRating(int? ratingLevel, BaseItem item)
|
private bool FilterByParentalRating(int? ratingLevel, BaseItem item)
|
||||||
@ -265,7 +287,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
|||||||
|
|
||||||
public IEnumerable<string> GetAllIntroFiles()
|
public IEnumerable<string> GetAllIntroFiles()
|
||||||
{
|
{
|
||||||
return new List<string>();
|
return GetCustomIntroFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsSupporter
|
private bool IsSupporter
|
||||||
|
@ -1235,7 +1235,19 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// <returns>IEnumerable{System.String}.</returns>
|
/// <returns>IEnumerable{System.String}.</returns>
|
||||||
public IEnumerable<string> GetAllIntroFiles()
|
public IEnumerable<string> GetAllIntroFiles()
|
||||||
{
|
{
|
||||||
return IntroProviders.SelectMany(i => i.GetAllIntroFiles());
|
return IntroProviders.SelectMany(i =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return i.GetAllIntroFiles().ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting intro files", ex);
|
||||||
|
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -570,5 +570,6 @@
|
|||||||
"MediaInfoStreamTypeSubtitle": "Subtitle",
|
"MediaInfoStreamTypeSubtitle": "Subtitle",
|
||||||
"MediaInfoStreamTypeEmbeddedImage": "Embedded Image",
|
"MediaInfoStreamTypeEmbeddedImage": "Embedded Image",
|
||||||
"MediaInfoRefFrames": "Ref frames",
|
"MediaInfoRefFrames": "Ref frames",
|
||||||
"TabPlayback": "Playback"
|
"TabPlayback": "Playback",
|
||||||
|
"HeaderSelectCustomIntrosPath": "Select Custom Intros Path"
|
||||||
}
|
}
|
||||||
|
@ -1188,12 +1188,13 @@
|
|||||||
"TitlePlayback": "Playback",
|
"TitlePlayback": "Playback",
|
||||||
"LabelEnableCinemaModeFor": "Enable cinema mode for:",
|
"LabelEnableCinemaModeFor": "Enable cinema mode for:",
|
||||||
"CinemaModeConfigurationHelp": "Cinema mode brings the theater experience straight to your living room with the ability to play trailers and custom intros before the main feature.",
|
"CinemaModeConfigurationHelp": "Cinema mode brings the theater experience straight to your living room with the ability to play trailers and custom intros before the main feature.",
|
||||||
"LabelEnableTheFollowingIntros": "Enable the following types of intros:",
|
"OptionTrailersFromMyMovies": "Include trailers from movies in my library",
|
||||||
"OptionTrailersFromMyMovies": "Trailers from movies in my library",
|
"OptionUpcomingMoviesInTheaters": "Include trailers from new and upcoming movies",
|
||||||
"OptionUpcomingMoviesInTheaters": "Trailers from upcoming movies",
|
|
||||||
"LabelLimitIntrosToUnwatchedContent": "Only use trailers from unwatched content",
|
"LabelLimitIntrosToUnwatchedContent": "Only use trailers from unwatched content",
|
||||||
"LabelEnableIntroParentalControl": "Enable smart parental control",
|
"LabelEnableIntroParentalControl": "Enable smart parental control",
|
||||||
"LabelEnableIntroParentalControlHelp": "Intros will only used from content with a parental rating equal to or less than the content being watched.",
|
"LabelEnableIntroParentalControlHelp": "Trailers will only be selected with a parental rating equal to or less than the content being watched.",
|
||||||
"LabelEnableTheFollowingIntrosHelp": "Trailers from existing movies requires setup of local trailers. Theater trailers require installation of the Trailer channel plugin.",
|
"LabelThisFeatureRequiresSupporterHelp": "This feature requires an active supporter membership.",
|
||||||
"ButtonThisFeatureRequiresSupporter": "This feature requires an active supporter membership"
|
"OptionTrailersFromMyMoviesHelp": "Requires setup of local trailers.",
|
||||||
|
"LabelCustomIntrosPath": "Custom intros path:",
|
||||||
|
"LabelCustomIntrosPathHelp": "A folder containing video files. A video will be randomly selected and played after trailers."
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user