update channels

This commit is contained in:
Luke Pulverenti 2016-03-19 11:38:05 -04:00
parent 5dd77ab145
commit 1d2b6329bf
23 changed files with 216 additions and 338 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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}
});
}
}
}

View File

@ -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<ChannelItemLookupInfo>
{
public ChannelMediaContentType ContentType { get; set; }
public List<ChannelMediaInfo> 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<ChannelMediaInfo>();
}
[IgnoreDataMember]
public override LocationType LocationType
{
get
{
if (string.IsNullOrEmpty(Path))
{
return LocationType.Remote;
}
return base.LocationType;
}
}
public override IEnumerable<MediaSourceInfo> 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<ChannelItemLookupInfo>();
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);
}
}
}

View File

@ -1359,6 +1359,11 @@ namespace MediaBrowser.Controller.Entities
public virtual string GetClientTypeName()
{
if (IsFolder && SourceType == SourceType.Channel)
{
return "ChannelFolderItem";
}
return GetType().Name;
}

View File

@ -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)

View File

@ -106,8 +106,49 @@ namespace MediaBrowser.Controller.Entities
var info = GetItemLookupInfo<TrailerInfo>();
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;
}
}
}

View File

@ -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<string> AdditionalParts { get; set; }
public List<string> LocalAlternateVersions { get; set; }
public List<LinkedChild> LinkedAlternateVersions { get; set; }
public List<ChannelMediaInfo> 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();
}
/// <summary>
/// Gets the linked children.
/// </summary>
@ -441,6 +485,22 @@ namespace MediaBrowser.Controller.Entities
public virtual IEnumerable<MediaSourceInfo> 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<MediaSourceInfo>
{
GetVersionInfo(enablePathSubstitution, this, MediaSourceType.Placeholder)
};
}
var item = this;
var result = item.GetAlternateVersions()

View File

@ -83,7 +83,6 @@
<Compile Include="Channels\ChannelSearchInfo.cs" />
<Compile Include="Channels\IChannel.cs" />
<Compile Include="Channels\IChannelManager.cs" />
<Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" />
<Compile Include="Channels\IHasCacheKey.cs" />
<Compile Include="Channels\IIndexableChannel.cs" />
@ -268,7 +267,6 @@
<Compile Include="Providers\ArtistInfo.cs" />
<Compile Include="Providers\BookInfo.cs" />
<Compile Include="Providers\BoxSetInfo.cs" />
<Compile Include="Providers\ChannelItemLookupInfo.cs" />
<Compile Include="Providers\DirectoryService.cs" />
<Compile Include="Providers\DynamicImageInfo.cs" />
<Compile Include="Providers\DynamicImageResponse.cs" />

View File

@ -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; }
}
}

View File

@ -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

View File

@ -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<ChannelVideoItem, ChannelItemLookupInfo>
{
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<ChannelVideoItem> source, MetadataResult<ChannelVideoItem> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
}
}
}

View File

@ -92,7 +92,6 @@
<Compile Include="Folders\FolderMetadataService.cs" />
<Compile Include="Folders\UserViewMetadataService.cs" />
<Compile Include="GameGenres\GameGenreMetadataService.cs" />
<Compile Include="Channels\VideoChannelItemMetadataService.cs" />
<Compile Include="Games\GameMetadataService.cs" />
<Compile Include="Games\GameSystemMetadataService.cs" />
<Compile Include="Genres\GenreMetadataService.cs" />

View File

@ -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<ImageType> GetSupportedImages(IHasImages item)

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Providers.Movies
{
public class MovieDbTrailerProvider : IHasOrder, IRemoteMetadataProvider<ChannelVideoItem, ChannelItemLookupInfo>
public class MovieDbTrailerProvider : IHasOrder, IRemoteMetadataProvider<Trailer, TrailerInfo>
{
private readonly IHttpClient _httpClient;
@ -26,24 +26,9 @@ namespace MediaBrowser.Providers.Movies
return MovieDbProvider.Current.GetMovieSearchResults(searchInfo, cancellationToken);
}
public Task<MetadataResult<ChannelVideoItem>> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken)
public Task<MetadataResult<Trailer>> GetMetadata(TrailerInfo info, CancellationToken cancellationToken)
{
if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer)
{
return Task.FromResult(new MetadataResult<ChannelVideoItem>());
}
return MovieDbProvider.Current.GetItemMetadata<ChannelVideoItem>(info, cancellationToken);
}
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ChannelItemLookupInfo info, CancellationToken cancellationToken)
{
if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer)
{
return Task.FromResult<IEnumerable<RemoteSearchResult>>(new List<RemoteSearchResult>());
}
return MovieDbProvider.Current.GetMovieSearchResults(info, cancellationToken);
return MovieDbProvider.Current.GetItemMetadata<Trailer>(info, cancellationToken);
}
public string Name

View File

@ -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;
}
}

View File

@ -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<Trailer, TrailerInfo>
{
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<Trailer> source, MetadataResult<Trailer> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
}
}
}

View File

@ -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

View File

@ -22,7 +22,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Providers.Omdb
{
public class OmdbItemProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<ChannelVideoItem, ChannelItemLookupInfo>, IRemoteMetadataProvider<LiveTvProgram, LiveTvProgramLookupInfo>
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<Trailer, TrailerInfo>, IRemoteMetadataProvider<LiveTvProgram, LiveTvProgramLookupInfo>
{
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
@ -196,23 +196,13 @@ namespace MediaBrowser.Providers.Omdb
return list;
}
public Task<MetadataResult<ChannelVideoItem>> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken)
public Task<MetadataResult<Trailer>> GetMetadata(TrailerInfo info, CancellationToken cancellationToken)
{
if (info.ContentType != ChannelMediaContentType.MovieExtra || info.ExtraType != ExtraType.Trailer)
{
return Task.FromResult(new MetadataResult<ChannelVideoItem>());
}
return GetMovieResult<ChannelVideoItem>(info, cancellationToken);
return GetMovieResult<Trailer>(info, cancellationToken);
}
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken)
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken)
{
if (searchInfo.ContentType != ChannelMediaContentType.MovieExtra || searchInfo.ExtraType != ExtraType.Trailer)
{
return Task.FromResult<IEnumerable<RemoteSearchResult>>(new List<RemoteSearchResult>());
}
return GetSearchResults(searchInfo, "movie", cancellationToken);
}

View File

@ -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<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken)
{
IEnumerable<ChannelMediaInfo> results = new List<ChannelMediaInfo>();
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<ChannelVideoItem>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
if (info.ContentType == ChannelMediaContentType.Episode)
{
item = GetItemById<Episode>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
}
else if (info.ContentType == ChannelMediaContentType.Movie)
{
item = GetItemById<Movie>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
}
else if (info.ContentType == ChannelMediaContentType.Trailer || info.ExtraType == ExtraType.Trailer)
{
item = GetItemById<Trailer>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
}
else
{
item = GetItemById<Video>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
}
}
item.RunTimeTicks = info.RunTimeTicks;
@ -1309,10 +1326,9 @@ namespace MediaBrowser.Server.Implementations.Channels
item.Path = mediaSource == null ? null : mediaSource.Path;
}
var channelVideoItem = item as ChannelVideoItem;
var channelVideoItem = item as Video;
if (channelVideoItem != null)
{
channelVideoItem.ContentType = info.ContentType;
channelVideoItem.ExtraType = info.ExtraType;
channelVideoItem.ChannelMediaSources = info.MediaSources;

View File

@ -28,12 +28,13 @@ namespace MediaBrowser.Server.Implementations.Library
.Cast<IHasTrailers>()
.ToList();
var channelTrailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
var trailerResult = _libraryManager.GetItems(new InternalItemsQuery
{
ExtraTypes = new[] { ExtraType.Trailer }
IncludeItemTypes = new[] { typeof(Trailer).Name },
//IsLocalTrailer = false
}, CancellationToken.None);
var channelTrailers = channelTrailerResult.Items;
});
var trailers = trailerResult.Items;
var numComplete = 0;
@ -41,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
cancellationToken.ThrowIfCancellationRequested();
await AssignTrailers(item, channelTrailers).ConfigureAwait(false);
await AssignTrailers(item, trailers).ConfigureAwait(false);
numComplete++;
double percent = numComplete;

View File

@ -287,7 +287,7 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes,
ExcludeLocationTypes = new[] { LocationType.Virtual },
Limit = limit * 20,
SourceTypes = new[] { SourceType.Library }
ExcludeSourceTypes = parentIds.Length == 0 ? new[] { SourceType.Channel, SourceType.LiveTV } : new SourceType[] { }
}, parentIds);
}

View File

@ -1891,6 +1891,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
var inClause = string.Join(",", query.SourceTypes.Select(i => "'" + i + "'").ToArray());
whereClauses.Add(string.Format("SourceType in ({0})", inClause));
}
if (query.ExcludeSourceTypes.Length == 1)
{
whereClauses.Add("SourceType<>@SourceType");
cmd.Parameters.Add(cmd, "@SourceType", DbType.String).Value = query.SourceTypes[0];
}
else if (query.ExcludeSourceTypes.Length > 1)
{
var inClause = string.Join(",", query.ExcludeSourceTypes.Select(i => "'" + i + "'").ToArray());
whereClauses.Add(string.Format("SourceType not in ({0})", inClause));
}
if (query.IsAiring.HasValue)
{
@ -2067,7 +2078,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
typeof(Trailer),
typeof(BoxSet),
typeof(Episode),
typeof(ChannelVideoItem),
typeof(Season),
typeof(Series),
typeof(Book),