remove IChannelMediaItem interface

This commit is contained in:
Luke Pulverenti 2016-03-19 00:22:33 -04:00
parent 9e495d3886
commit cbac67b5ae
10 changed files with 44 additions and 52 deletions

View File

@ -12,7 +12,7 @@ using System.Threading;
namespace MediaBrowser.Controller.Channels
{
public class ChannelAudioItem : Audio, IChannelMediaItem
public class ChannelAudioItem : Audio
{
public ChannelMediaContentType ContentType { get; set; }

View File

@ -13,7 +13,7 @@ using System.Threading;
namespace MediaBrowser.Controller.Channels
{
public class ChannelVideoItem : Video, IChannelMediaItem, IHasLookupInfo<ChannelItemLookupInfo>
public class ChannelVideoItem : Video, IHasLookupInfo<ChannelItemLookupInfo>
{
public ChannelMediaContentType ContentType { get; set; }

View File

@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Channels
/// <param name="includeCachedVersions">if set to <c>true</c> [include cached versions].</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(IChannelMediaItem item, bool includeCachedVersions, CancellationToken cancellationToken);
Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken);
/// <summary>
/// Gets the channel folder.
@ -141,6 +141,6 @@ namespace MediaBrowser.Controller.Channels
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task DownloadChannelItem(IChannelMediaItem item, string destinationPath, IProgress<double> progress, CancellationToken cancellationToken);
Task DownloadChannelItem(BaseItem item, string destinationPath, IProgress<double> progress, CancellationToken cancellationToken);
}
}

View File

@ -1,23 +0,0 @@
using System;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
namespace MediaBrowser.Controller.Channels
{
public interface IChannelMediaItem
{
string ChannelId { get; set; }
Guid Id { get; set; }
string ExternalId { get; set; }
long? RunTimeTicks { get; set; }
string MediaType { get; }
ChannelMediaContentType ContentType { get; set; }
ExtraType? ExtraType { get; set; }
List<ChannelMediaInfo> ChannelMediaSources { get; set; }
}
}

View File

@ -87,7 +87,6 @@
<Compile Include="Channels\ChannelAudioItem.cs" />
<Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" />
<Compile Include="Channels\IChannelMediaItem.cs" />
<Compile Include="Channels\IHasCacheKey.cs" />
<Compile Include="Channels\IIndexableChannel.cs" />
<Compile Include="Channels\InternalAllChannelMediaQuery.cs" />

View File

@ -42,7 +42,7 @@ namespace MediaBrowser.Providers.Movies
public bool Supports(IHasImages item)
{
var channelItem = item as IChannelMediaItem;
var channelItem = item as ChannelVideoItem;
if (channelItem != null)
{

View File

@ -81,7 +81,7 @@ namespace MediaBrowser.Providers.Omdb
return false;
}
var channelItem = item as IChannelMediaItem;
var channelItem = item as ChannelVideoItem;
if (channelItem != null)
{

View File

@ -20,11 +20,11 @@ namespace MediaBrowser.Server.Implementations.Channels
public Task<IEnumerable<MediaSourceInfo>> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
{
var channelItem = item as IChannelMediaItem;
var baseItem = (BaseItem) item;
if (channelItem != null)
if (baseItem.SourceType == SourceType.Channel)
{
return _channelManager.GetDynamicMediaSources(channelItem, cancellationToken);
return _channelManager.GetDynamicMediaSources(baseItem, cancellationToken);
}
return Task.FromResult<IEnumerable<MediaSourceInfo>>(new List<MediaSourceInfo>());

View File

@ -248,9 +248,19 @@ namespace MediaBrowser.Server.Implementations.Channels
return item;
}
public async Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(IChannelMediaItem item, bool includeCachedVersions, CancellationToken cancellationToken)
public async Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken)
{
IEnumerable<ChannelMediaInfo> results = item.ChannelMediaSources;
IEnumerable<ChannelMediaInfo> results = new List<ChannelMediaInfo>();
var video = item as ChannelVideoItem;
if (video != null)
{
results = video.ChannelMediaSources;
}
var audio = item as ChannelAudioItem;
if (audio != null)
{
results = audio.ChannelMediaSources;
}
var sources = SortMediaInfoResults(results)
.Select(i => GetMediaSource(item, i))
@ -265,7 +275,7 @@ namespace MediaBrowser.Server.Implementations.Channels
return sources;
}
public async Task<IEnumerable<MediaSourceInfo>> GetDynamicMediaSources(IChannelMediaItem item, CancellationToken cancellationToken)
public async Task<IEnumerable<MediaSourceInfo>> GetDynamicMediaSources(BaseItem item, CancellationToken cancellationToken)
{
var channel = GetChannel(item.ChannelId);
var channelPlugin = GetChannelProvider(channel);
@ -319,7 +329,7 @@ namespace MediaBrowser.Server.Implementations.Channels
return list;
}
private IEnumerable<MediaSourceInfo> GetCachedChannelItemMediaSources(IChannelMediaItem item)
private IEnumerable<MediaSourceInfo> GetCachedChannelItemMediaSources(BaseItem item)
{
var filenamePrefix = item.Id.ToString("N");
var parentPath = Path.Combine(ChannelDownloadPath, item.ChannelId);
@ -368,7 +378,7 @@ namespace MediaBrowser.Server.Implementations.Channels
return new List<MediaSourceInfo>();
}
private MediaSourceInfo GetMediaSource(IChannelMediaItem item, ChannelMediaInfo info)
private MediaSourceInfo GetMediaSource(BaseItem item, ChannelMediaInfo info)
{
var source = info.ToMediaSource();
@ -1277,16 +1287,25 @@ namespace MediaBrowser.Server.Implementations.Channels
}
item.ExternalId = info.Id;
var channelMediaItem = item as IChannelMediaItem;
if (channelMediaItem != null)
var channelAudioItem = item as ChannelAudioItem;
if (channelAudioItem != null)
{
channelMediaItem.ContentType = info.ContentType;
channelMediaItem.ExtraType = info.ExtraType;
channelMediaItem.ChannelMediaSources = info.MediaSources;
channelAudioItem.ContentType = info.ContentType;
channelAudioItem.ExtraType = info.ExtraType;
channelAudioItem.ChannelMediaSources = info.MediaSources;
var mediaSource = info.MediaSources.FirstOrDefault();
item.Path = mediaSource == null ? null : mediaSource.Path;
}
var channelVideoItem = item as ChannelVideoItem;
if (channelVideoItem != null)
{
channelVideoItem.ContentType = info.ContentType;
channelVideoItem.ExtraType = info.ExtraType;
channelVideoItem.ChannelMediaSources = info.MediaSources;
var mediaSource = info.MediaSources.FirstOrDefault();
item.Path = mediaSource == null ? null : mediaSource.Path;
}
@ -1439,7 +1458,7 @@ namespace MediaBrowser.Server.Implementations.Channels
return await _libraryManager.GetNamedView(name, "channels", "zz_" + name, cancellationToken).ConfigureAwait(false);
}
public async Task DownloadChannelItem(IChannelMediaItem item, string destination,
public async Task DownloadChannelItem(BaseItem item, string destination,
IProgress<double> progress, CancellationToken cancellationToken)
{
var sources = await GetDynamicMediaSources(item, cancellationToken)
@ -1455,7 +1474,7 @@ namespace MediaBrowser.Server.Implementations.Channels
}
private async Task TryDownloadChannelItem(MediaSourceInfo source,
IChannelMediaItem item,
BaseItem item,
string destination,
IProgress<double> progress,
CancellationToken cancellationToken)

View File

@ -1250,6 +1250,7 @@ namespace MediaBrowser.Server.Implementations.Dto
if (audio != null)
{
dto.Album = audio.Album;
dto.ExtraType = audio.ExtraType;
var albumParent = audio.AlbumEntity;
@ -1352,6 +1353,8 @@ namespace MediaBrowser.Server.Implementations.Dto
{
dto.Chapters = GetChapterInfoDtos(item);
}
dto.ExtraType = video.ExtraType;
}
if (fields.Contains(ItemFields.MediaStreams))
@ -1535,12 +1538,6 @@ namespace MediaBrowser.Server.Implementations.Dto
{
dto.ChannelName = _channelManagerFactory().GetChannel(item.ChannelId).Name;
}
var channelMediaItem = item as IChannelMediaItem;
if (channelMediaItem != null)
{
dto.ExtraType = channelMediaItem.ExtraType;
}
}
private void AttachLinkedChildImages(BaseItemDto dto, Folder folder, User user, DtoOptions options)