add channels infrastructure

This commit is contained in:
Luke Pulverenti
2014-05-03 00:20:04 -04:00
parent 3228f50895
commit 6936336b82
19 changed files with 437 additions and 60 deletions

View File

@@ -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);
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -18,6 +18,7 @@ namespace MediaBrowser.Controller.Channels
public string Overview { get; set; }
public List<string> Genres { get; set; }
public List<string> Studios { get; set; }
public List<PersonInfo> 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<ChannelMediaInfo> MediaSources { get; set; }
public ChannelItemInfo()
{
MediaSources = new List<ChannelMediaInfo>();
Genres = new List<string>();
Studios = new List<string>();
People = new List<PersonInfo>();
ProviderIds = new Dictionary<string, string>(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<string, string> RequiredHttpHeaders { get; set; }
public ChannelMediaInfo()
{
RequiredHttpHeaders = new Dictionary<string, string>();
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -17,16 +17,10 @@ namespace MediaBrowser.Controller.Channels
string Name { get; }
/// <summary>
/// Gets the home page URL.
/// Gets the channel information.
/// </summary>
/// <value>The home page URL.</value>
string HomePageUrl { get; }
/// <summary>
/// Gets the capabilities.
/// </summary>
/// <returns>ChannelCapabilities.</returns>
ChannelCapabilities GetCapabilities();
/// <returns>ChannelInfo.</returns>
ChannelInfo GetChannelInfo();
/// <summary>
/// Determines whether [is enabled for] [the specified user].
@@ -67,9 +61,29 @@ namespace MediaBrowser.Controller.Channels
IEnumerable<ImageType> GetSupportedChannelImages();
}
public class ChannelCapabilities
public class ChannelInfo
{
/// <summary>
/// Gets the home page URL.
/// </summary>
/// <value>The home page URL.</value>
public string HomePageUrl { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance can search.
/// </summary>
/// <value><c>true</c> if this instance can search; otherwise, <c>false</c>.</value>
public bool CanSearch { get; set; }
public List<ChannelMediaType> MediaTypes { get; set; }
public List<ChannelMediaContentType> ContentTypes { get; set; }
public ChannelInfo()
{
MediaTypes = new List<ChannelMediaType>();
ContentTypes = new List<ChannelMediaContentType>();
}
}
public class ChannelSearchInfo

View File

@@ -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
{