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 class. /// 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; - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The user manager. /// The user data repository. /// The library manager. - public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, IChannelManager channelManager) + /// The item repo. + /// The dto service. + public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; _libraryManager = libraryManager; _itemRepo = itemRepo; _dtoService = dtoService; - _channelManager = channelManager; } /// @@ -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> 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 - { - Items = trailerResult.Items, - TotalRecordCount = trailerResult.TotalRecordCount - }; + IncludeItemTypes = new[] {typeof (Trailer).Name} + }); } } } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs deleted file mode 100644 index c42363dcf9..0000000000 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ /dev/null @@ -1,142 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Channels; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Users; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Runtime.Serialization; -using System.Threading; - -namespace MediaBrowser.Controller.Channels -{ - public class ChannelVideoItem : Video, IHasLookupInfo - { - public ChannelMediaContentType ContentType { get; set; } - - public List ChannelMediaSources { get; set; } - - protected override string CreateUserDataKey() - { - if (ContentType == ChannelMediaContentType.MovieExtra) - { - var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb); - - if (!string.IsNullOrWhiteSpace(key)) - { - key = key + "-" + ExtraType.ToString().ToLower(); - - // Make sure different trailers have their own data. - if (RunTimeTicks.HasValue) - { - key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture); - } - - return key; - } - } - - return ExternalId; - } - - public override UnratedItem GetBlockUnratedType() - { - return UnratedItem.ChannelContent; - } - - [IgnoreDataMember] - public override SourceType SourceType - { - get { return SourceType.Channel; } - set { } - } - - [IgnoreDataMember] - public override bool SupportsLocalMetadata - { - get - { - return false; - } - } - - public override bool IsSaveLocalMetadataEnabled() - { - return false; - } - - public ChannelVideoItem() - { - ChannelMediaSources = new List(); - } - - [IgnoreDataMember] - public override LocationType LocationType - { - get - { - if (string.IsNullOrEmpty(Path)) - { - return LocationType.Remote; - } - - return base.LocationType; - } - } - - public override IEnumerable GetMediaSources(bool enablePathSubstitution) - { - var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None) - .Result.ToList(); - - if (sources.Count > 0) - { - return sources; - } - - var list = base.GetMediaSources(enablePathSubstitution).ToList(); - - foreach (var mediaSource in list) - { - if (string.IsNullOrWhiteSpace(mediaSource.Path)) - { - mediaSource.Type = MediaSourceType.Placeholder; - } - } - - return list; - } - - public ChannelItemLookupInfo GetLookupInfo() - { - var info = GetItemLookupInfo(); - - info.ContentType = ContentType; - - if (ExtraType.HasValue) - { - info.ExtraType = ExtraType.Value; - } - - return info; - } - - protected override string GetInternalMetadataPath(string basePath) - { - return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N")); - } - - public override bool CanDelete() - { - return false; - } - - public override bool IsVisibleStandalone(User user) - { - return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user); - } - } -} diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 366aceb835..22f688c424 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1359,6 +1359,11 @@ namespace MediaBrowser.Controller.Entities public virtual string GetClientTypeName() { + if (IsFolder && SourceType == SourceType.Channel) + { + return "ChannelFolderItem"; + } + return GetType().Name; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 56f1e8a66f..cedc9591d5 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -116,6 +116,7 @@ namespace MediaBrowser.Controller.Entities public LocationType[] ExcludeLocationTypes { get; set; } public string[] PresetViews { get; set; } public SourceType[] SourceTypes { get; set; } + public SourceType[] ExcludeSourceTypes { get; set; } public InternalItemsQuery() { @@ -143,6 +144,7 @@ namespace MediaBrowser.Controller.Entities ExcludeLocationTypes = new LocationType[] { }; PresetViews = new string[] { }; SourceTypes = new SourceType[] { }; + ExcludeSourceTypes = new SourceType[] { }; } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 3bff5bc64f..cefc1dabe9 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -106,8 +106,49 @@ namespace MediaBrowser.Controller.Entities var info = GetItemLookupInfo(); info.IsLocalTrailer = IsLocalTrailer; + + if (!IsInMixedFolder) + { + info.Name = System.IO.Path.GetFileName(ContainingFolderPath); + } return info; } + + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + if (!ProductionYear.HasValue) + { + var info = LibraryManager.ParseName(Name); + + var yearInName = info.Year; + + if (yearInName.HasValue) + { + ProductionYear = yearInName; + hasChanges = true; + } + else + { + // Try to get the year from the folder name + if (!IsInMixedFolder) + { + info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); + + yearInName = info.Year; + + if (yearInName.HasValue) + { + ProductionYear = yearInName; + hasChanges = true; + } + } + } + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 1972226692..3b1da85b55 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -6,13 +6,16 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; +using System.Net.Mime; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Common.IO; +using MediaBrowser.Controller.Channels; namespace MediaBrowser.Controller.Entities { @@ -33,6 +36,7 @@ namespace MediaBrowser.Controller.Entities public List AdditionalParts { get; set; } public List LocalAlternateVersions { get; set; } public List LinkedAlternateVersions { get; set; } + public List ChannelMediaSources { get; set; } [IgnoreDataMember] public bool IsThemeMedia @@ -78,6 +82,23 @@ namespace MediaBrowser.Controller.Entities locationType != LocationType.Virtual; } + [IgnoreDataMember] + public override LocationType LocationType + { + get + { + if (SourceType == SourceType.Channel) + { + if (string.IsNullOrEmpty(Path)) + { + return LocationType.Remote; + } + } + + return base.LocationType; + } + } + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { @@ -130,6 +151,29 @@ namespace MediaBrowser.Controller.Entities return LocalAlternateVersions.Select(i => LibraryManager.GetNewItemId(i, typeof(Video))); } + protected override string CreateUserDataKey() + { + if (ExtraType.HasValue) + { + var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb); + + if (!string.IsNullOrWhiteSpace(key)) + { + key = key + "-" + ExtraType.ToString().ToLower(); + + // Make sure different trailers have their own data. + if (RunTimeTicks.HasValue) + { + key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture); + } + + return key; + } + } + + return base.CreateUserDataKey(); + } + /// /// Gets the linked children. /// @@ -441,6 +485,22 @@ namespace MediaBrowser.Controller.Entities public virtual IEnumerable GetMediaSources(bool enablePathSubstitution) { + if (SourceType == SourceType.Channel) + { + var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None) + .Result.ToList(); + + if (sources.Count > 0) + { + return sources; + } + + return new List + { + GetVersionInfo(enablePathSubstitution, this, MediaSourceType.Placeholder) + }; + } + var item = this; var result = item.GetAlternateVersions() diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 7cc66ef737..572f45b361 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -83,7 +83,6 @@ - @@ -268,7 +267,6 @@ - diff --git a/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs b/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs deleted file mode 100644 index 6c972f3bf5..0000000000 --- a/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediaBrowser.Model.Channels; -using MediaBrowser.Model.Entities; - -namespace MediaBrowser.Controller.Providers -{ - public class ChannelItemLookupInfo : ItemLookupInfo - { - public ChannelMediaContentType ContentType { get; set; } - public ExtraType ExtraType { get; set; } - } -} \ No newline at end of file diff --git a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs index 937a3f8fdf..233f96f655 100644 --- a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs +++ b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs @@ -488,7 +488,7 @@ namespace MediaBrowser.Dlna.ContentDirectory var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user) { Person = person.Name, - IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name, typeof(ChannelVideoItem).Name }, + IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name }, SortBy = new[] { ItemSortBy.SortName }, Limit = limit, StartIndex = startIndex diff --git a/MediaBrowser.Providers/Channels/VideoChannelItemMetadataService.cs b/MediaBrowser.Providers/Channels/VideoChannelItemMetadataService.cs deleted file mode 100644 index 597ae5e10c..0000000000 --- a/MediaBrowser.Providers/Channels/VideoChannelItemMetadataService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.Channels; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; -using MediaBrowser.Providers.Manager; -using System.Collections.Generic; -using CommonIO; - -namespace MediaBrowser.Providers.Channels -{ - public class VideoChannelItemMetadataService : MetadataService - { - public VideoChannelItemMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager) - { - } - - protected override void MergeData(MetadataResult source, MetadataResult target, List lockedFields, bool replaceData, bool mergeMetadataSettings) - { - ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); - } - } -} diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index f9d4d7bd4a..2a2408b2fe 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -92,7 +92,6 @@ - diff --git a/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs b/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs index c29df61912..6bfd9b7fa7 100644 --- a/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs @@ -42,23 +42,6 @@ namespace MediaBrowser.Providers.Movies public bool Supports(IHasImages item) { - var channelItem = item as ChannelVideoItem; - - if (channelItem != null) - { - if (channelItem.ContentType == ChannelMediaContentType.Movie) - { - return true; - } - if (channelItem.ContentType == ChannelMediaContentType.MovieExtra) - { - if (channelItem.ExtraType == ExtraType.Trailer) - { - return true; - } - } - } - // Supports images for tv movies var tvProgram = item as LiveTvProgram; if (tvProgram != null && tvProgram.IsMovie) @@ -66,7 +49,7 @@ namespace MediaBrowser.Providers.Movies return true; } - return item is Movie || item is MusicVideo; + return item is Movie || item is MusicVideo || item is Trailer; } public IEnumerable GetSupportedImages(IHasImages item) diff --git a/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs b/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs index 2bb452df77..2b8686d5d6 100644 --- a/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Providers.Movies { - public class MovieDbTrailerProvider : IHasOrder, IRemoteMetadataProvider + public class MovieDbTrailerProvider : IHasOrder, IRemoteMetadataProvider { private readonly IHttpClient _httpClient; @@ -26,24 +26,9 @@ namespace MediaBrowser.Providers.Movies return MovieDbProvider.Current.GetMovieSearchResults(searchInfo, cancellationToken); } - public Task> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken) + public Task> GetMetadata(TrailerInfo info, CancellationToken cancellationToken) { - if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer) - { - return Task.FromResult(new MetadataResult()); - } - - return MovieDbProvider.Current.GetItemMetadata(info, cancellationToken); - } - - public Task> GetSearchResults(ChannelItemLookupInfo info, CancellationToken cancellationToken) - { - if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer) - { - return Task.FromResult>(new List()); - } - - return MovieDbProvider.Current.GetMovieSearchResults(info, cancellationToken); + return MovieDbProvider.Current.GetItemMetadata(info, cancellationToken); } public string Name diff --git a/MediaBrowser.Providers/Movies/MovieExternalIds.cs b/MediaBrowser.Providers/Movies/MovieExternalIds.cs index c582447a9f..adaff5e771 100644 --- a/MediaBrowser.Providers/Movies/MovieExternalIds.cs +++ b/MediaBrowser.Providers/Movies/MovieExternalIds.cs @@ -28,13 +28,6 @@ namespace MediaBrowser.Providers.Movies public bool Supports(IHasProviderIds item) { - var channelItem = item as ChannelVideoItem; - - if (channelItem != null && channelItem.ContentType == ChannelMediaContentType.MovieExtra && channelItem.ExtraType == ExtraType.Trailer) - { - return true; - } - // Supports images for tv movies var tvProgram = item as LiveTvProgram; if (tvProgram != null && tvProgram.IsMovie) @@ -42,7 +35,7 @@ namespace MediaBrowser.Providers.Movies return true; } - return item is Movie || item is MusicVideo; + return item is Movie || item is MusicVideo || item is Trailer; } } @@ -88,7 +81,7 @@ namespace MediaBrowser.Providers.Movies public bool Supports(IHasProviderIds item) { - return item is Movie || item is MusicVideo; + return item is Movie || item is MusicVideo || item is Trailer; } } @@ -157,14 +150,7 @@ namespace MediaBrowser.Providers.Movies public bool Supports(IHasProviderIds item) { - var channelItem = item as ChannelVideoItem; - - if (channelItem != null && channelItem.ContentType == ChannelMediaContentType.MovieExtra && channelItem.ExtraType == ExtraType.Trailer) - { - return true; - } - - return item is Movie || item is MusicVideo || item is Series || item is Episode; + return item is Movie || item is MusicVideo || item is Series || item is Episode || item is Trailer; } } diff --git a/MediaBrowser.Providers/Movies/MovieMetadataService.cs b/MediaBrowser.Providers/Movies/MovieMetadataService.cs index f4cad837a1..1e55dce760 100644 --- a/MediaBrowser.Providers/Movies/MovieMetadataService.cs +++ b/MediaBrowser.Providers/Movies/MovieMetadataService.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; @@ -8,6 +7,7 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Providers.Manager; using System.Collections.Generic; using CommonIO; +using MediaBrowser.Controller.Entities; namespace MediaBrowser.Providers.Movies { @@ -43,4 +43,31 @@ namespace MediaBrowser.Providers.Movies } } } + + public class TrailerMetadataService : MetadataService + { + public TrailerMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) + : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager) + { + } + + protected override bool IsFullLocalMetadata(Trailer item) + { + if (string.IsNullOrWhiteSpace(item.Overview)) + { + return false; + } + if (!item.ProductionYear.HasValue) + { + return false; + } + return base.IsFullLocalMetadata(item); + } + + protected override void MergeData(MetadataResult source, MetadataResult target, List lockedFields, bool replaceData, bool mergeMetadataSettings) + { + ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); + } + } + } diff --git a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs index d63a1594e4..345ed8adb8 100644 --- a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs @@ -81,23 +81,6 @@ namespace MediaBrowser.Providers.Omdb return false; } - var channelItem = item as ChannelVideoItem; - - if (channelItem != null) - { - if (channelItem.ContentType == ChannelMediaContentType.Movie) - { - return true; - } - if (channelItem.ContentType == ChannelMediaContentType.MovieExtra) - { - if (channelItem.ExtraType == ExtraType.Trailer) - { - return true; - } - } - } - // Supports images for tv movies var tvProgram = item as LiveTvProgram; if (tvProgram != null && tvProgram.IsMovie) @@ -105,7 +88,7 @@ namespace MediaBrowser.Providers.Omdb return true; } - return item is Movie; + return item is Movie || item is Trailer; } public int Order diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs index ace1a8ffb9..a33e1d6c17 100644 --- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs @@ -22,7 +22,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Providers.Omdb { public class OmdbItemProvider : IRemoteMetadataProvider, - IRemoteMetadataProvider, IRemoteMetadataProvider, IRemoteMetadataProvider + IRemoteMetadataProvider, IRemoteMetadataProvider, IRemoteMetadataProvider { private readonly IJsonSerializer _jsonSerializer; private readonly IHttpClient _httpClient; @@ -196,23 +196,13 @@ namespace MediaBrowser.Providers.Omdb return list; } - public Task> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken) + public Task> GetMetadata(TrailerInfo info, CancellationToken cancellationToken) { - if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer) - { - return Task.FromResult(new MetadataResult()); - } - - return GetMovieResult(info, cancellationToken); + return GetMovieResult(info, cancellationToken); } - public Task> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken) + public Task> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken) { - if (searchInfo.ContentType != ChannelMediaContentType.MovieExtra || searchInfo.ExtraType != ExtraType.Trailer) - { - return Task.FromResult>(new List()); - } - return GetSearchResults(searchInfo, "movie", cancellationToken); } diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index 775f7224c0..ee49a7005c 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -27,6 +27,8 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Entities.TV; namespace MediaBrowser.Server.Implementations.Channels { @@ -252,7 +254,7 @@ namespace MediaBrowser.Server.Implementations.Channels public async Task> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken) { IEnumerable results = new List(); - var video = item as ChannelVideoItem; + var video = item as Video; if (video != null) { results = video.ChannelMediaSources; @@ -1263,7 +1265,22 @@ namespace MediaBrowser.Server.Implementations.Channels } else { - item = GetItemById(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew); + if (info.ContentType == ChannelMediaContentType.Episode) + { + item = GetItemById(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew); + } + else if (info.ContentType == ChannelMediaContentType.Movie) + { + item = GetItemById(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew); + } + else if (info.ContentType == ChannelMediaContentType.Trailer || info.ExtraType == ExtraType.Trailer) + { + item = GetItemById(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew); + } + else + { + item = GetItemById