remove ChannelAudioItem

This commit is contained in:
Luke Pulverenti 2016-03-19 01:14:47 -04:00
parent 7b93b7a33c
commit f0c947851d
9 changed files with 48 additions and 150 deletions

View File

@ -83,5 +83,12 @@ namespace MediaBrowser.Controller.Channels
{
return false;
}
internal static bool IsChannelVisible(BaseItem channelItem, User user)
{
var channel = ChannelManager.GetChannel(channelItem.ChannelId);
return channel.IsVisible(user);
}
}
}

View File

@ -1,108 +0,0 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
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.Linq;
using System.Runtime.Serialization;
using System.Threading;
namespace MediaBrowser.Controller.Channels
{
public class ChannelAudioItem : Audio
{
public ChannelMediaContentType ContentType { get; set; }
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.ChannelContent;
}
protected override string CreateUserDataKey()
{
return ExternalId;
}
[IgnoreDataMember]
public override bool SupportsLocalMetadata
{
get
{
return false;
}
}
[IgnoreDataMember]
public override SourceType SourceType {
get { return SourceType.Channel; }
set { }
}
public override bool IsSaveLocalMetadataEnabled()
{
return false;
}
public ChannelAudioItem()
{
ChannelMediaSources = new List<ChannelMediaInfo>();
}
[IgnoreDataMember]
public override LocationType LocationType
{
get
{
if (string.IsNullOrEmpty(Path))
{
return LocationType.Remote;
}
return base.LocationType;
}
}
protected override string GetInternalMetadataPath(string basePath)
{
return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));
}
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 override bool CanDelete()
{
return false;
}
public override bool IsVisibleStandalone(User user)
{
return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user);
}
}
}

View File

@ -136,14 +136,7 @@ namespace MediaBrowser.Controller.Channels
public override bool IsVisibleStandalone(User user)
{
return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user);
}
internal static bool IsChannelVisible(BaseItem channelItem, User user)
{
var channel = ChannelManager.GetChannel(channelItem.ChannelId);
return channel.IsVisible(user);
return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
}
}
}

View File

@ -8,6 +8,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using MediaBrowser.Controller.Channels;
namespace MediaBrowser.Controller.Entities.Audio
{
@ -24,6 +26,8 @@ namespace MediaBrowser.Controller.Entities.Audio
IThemeMedia,
IArchivable
{
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
public long? Size { get; set; }
public string Container { get; set; }
public int? TotalBitrate { get; set; }
@ -198,7 +202,11 @@ namespace MediaBrowser.Controller.Entities.Audio
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.Music;
if (SourceType == SourceType.Library)
{
return UnratedItem.Music;
}
return base.GetBlockUnratedType();
}
public SongInfo GetLookupInfo()
@ -214,6 +222,32 @@ namespace MediaBrowser.Controller.Entities.Audio
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;
}
var list = new List<MediaSourceInfo>
{
GetVersionInfo(this, enablePathSubstitution)
};
foreach (var mediaSource in list)
{
if (string.IsNullOrWhiteSpace(mediaSource.Path))
{
mediaSource.Type = MediaSourceType.Placeholder;
}
}
return list;
}
var result = new List<MediaSourceInfo>
{
GetVersionInfo(this, enablePathSubstitution)

View File

@ -1305,7 +1305,7 @@ namespace MediaBrowser.Controller.Entities
{
if (SourceType == SourceType.Channel)
{
return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user);
return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
}
return IsVisibleStandaloneInternal(user, true);

View File

@ -83,7 +83,6 @@
<Compile Include="Channels\ChannelSearchInfo.cs" />
<Compile Include="Channels\IChannel.cs" />
<Compile Include="Channels\IChannelManager.cs" />
<Compile Include="Channels\ChannelAudioItem.cs" />
<Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" />
<Compile Include="Channels\IHasCacheKey.cs" />

View File

@ -1,25 +0,0 @@
using System.Collections.Generic;
using CommonIO;
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;
namespace MediaBrowser.Providers.Channels
{
public class AudioChannelItemMetadataService : MetadataService<ChannelAudioItem, ItemLookupInfo>
{
public AudioChannelItemMetadataService(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<ChannelAudioItem> source, MetadataResult<ChannelAudioItem> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
}
}
}

View File

@ -90,7 +90,6 @@
<Compile Include="Chapters\ChapterManager.cs" />
<Compile Include="Folders\DefaultImageProvider.cs" />
<Compile Include="Folders\FolderMetadataService.cs" />
<Compile Include="Channels\AudioChannelItemMetadataService.cs" />
<Compile Include="Folders\UserViewMetadataService.cs" />
<Compile Include="GameGenres\GameGenreMetadataService.cs" />
<Compile Include="Channels\VideoChannelItemMetadataService.cs" />

View File

@ -257,10 +257,10 @@ namespace MediaBrowser.Server.Implementations.Channels
{
results = video.ChannelMediaSources;
}
var audio = item as ChannelAudioItem;
var audio = item as Audio;
if (audio != null)
{
results = audio.ChannelMediaSources;
results = audio.ChannelMediaSources ?? new List<ChannelMediaInfo>();
}
var sources = SortMediaInfoResults(results)
@ -1259,7 +1259,7 @@ namespace MediaBrowser.Server.Implementations.Channels
}
else if (info.MediaType == ChannelMediaType.Audio)
{
item = GetItemById<ChannelAudioItem>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
item = GetItemById<Audio>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
}
else
{
@ -1299,10 +1299,9 @@ namespace MediaBrowser.Server.Implementations.Channels
}
item.ExternalId = info.Id;
var channelAudioItem = item as ChannelAudioItem;
var channelAudioItem = item as Audio;
if (channelAudioItem != null)
{
channelAudioItem.ContentType = info.ContentType;
channelAudioItem.ExtraType = info.ExtraType;
channelAudioItem.ChannelMediaSources = info.MediaSources;