diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-19 11:38:05 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-19 11:38:05 -0400 |
| commit | 1d2b6329bf3d395c57ac45a0f56b2e15bbee4c22 (patch) | |
| tree | d1938509e92eac1b2f8ac9f5657785a155a05d50 /MediaBrowser.Api | |
| parent | 5dd77ab145553ea81b9faa6167a426b1ddcf1e9b (diff) | |
update channels
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/Library/LibraryService.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Api/Movies/MoviesService.cs | 59 | ||||
| -rw-r--r-- | MediaBrowser.Api/Movies/TrailersService.cs | 16 |
3 files changed, 28 insertions, 58 deletions
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 896f8c9908..1d7b76c369 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -289,7 +289,6 @@ namespace MediaBrowser.Api.Library private readonly IActivityManager _activityManager; private readonly ILocalizationManager _localization; private readonly ILiveTvManager _liveTv; - private readonly IChannelManager _channelManager; private readonly ITVSeriesManager _tvManager; private readonly ILibraryMonitor _libraryMonitor; private readonly IFileSystem _fileSystem; @@ -298,7 +297,7 @@ namespace MediaBrowser.Api.Library /// Initializes a new instance of the <see cref="LibraryService" /> class. /// </summary> public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, - IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization, ILiveTvManager liveTv, IChannelManager channelManager, ITVSeriesManager tvManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem) + IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization, ILiveTvManager liveTv, ITVSeriesManager tvManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem) { _itemRepo = itemRepo; _libraryManager = libraryManager; @@ -309,7 +308,6 @@ namespace MediaBrowser.Api.Library _activityManager = activityManager; _localization = localization; _liveTv = liveTv; - _channelManager = channelManager; _tvManager = tvManager; _libraryMonitor = libraryMonitor; _fileSystem = fileSystem; @@ -379,11 +377,10 @@ namespace MediaBrowser.Api.Library } var program = item as IHasProgramAttributes; - var channelItem = item as ChannelVideoItem; - if (item is Movie || (program != null && program.IsMovie) || (channelItem != null && channelItem.ContentType == ChannelMediaContentType.Movie) || (channelItem != null && channelItem.ContentType == ChannelMediaContentType.MovieExtra)) + if (item is Movie || (program != null && program.IsMovie) || item is Trailer) { - return new MoviesService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService, _channelManager) + return new MoviesService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService) { AuthorizationContext = AuthorizationContext, Logger = Logger, @@ -400,7 +397,7 @@ namespace MediaBrowser.Api.Library }); } - if (item is Series || (program != null && program.IsSeries) || (channelItem != null && channelItem.ContentType == ChannelMediaContentType.Episode)) + if (item is Series || (program != null && program.IsSeries) ) { return new TvShowsService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService, _tvManager) { diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 36cbc6ffa6..b60aa0cbad 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -91,22 +91,21 @@ namespace MediaBrowser.Api.Movies private readonly IItemRepository _itemRepo; private readonly IDtoService _dtoService; - private readonly IChannelManager _channelManager; - /// <summary> - /// Initializes a new instance of the <see cref="MoviesService"/> class. + /// Initializes a new instance of the <see cref="MoviesService" /> class. /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="userDataRepository">The user data repository.</param> /// <param name="libraryManager">The library manager.</param> - public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, IChannelManager channelManager) + /// <param name="itemRepo">The item repo.</param> + /// <param name="dtoService">The dto service.</param> + public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; _libraryManager = libraryManager; _itemRepo = itemRepo; _dtoService = dtoService; - _channelManager = channelManager; } /// <summary> @@ -138,6 +137,14 @@ namespace MediaBrowser.Api.Movies { IncludeItemTypes = new[] { typeof(Movie).Name } }; + + if (user.Configuration.IncludeTrailersInSuggestions) + { + var includeList = query.IncludeItemTypes.ToList(); + includeList.Add(typeof(Trailer).Name); + query.IncludeItemTypes = includeList.ToArray(); + } + var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId }; var movies = _libraryManager.GetItems(query, parentIds); movies = _libraryManager.ReplaceVideosWithPrimaryVersions(movies); @@ -150,19 +157,6 @@ namespace MediaBrowser.Api.Movies listEligibleForCategories.AddRange(list); listEligibleForSuggestion.AddRange(list); - if (user.Configuration.IncludeTrailersInSuggestions) - { - var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery - { - ContentTypes = new[] { ChannelMediaContentType.MovieExtra }, - ExtraTypes = new[] { ExtraType.Trailer }, - UserId = user.Id.ToString("N") - - }, CancellationToken.None).ConfigureAwait(false); - - listEligibleForSuggestion.AddRange(trailerResult.Items); - } - listEligibleForCategories = listEligibleForCategories .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase) .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase) @@ -194,6 +188,14 @@ namespace MediaBrowser.Api.Movies { IncludeItemTypes = new[] { typeof(Movie).Name } }; + + if (user == null || user.Configuration.IncludeTrailersInSuggestions) + { + var includeList = query.IncludeItemTypes.ToList(); + includeList.Add(typeof(Trailer).Name); + query.IncludeItemTypes = includeList.ToArray(); + } + var parentIds = new string[] { }; var list = _libraryManager.GetItems(query, parentIds) .Where(i => @@ -202,28 +204,9 @@ namespace MediaBrowser.Api.Movies var v = i as Video; return v != null && !v.PrimaryVersionId.HasValue; }) + .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) .ToList(); - if (user != null && user.Configuration.IncludeTrailersInSuggestions) - { - var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery - { - ContentTypes = new[] { ChannelMediaContentType.MovieExtra }, - ExtraTypes = new[] { ExtraType.Trailer }, - UserId = user.Id.ToString("N") - - }, CancellationToken.None).ConfigureAwait(false); - - var newTrailers = trailerResult.Items; - - list.AddRange(newTrailers); - - list = list - .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase) - .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase) - .ToList(); - } - if (item is Video) { var imdbId = item.GetProviderId(MetadataProviders.Imdb); diff --git a/MediaBrowser.Api/Movies/TrailersService.cs b/MediaBrowser.Api/Movies/TrailersService.cs index ed197911a0..39c7b7f446 100644 --- a/MediaBrowser.Api/Movies/TrailersService.cs +++ b/MediaBrowser.Api/Movies/TrailersService.cs @@ -108,20 +108,10 @@ namespace MediaBrowser.Api.Movies private async Task<QueryResult<BaseItem>> GetAllTrailers(User user) { - var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery + return _libraryManager.GetItems(new InternalItemsQuery(user) { - ContentTypes = new[] { ChannelMediaContentType.MovieExtra }, - ExtraTypes = new[] { ExtraType.Trailer }, - UserId = user.Id.ToString("N") - - }, CancellationToken.None).ConfigureAwait(false); - - - return new QueryResult<BaseItem> - { - Items = trailerResult.Items, - TotalRecordCount = trailerResult.TotalRecordCount - }; + IncludeItemTypes = new[] {typeof (Trailer).Name} + }); } } } |
