From 6936336b82467d3d8ea53af89bd5abcf7cdea678 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 3 May 2014 00:20:04 -0400 Subject: add channels infrastructure --- MediaBrowser.Controller/Channels/Channel.cs | 12 +++++++ .../Channels/ChannelAudioItem.cs | 17 ++++++++- .../Channels/ChannelCategoryItem.cs | 15 ++++++++ .../Channels/ChannelItemInfo.cs | 23 ++++++++++++- .../Channels/ChannelVideoItem.cs | 40 ++++++++++++++++++++++ MediaBrowser.Controller/Channels/IChannel.cs | 34 ++++++++++++------ MediaBrowser.Controller/Library/ILibraryManager.cs | 1 + 7 files changed, 130 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index c9a70f2bc..b894893c6 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -1,9 +1,21 @@ using MediaBrowser.Controller.Entities; +using System; +using System.Linq; namespace MediaBrowser.Controller.Channels { public class Channel : BaseItem { public string OriginalChannelName { get; set; } + + public override bool IsVisible(User user) + { + if (user.Configuration.BlockedChannels.Contains(Name, StringComparer.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsVisible(user); + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index 6f3398f52..a0999593f 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Controller.Entities.Audio; +using System.Linq; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Channels { @@ -13,5 +15,18 @@ namespace MediaBrowser.Controller.Channels public ChannelMediaContentType ContentType { get; set; } public string OriginalImageUrl { get; set; } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent); + } + + public override bool SupportsLocalMetadata + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs b/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs index 61b38c2b1..67f0ec65f 100644 --- a/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Channels { @@ -9,5 +10,19 @@ namespace MediaBrowser.Controller.Channels public ChannelItemType ChannelItemType { get; set; } public string OriginalImageUrl { get; set; } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + // Don't block. + return false; + } + + public override bool SupportsLocalMetadata + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs index 421d3e6f2..104204eb0 100644 --- a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs @@ -18,6 +18,7 @@ namespace MediaBrowser.Controller.Channels public string Overview { get; set; } public List Genres { get; set; } + public List Studios { get; set; } public List People { get; set; } @@ -38,9 +39,15 @@ namespace MediaBrowser.Controller.Channels public DateTime? PremiereDate { get; set; } public int? ProductionYear { get; set; } + public DateTime? DateCreated { get; set; } + + public List MediaSources { get; set; } + public ChannelItemInfo() { + MediaSources = new List(); Genres = new List(); + Studios = new List(); People = new List(); ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); } @@ -70,6 +77,20 @@ namespace MediaBrowser.Controller.Channels Movie = 3, - Episode = 4 + Episode = 4, + + Song = 5 + } + + public class ChannelMediaInfo + { + public string Path { get; set; } + + public Dictionary RequiredHttpHeaders { get; set; } + + public ChannelMediaInfo() + { + RequiredHttpHeaders = new Dictionary(); + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index 83b85794d..0bf05f965 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -1,4 +1,8 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Entities; +using System.Globalization; +using System.Linq; namespace MediaBrowser.Controller.Channels { @@ -13,5 +17,41 @@ namespace MediaBrowser.Controller.Channels public ChannelMediaContentType ContentType { get; set; } public string OriginalImageUrl { get; set; } + + public override string GetUserDataKey() + { + if (ContentType == ChannelMediaContentType.Trailer) + { + var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom); + + if (!string.IsNullOrWhiteSpace(key)) + { + key = key + "-trailer"; + + // Make sure different trailers have their own data. + if (RunTimeTicks.HasValue) + { + key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture); + } + + return key; + } + } + + return base.GetUserDataKey(); + } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent); + } + + public override bool SupportsLocalMetadata + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Channels/IChannel.cs b/MediaBrowser.Controller/Channels/IChannel.cs index 773147a14..0c4be8630 100644 --- a/MediaBrowser.Controller/Channels/IChannel.cs +++ b/MediaBrowser.Controller/Channels/IChannel.cs @@ -17,16 +17,10 @@ namespace MediaBrowser.Controller.Channels string Name { get; } /// - /// Gets the home page URL. - /// - /// The home page URL. - string HomePageUrl { get; } - - /// - /// Gets the capabilities. + /// Gets the channel information. /// - /// ChannelCapabilities. - ChannelCapabilities GetCapabilities(); + /// ChannelInfo. + ChannelInfo GetChannelInfo(); /// /// Determines whether [is enabled for] [the specified user]. @@ -67,9 +61,29 @@ namespace MediaBrowser.Controller.Channels IEnumerable GetSupportedChannelImages(); } - public class ChannelCapabilities + public class ChannelInfo { + /// + /// Gets the home page URL. + /// + /// The home page URL. + public string HomePageUrl { get; set; } + + /// + /// Gets or sets a value indicating whether this instance can search. + /// + /// true if this instance can search; otherwise, false. public bool CanSearch { get; set; } + + public List MediaTypes { get; set; } + + public List ContentTypes { get; set; } + + public ChannelInfo() + { + MediaTypes = new List(); + ContentTypes = new List(); + } } public class ChannelSearchInfo diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 9e18dc9b0..7529f1e0d 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Library { -- cgit v1.2.3