update channels

This commit is contained in:
Luke Pulverenti
2016-03-19 11:38:05 -04:00
parent 5dd77ab145
commit 1d2b6329bf
23 changed files with 216 additions and 338 deletions

View File

@@ -1,142 +0,0 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
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.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
namespace MediaBrowser.Controller.Channels
{
public class ChannelVideoItem : Video, IHasLookupInfo<ChannelItemLookupInfo>
{
public ChannelMediaContentType ContentType { get; set; }
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
protected override string CreateUserDataKey()
{
if (ContentType == ChannelMediaContentType.MovieExtra)
{
var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrWhiteSpace(key))
{
key = key + "-" + ExtraType.ToString().ToLower();
// Make sure different trailers have their own data.
if (RunTimeTicks.HasValue)
{
key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
}
return key;
}
}
return ExternalId;
}
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.ChannelContent;
}
[IgnoreDataMember]
public override SourceType SourceType
{
get { return SourceType.Channel; }
set { }
}
[IgnoreDataMember]
public override bool SupportsLocalMetadata
{
get
{
return false;
}
}
public override bool IsSaveLocalMetadataEnabled()
{
return false;
}
public ChannelVideoItem()
{
ChannelMediaSources = new List<ChannelMediaInfo>();
}
[IgnoreDataMember]
public override LocationType LocationType
{
get
{
if (string.IsNullOrEmpty(Path))
{
return LocationType.Remote;
}
return base.LocationType;
}
}
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 ChannelItemLookupInfo GetLookupInfo()
{
var info = GetItemLookupInfo<ChannelItemLookupInfo>();
info.ContentType = ContentType;
if (ExtraType.HasValue)
{
info.ExtraType = ExtraType.Value;
}
return info;
}
protected override string GetInternalMetadataPath(string basePath)
{
return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));
}
public override bool CanDelete()
{
return false;
}
public override bool IsVisibleStandalone(User user)
{
return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
}
}
}

View File

@@ -1359,6 +1359,11 @@ namespace MediaBrowser.Controller.Entities
public virtual string GetClientTypeName()
{
if (IsFolder && SourceType == SourceType.Channel)
{
return "ChannelFolderItem";
}
return GetType().Name;
}

View File

@@ -116,6 +116,7 @@ namespace MediaBrowser.Controller.Entities
public LocationType[] ExcludeLocationTypes { get; set; }
public string[] PresetViews { get; set; }
public SourceType[] SourceTypes { get; set; }
public SourceType[] ExcludeSourceTypes { get; set; }
public InternalItemsQuery()
{
@@ -143,6 +144,7 @@ namespace MediaBrowser.Controller.Entities
ExcludeLocationTypes = new LocationType[] { };
PresetViews = new string[] { };
SourceTypes = new SourceType[] { };
ExcludeSourceTypes = new SourceType[] { };
}
public InternalItemsQuery(User user)

View File

@@ -106,8 +106,49 @@ namespace MediaBrowser.Controller.Entities
var info = GetItemLookupInfo<TrailerInfo>();
info.IsLocalTrailer = IsLocalTrailer;
if (!IsInMixedFolder)
{
info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
}
return info;
}
public override bool BeforeMetadataRefresh()
{
var hasChanges = base.BeforeMetadataRefresh();
if (!ProductionYear.HasValue)
{
var info = LibraryManager.ParseName(Name);
var yearInName = info.Year;
if (yearInName.HasValue)
{
ProductionYear = yearInName;
hasChanges = true;
}
else
{
// Try to get the year from the folder name
if (!IsInMixedFolder)
{
info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
yearInName = info.Year;
if (yearInName.HasValue)
{
ProductionYear = yearInName;
hasChanges = true;
}
}
}
}
return hasChanges;
}
}
}

View File

@@ -6,13 +6,16 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
namespace MediaBrowser.Controller.Entities
{
@@ -33,6 +36,7 @@ namespace MediaBrowser.Controller.Entities
public List<string> AdditionalParts { get; set; }
public List<string> LocalAlternateVersions { get; set; }
public List<LinkedChild> LinkedAlternateVersions { get; set; }
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
[IgnoreDataMember]
public bool IsThemeMedia
@@ -78,6 +82,23 @@ namespace MediaBrowser.Controller.Entities
locationType != LocationType.Virtual;
}
[IgnoreDataMember]
public override LocationType LocationType
{
get
{
if (SourceType == SourceType.Channel)
{
if (string.IsNullOrEmpty(Path))
{
return LocationType.Remote;
}
}
return base.LocationType;
}
}
[IgnoreDataMember]
public override bool SupportsAddingToPlaylist
{
@@ -130,6 +151,29 @@ namespace MediaBrowser.Controller.Entities
return LocalAlternateVersions.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
}
protected override string CreateUserDataKey()
{
if (ExtraType.HasValue)
{
var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrWhiteSpace(key))
{
key = key + "-" + ExtraType.ToString().ToLower();
// Make sure different trailers have their own data.
if (RunTimeTicks.HasValue)
{
key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
}
return key;
}
}
return base.CreateUserDataKey();
}
/// <summary>
/// Gets the linked children.
/// </summary>
@@ -441,6 +485,22 @@ namespace MediaBrowser.Controller.Entities
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;
}
return new List<MediaSourceInfo>
{
GetVersionInfo(enablePathSubstitution, this, MediaSourceType.Placeholder)
};
}
var item = this;
var result = item.GetAlternateVersions()

View File

@@ -83,7 +83,6 @@
<Compile Include="Channels\ChannelSearchInfo.cs" />
<Compile Include="Channels\IChannel.cs" />
<Compile Include="Channels\IChannelManager.cs" />
<Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" />
<Compile Include="Channels\IHasCacheKey.cs" />
<Compile Include="Channels\IIndexableChannel.cs" />
@@ -268,7 +267,6 @@
<Compile Include="Providers\ArtistInfo.cs" />
<Compile Include="Providers\BookInfo.cs" />
<Compile Include="Providers\BoxSetInfo.cs" />
<Compile Include="Providers\ChannelItemLookupInfo.cs" />
<Compile Include="Providers\DirectoryService.cs" />
<Compile Include="Providers\DynamicImageInfo.cs" />
<Compile Include="Providers\DynamicImageResponse.cs" />

View File

@@ -1,11 +0,0 @@
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Providers
{
public class ChannelItemLookupInfo : ItemLookupInfo
{
public ChannelMediaContentType ContentType { get; set; }
public ExtraType ExtraType { get; set; }
}
}