2014-03-17 18:45:41 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-09-01 13:10:54 -07:00
|
|
|
|
using MediaBrowser.Model.Channels;
|
|
|
|
|
using MediaBrowser.Model.Querying;
|
2014-05-02 21:20:04 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2016-10-25 12:02:04 -07:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2014-09-01 13:10:54 -07:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-06-23 09:04:45 -07:00
|
|
|
|
using MediaBrowser.Common.Progress;
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Channels
|
|
|
|
|
{
|
2014-06-30 12:24:35 -07:00
|
|
|
|
public class Channel : Folder
|
2014-03-17 18:45:41 -07:00
|
|
|
|
{
|
2014-05-02 21:20:04 -07:00
|
|
|
|
public override bool IsVisible(User user)
|
|
|
|
|
{
|
2015-04-14 20:41:29 -07:00
|
|
|
|
if (user.Policy.BlockedChannels != null)
|
2014-05-02 21:20:04 -07:00
|
|
|
|
{
|
2015-04-14 20:41:29 -07:00
|
|
|
|
if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-02 21:20:04 -07:00
|
|
|
|
}
|
2015-04-14 20:41:29 -07:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 21:20:04 -07:00
|
|
|
|
return base.IsVisible(user);
|
|
|
|
|
}
|
2014-09-01 13:10:54 -07:00
|
|
|
|
|
2017-09-22 13:33:01 -07:00
|
|
|
|
public override double? GetDefaultPrimaryImageAspectRatio()
|
|
|
|
|
{
|
|
|
|
|
double value = 16;
|
|
|
|
|
value /= 9;
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-29 12:10:58 -07:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool SupportsInheritedParentImages
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 22:04:38 -07:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override SourceType SourceType
|
|
|
|
|
{
|
|
|
|
|
get { return SourceType.Channel; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-25 23:48:54 -07:00
|
|
|
|
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
|
2014-09-01 13:10:54 -07:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Don't blow up here because it could cause parent screens with other content to fail
|
2017-05-25 23:48:54 -07:00
|
|
|
|
return ChannelManager.GetChannelItemsInternal(new ChannelItemQuery
|
2014-09-01 13:10:54 -07:00
|
|
|
|
{
|
|
|
|
|
ChannelId = Id.ToString("N"),
|
|
|
|
|
Limit = query.Limit,
|
|
|
|
|
StartIndex = query.StartIndex,
|
|
|
|
|
UserId = query.User.Id.ToString("N"),
|
2017-09-04 12:28:22 -07:00
|
|
|
|
OrderBy = query.OrderBy
|
2014-09-01 13:10:54 -07:00
|
|
|
|
|
2017-06-23 09:04:45 -07:00
|
|
|
|
}, new SimpleProgress<double>(), CancellationToken.None).Result;
|
2014-09-01 13:10:54 -07:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// Already logged at lower levels
|
2016-07-29 12:18:03 -07:00
|
|
|
|
return new QueryResult<BaseItem>();
|
2014-09-01 13:10:54 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-28 08:27:26 -07:00
|
|
|
|
|
|
|
|
|
protected override string GetInternalMetadataPath(string basePath)
|
|
|
|
|
{
|
2015-01-23 21:50:45 -07:00
|
|
|
|
return GetInternalMetadataPath(basePath, Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetInternalMetadataPath(string basePath, Guid id)
|
|
|
|
|
{
|
|
|
|
|
return System.IO.Path.Combine(basePath, "channels", id.ToString("N"), "metadata");
|
2014-09-28 08:27:26 -07:00
|
|
|
|
}
|
2015-02-05 22:39:07 -07:00
|
|
|
|
|
|
|
|
|
public override bool CanDelete()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-02-08 23:17:11 -07:00
|
|
|
|
|
2015-02-08 23:56:45 -07:00
|
|
|
|
protected override bool IsAllowTagFilterEnforced()
|
2015-02-08 23:17:11 -07:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-03-18 22:14:47 -07:00
|
|
|
|
|
|
|
|
|
internal static bool IsChannelVisible(BaseItem channelItem, User user)
|
|
|
|
|
{
|
|
|
|
|
var channel = ChannelManager.GetChannel(channelItem.ChannelId);
|
|
|
|
|
|
|
|
|
|
return channel.IsVisible(user);
|
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
|
|
|
|
}
|