diff options
Diffstat (limited to 'MediaBrowser.Controller/Channels')
13 files changed, 555 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs new file mode 100644 index 000000000..9cd50db17 --- /dev/null +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -0,0 +1,94 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Channels; +using MediaBrowser.Model.Querying; +using System; +using System.Linq; +using MediaBrowser.Model.Serialization; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Progress; + +namespace MediaBrowser.Controller.Channels +{ + public class Channel : Folder + { + public override bool IsVisible(User user) + { + if (user.Policy.BlockedChannels != null) + { + if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } + } + else + { + if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } + } + + return base.IsVisible(user); + } + + [IgnoreDataMember] + public override bool SupportsInheritedParentImages + { + get + { + return false; + } + } + + [IgnoreDataMember] + public override SourceType SourceType + { + get { return SourceType.Channel; } + } + + protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) + { + try + { + query.Parent = this; + query.ChannelIds = new Guid[] { Id }; + + // Don't blow up here because it could cause parent screens with other content to fail + return ChannelManager.GetChannelItemsInternal(query, new SimpleProgress<double>(), CancellationToken.None).Result; + } + catch + { + // Already logged at lower levels + return new QueryResult<BaseItem>(); + } + } + + protected override string GetInternalMetadataPath(string basePath) + { + return GetInternalMetadataPath(basePath, Id); + } + + public static string GetInternalMetadataPath(string basePath, Guid id) + { + return System.IO.Path.Combine(basePath, "channels", id.ToString("N"), "metadata"); + } + + public override bool CanDelete() + { + return false; + } + + protected override bool IsAllowTagFilterEnforced() + { + return false; + } + + internal static bool IsChannelVisible(BaseItem channelItem, User user) + { + var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString("")); + + return channel.IsVisible(user); + } + } +} diff --git a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs new file mode 100644 index 000000000..0de2b9a0c --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs @@ -0,0 +1,82 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Channels; +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; +using MediaBrowser.Model.Dto; + +namespace MediaBrowser.Controller.Channels +{ + public class ChannelItemInfo : IHasProviderIds + { + public string Name { get; set; } + + public string SeriesName { get; set; } + + public string Id { get; set; } + + public DateTime DateModified { get; set; } + + public ChannelItemType Type { get; set; } + + public string OfficialRating { get; set; } + + public string Overview { get; set; } + + public List<string> Genres { get; set; } + public List<string> Studios { get; set; } + public List<string> Tags { get; set; } + + public List<PersonInfo> People { get; set; } + + public float? CommunityRating { get; set; } + + public long? RunTimeTicks { get; set; } + + public string ImageUrl { get; set; } + public string OriginalTitle { get; set; } + + public ChannelMediaType MediaType { get; set; } + public ChannelFolderType FolderType { get; set; } + + public ChannelMediaContentType ContentType { get; set; } + public ExtraType ExtraType { get; set; } + public List<TrailerType> TrailerTypes { get; set; } + + public Dictionary<string, string> ProviderIds { get; set; } + + public DateTime? PremiereDate { get; set; } + public int? ProductionYear { get; set; } + + public DateTime? DateCreated { get; set; } + + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + + public int? IndexNumber { get; set; } + public int? ParentIndexNumber { get; set; } + + public List<MediaSourceInfo> MediaSources { get; set; } + + public string HomePageUrl { get; set; } + + public List<string> Artists { get; set; } + + public List<string> AlbumArtists { get; set; } + public bool IsLiveStream { get; set; } + public string Etag { get; set; } + + public ChannelItemInfo() + { + MediaSources = new List<MediaSourceInfo>(); + TrailerTypes = new List<TrailerType>(); + Genres = new List<string>(); + Studios = new List<string>(); + People = new List<PersonInfo>(); + Tags = new List<string>(); + ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + Artists = new List<string>(); + AlbumArtists = new List<string>(); + } + } +} diff --git a/MediaBrowser.Controller/Channels/ChannelItemResult.cs b/MediaBrowser.Controller/Channels/ChannelItemResult.cs new file mode 100644 index 000000000..f88881811 --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelItemResult.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Channels +{ + public class ChannelItemResult + { + public List<ChannelItemInfo> Items { get; set; } + + public int? TotalRecordCount { get; set; } + + public ChannelItemResult() + { + Items = new List<ChannelItemInfo>(); + } + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/ChannelItemType.cs b/MediaBrowser.Controller/Channels/ChannelItemType.cs new file mode 100644 index 000000000..184ce8a76 --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelItemType.cs @@ -0,0 +1,9 @@ +namespace MediaBrowser.Controller.Channels +{ + public enum ChannelItemType + { + Media = 0, + + Folder = 1 + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/ChannelParentalRating.cs b/MediaBrowser.Controller/Channels/ChannelParentalRating.cs new file mode 100644 index 000000000..d9cc521b3 --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelParentalRating.cs @@ -0,0 +1,15 @@ +namespace MediaBrowser.Controller.Channels +{ + public enum ChannelParentalRating + { + GeneralAudience = 0, + + UsPG = 1, + + UsPG13 = 2, + + UsR = 3, + + Adult = 4 + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/ChannelSearchInfo.cs b/MediaBrowser.Controller/Channels/ChannelSearchInfo.cs new file mode 100644 index 000000000..c2a51654c --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelSearchInfo.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Controller.Channels +{ + public class ChannelSearchInfo + { + public string SearchTerm { get; set; } + + public string UserId { get; set; } + } + + public class ChannelLatestMediaSearch + { + public string UserId { get; set; } + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/IChannel.cs b/MediaBrowser.Controller/Channels/IChannel.cs new file mode 100644 index 000000000..dc1d9b00a --- /dev/null +++ b/MediaBrowser.Controller/Channels/IChannel.cs @@ -0,0 +1,76 @@ +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Channels +{ + public interface IChannel + { + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; } + + /// <summary> + /// Gets the description. + /// </summary> + /// <value>The description.</value> + string Description { get; } + + /// <summary> + /// Gets the data version. + /// </summary> + /// <value>The data version.</value> + string DataVersion { get; } + + /// <summary> + /// Gets the home page URL. + /// </summary> + /// <value>The home page URL.</value> + string HomePageUrl { get; } + + /// <summary> + /// Gets the parental rating. + /// </summary> + /// <value>The parental rating.</value> + ChannelParentalRating ParentalRating { get; } + + /// <summary> + /// Gets the channel information. + /// </summary> + /// <returns>ChannelFeatures.</returns> + InternalChannelFeatures GetChannelFeatures(); + + /// <summary> + /// Determines whether [is enabled for] [the specified user]. + /// </summary> + /// <param name="userId">The user identifier.</param> + /// <returns><c>true</c> if [is enabled for] [the specified user]; otherwise, <c>false</c>.</returns> + bool IsEnabledFor(string userId); + + /// <summary> + /// Gets the channel items. + /// </summary> + /// <param name="query">The query.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItem}}.</returns> + Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel image. + /// </summary> + /// <param name="type">The type.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{DynamicImageInfo}.</returns> + Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken); + + /// <summary> + /// Gets the supported channel images. + /// </summary> + /// <returns>IEnumerable{ImageType}.</returns> + IEnumerable<ImageType> GetSupportedChannelImages(); + } +} diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs new file mode 100644 index 000000000..a9839e1fb --- /dev/null +++ b/MediaBrowser.Controller/Channels/IChannelManager.cs @@ -0,0 +1,89 @@ +using System; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Channels; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Querying; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Channels +{ + public interface IChannelManager + { + /// <summary> + /// Adds the parts. + /// </summary> + /// <param name="channels">The channels.</param> + void AddParts(IEnumerable<IChannel> channels); + + /// <summary> + /// Gets the channel features. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>ChannelFeatures.</returns> + ChannelFeatures GetChannelFeatures(string id); + + /// <summary> + /// Gets all channel features. + /// </summary> + /// <returns>IEnumerable{ChannelFeatures}.</returns> + ChannelFeatures[] GetAllChannelFeatures(); + + bool EnableMediaSourceDisplay(BaseItem item); + bool CanDelete(BaseItem item); + + Task DeleteItem(BaseItem item); + + /// <summary> + /// Gets the channel. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>Channel.</returns> + Channel GetChannel(string id); + + /// <summary> + /// Gets the channels internal. + /// </summary> + /// <param name="query">The query.</param> + /// <param name="cancellationToken">The cancellation token.</param> + QueryResult<Channel> GetChannelsInternal(ChannelQuery query); + + /// <summary> + /// Gets the channels. + /// </summary> + /// <param name="query">The query.</param> + /// <param name="cancellationToken">The cancellation token.</param> + QueryResult<BaseItemDto> GetChannels(ChannelQuery query); + + /// <summary> + /// Gets the latest media. + /// </summary> + Task<QueryResult<BaseItemDto>> GetLatestChannelItems(InternalItemsQuery query, CancellationToken cancellationToken); + + /// <summary> + /// Gets the latest media. + /// </summary> + Task<QueryResult<BaseItem>> GetLatestChannelItemsInternal(InternalItemsQuery query, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel items. + /// </summary> + Task<QueryResult<BaseItemDto>> GetChannelItems(InternalItemsQuery query, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel items internal. + /// </summary> + Task<QueryResult<BaseItem>> GetChannelItemsInternal(InternalItemsQuery query, IProgress<double> progress, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel item media sources. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns> + IEnumerable<MediaSourceInfo> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken); + + bool EnableMediaProbe(BaseItem item); + } +} diff --git a/MediaBrowser.Controller/Channels/IHasCacheKey.cs b/MediaBrowser.Controller/Channels/IHasCacheKey.cs new file mode 100644 index 000000000..6376d2f91 --- /dev/null +++ b/MediaBrowser.Controller/Channels/IHasCacheKey.cs @@ -0,0 +1,13 @@ + +namespace MediaBrowser.Controller.Channels +{ + public interface IHasCacheKey + { + /// <summary> + /// Gets the cache key. + /// </summary> + /// <param name="userId">The user identifier.</param> + /// <returns>System.String.</returns> + string GetCacheKey(string userId); + } +} diff --git a/MediaBrowser.Controller/Channels/IRequiresMediaInfoCallback.cs b/MediaBrowser.Controller/Channels/IRequiresMediaInfoCallback.cs new file mode 100644 index 000000000..a2c63586b --- /dev/null +++ b/MediaBrowser.Controller/Channels/IRequiresMediaInfoCallback.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Model.Dto; + +namespace MediaBrowser.Controller.Channels +{ + public interface IRequiresMediaInfoCallback + { + /// <summary> + /// Gets the channel item media information. + /// </summary> + Task<IEnumerable<MediaSourceInfo>> GetChannelItemMediaInfo(string id, CancellationToken cancellationToken); + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/ISearchableChannel.cs b/MediaBrowser.Controller/Channels/ISearchableChannel.cs new file mode 100644 index 000000000..bf9842eb4 --- /dev/null +++ b/MediaBrowser.Controller/Channels/ISearchableChannel.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; + +namespace MediaBrowser.Controller.Channels +{ + public interface ISearchableChannel + { + /// <summary> + /// Searches the specified search term. + /// </summary> + /// <param name="searchInfo">The search information.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItemInfo}}.</returns> + Task<IEnumerable<ChannelItemInfo>> Search(ChannelSearchInfo searchInfo, CancellationToken cancellationToken); + } + + public interface ISupportsLatestMedia + { + /// <summary> + /// Gets the latest media. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItemInfo}}.</returns> + Task<IEnumerable<ChannelItemInfo>> GetLatestMedia(ChannelLatestMediaSearch request, CancellationToken cancellationToken); + } + + public interface ISupportsDelete + { + bool CanDelete(BaseItem item); + Task DeleteItem(string id, CancellationToken cancellationToken); + } + + public interface IDisableMediaSourceDisplay + { + + } + + public interface ISupportsMediaProbe + { + + } + + public interface IHasFolderAttributes + { + string[] Attributes { get; } + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs new file mode 100644 index 000000000..976808aad --- /dev/null +++ b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs @@ -0,0 +1,61 @@ +using System; +using MediaBrowser.Model.Channels; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Channels +{ + public class InternalChannelFeatures + { + /// <summary> + /// Gets or sets the media types. + /// </summary> + /// <value>The media types.</value> + public List<ChannelMediaType> MediaTypes { get; set; } + + /// <summary> + /// Gets or sets the content types. + /// </summary> + /// <value>The content types.</value> + public List<ChannelMediaContentType> ContentTypes { get; set; } + + /// <summary> + /// Represents the maximum number of records the channel allows retrieving at a time + /// </summary> + public int? MaxPageSize { get; set; } + + /// <summary> + /// Gets or sets the default sort orders. + /// </summary> + /// <value>The default sort orders.</value> + public List<ChannelItemSortField> DefaultSortFields { get; set; } + + /// <summary> + /// Indicates if a sort ascending/descending toggle is supported or not. + /// </summary> + public bool SupportsSortOrderToggle { get; set; } + /// <summary> + /// Gets or sets the automatic refresh levels. + /// </summary> + /// <value>The automatic refresh levels.</value> + public int? AutoRefreshLevels { get; set; } + + /// <summary> + /// Gets or sets the daily download limit. + /// </summary> + /// <value>The daily download limit.</value> + public int? DailyDownloadLimit { get; set; } + /// <summary> + /// Gets or sets a value indicating whether [supports downloading]. + /// </summary> + /// <value><c>true</c> if [supports downloading]; otherwise, <c>false</c>.</value> + public bool SupportsContentDownloading { get; set; } + + public InternalChannelFeatures() + { + MediaTypes = new List<ChannelMediaType>(); + ContentTypes = new List<ChannelMediaContentType>(); + + DefaultSortFields = new List<ChannelItemSortField>(); + } + } +} diff --git a/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs b/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs new file mode 100644 index 000000000..c69a1f6c3 --- /dev/null +++ b/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs @@ -0,0 +1,21 @@ +using MediaBrowser.Model.Channels; +using System; + + +namespace MediaBrowser.Controller.Channels +{ + public class InternalChannelItemQuery + { + public string FolderId { get; set; } + + public Guid UserId { get; set; } + + public int? StartIndex { get; set; } + + public int? Limit { get; set; } + + public ChannelItemSortField? SortBy { get; set; } + + public bool SortDescending { get; set; } + } +} |
