From 99dba814f405f08111b36ace4ba8a7fc7a273245 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 22 Sep 2014 20:04:50 -0400 Subject: add custom intros path --- .../Intros/DefaultIntroProvider.cs | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs') diff --git a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs index b5e449eae..97129368e 100644 --- a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs +++ b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs @@ -6,11 +6,13 @@ using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; +using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Channels; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -55,11 +57,6 @@ namespace MediaBrowser.Server.Implementations.Intros return new List(); } - if (!IsSupporter) - { - return new List(); - } - var ratingLevel = string.IsNullOrWhiteSpace(item.OfficialRating) ? (int?)null : _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 { @@ -137,7 +134,6 @@ namespace MediaBrowser.Server.Implementations.Intros } // Avoid implicitly captured closure - var currentUser = user; return candidates.Where(i => { if (config.EnableIntrosParentalControl && !FilterByParentalRating(ratingLevel, i.Item)) @@ -166,7 +162,33 @@ namespace MediaBrowser.Server.Implementations.Intros private List GetCustomIntros(BaseItem item) { - return new List(); + try + { + return GetCustomIntroFiles() + .OrderBy(i => Guid.NewGuid()) + .Select(i => new IntroInfo + { + Path = i + + }).ToList(); + } + catch (IOException) + { + return new List(); + } + } + + private IEnumerable GetCustomIntroFiles(CinemaModeConfiguration options = null) + { + options = options ?? GetOptions(); + + if (string.IsNullOrWhiteSpace(options.CustomIntroPath)) + { + return new List(); + } + + return Directory.EnumerateFiles(options.CustomIntroPath, "*", SearchOption.AllDirectories) + .Where(EntityResolutionHelper.IsVideoFile); } private bool FilterByParentalRating(int? ratingLevel, BaseItem item) @@ -265,7 +287,7 @@ namespace MediaBrowser.Server.Implementations.Intros public IEnumerable GetAllIntroFiles() { - return new List(); + return GetCustomIntroFiles(); } private bool IsSupporter -- cgit v1.2.3