aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs90
1 files changed, 28 insertions, 62 deletions
diff --git a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
index 5b72860b6..5adddd38a 100644
--- a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
+++ b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
@@ -24,17 +24,15 @@ namespace MediaBrowser.Server.Implementations.Intros
public class DefaultIntroProvider : IIntroProvider
{
private readonly ISecurityManager _security;
- private readonly IChannelManager _channelManager;
private readonly ILocalizationManager _localization;
private readonly IConfigurationManager _serverConfig;
private readonly ILibraryManager _libraryManager;
private readonly IFileSystem _fileSystem;
private readonly IMediaSourceManager _mediaSourceManager;
- public DefaultIntroProvider(ISecurityManager security, IChannelManager channelManager, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager, IFileSystem fileSystem, IMediaSourceManager mediaSourceManager)
+ public DefaultIntroProvider(ISecurityManager security, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager, IFileSystem fileSystem, IMediaSourceManager mediaSourceManager)
{
_security = security;
- _channelManager = channelManager;
_localization = localization;
_serverConfig = serverConfig;
_libraryManager = libraryManager;
@@ -79,76 +77,45 @@ namespace MediaBrowser.Server.Implementations.Intros
AppearsInItemId = item.Id
});
- if (config.EnableIntrosFromMoviesInLibrary)
- {
- var inputItems = _libraryManager.GetItems(new InternalItemsQuery(user)
- {
- IncludeItemTypes = new[] { typeof(Movie).Name }
-
- }, new string[] { });
-
- var itemsWithTrailers = inputItems
- .Where(i =>
- {
- var hasTrailers = i as IHasTrailers;
-
- if (hasTrailers != null && hasTrailers.LocalTrailerIds.Count > 0)
- {
- if (i is Movie)
- {
- return !IsDuplicate(item, i);
- }
- }
- return false;
- });
-
- candidates.AddRange(itemsWithTrailers.Select(i => new ItemWithTrailer
- {
- Item = i,
- Type = ItemWithTrailerType.ItemWithTrailer,
- User = user,
- WatchingItem = item,
- WatchingItemPeople = itemPeople,
- AllPeople = allPeople,
- Random = random,
- LibraryManager = _libraryManager
- }));
- }
-
var trailerTypes = new List<TrailerType>();
- if (config.EnableIntrosFromUpcomingTrailers)
- {
- trailerTypes.Add(TrailerType.ComingSoonToTheaters);
- }
- if (config.EnableIntrosFromUpcomingDvdMovies)
- {
- trailerTypes.Add(TrailerType.ComingSoonToDvd);
- }
- if (config.EnableIntrosFromUpcomingStreamingMovies)
+ if (config.EnableIntrosFromMoviesInLibrary)
{
- trailerTypes.Add(TrailerType.ComingSoonToStreaming);
+ trailerTypes.Add(TrailerType.LocalTrailer);
}
- if (config.EnableIntrosFromSimilarMovies)
+
+ if (IsSupporter)
{
- trailerTypes.Add(TrailerType.Archive);
+ if (config.EnableIntrosFromUpcomingTrailers)
+ {
+ trailerTypes.Add(TrailerType.ComingSoonToTheaters);
+ }
+ if (config.EnableIntrosFromUpcomingDvdMovies)
+ {
+ trailerTypes.Add(TrailerType.ComingSoonToDvd);
+ }
+ if (config.EnableIntrosFromUpcomingStreamingMovies)
+ {
+ trailerTypes.Add(TrailerType.ComingSoonToStreaming);
+ }
+ if (config.EnableIntrosFromSimilarMovies)
+ {
+ trailerTypes.Add(TrailerType.Archive);
+ }
}
- if (trailerTypes.Count > 0 && IsSupporter)
+ if (trailerTypes.Count > 0)
{
- var channelTrailers = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
+ var trailerResult = _libraryManager.GetItems(new InternalItemsQuery
{
- ContentTypes = new[] { ChannelMediaContentType.MovieExtra },
- ExtraTypes = new[] { ExtraType.Trailer },
- UserId = user.Id.ToString("N"),
+ IncludeItemTypes = new[] { typeof(Trailer).Name },
TrailerTypes = trailerTypes.ToArray()
+ });
- }, CancellationToken.None);
-
- candidates.AddRange(channelTrailers.Items.Select(i => new ItemWithTrailer
+ candidates.AddRange(trailerResult.Items.Select(i => new ItemWithTrailer
{
Item = i,
- Type = ItemWithTrailerType.ChannelTrailer,
+ Type = i.SourceType == SourceType.Channel ? ItemWithTrailerType.ChannelTrailer : ItemWithTrailerType.ItemWithTrailer,
User = user,
WatchingItem = item,
WatchingItemPeople = itemPeople,
@@ -156,7 +123,7 @@ namespace MediaBrowser.Server.Implementations.Intros
Random = random,
LibraryManager = _libraryManager
}));
- }
+ }
return GetResult(item, candidates, config, ratingLevel);
}
@@ -556,7 +523,6 @@ namespace MediaBrowser.Server.Implementations.Intros
internal enum ItemWithTrailerType
{
- LibraryTrailer,
ChannelTrailer,
ItemWithTrailer
}