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

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