You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.8 KiB
88 lines
2.8 KiB
using System;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading;
|
|
using Jellyfin.Data.Enums;
|
|
using MediaBrowser.Common.Progress;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
namespace MediaBrowser.Controller.Channels
|
|
{
|
|
public class Channel : Folder
|
|
{
|
|
public override bool IsVisible(Jellyfin.Data.Entities.User user)
|
|
{
|
|
if (user.GetPreference(PreferenceKind.BlockedChannels) != null)
|
|
{
|
|
if (user.GetPreference(PreferenceKind.BlockedChannels).Contains(Id.ToString("N", CultureInfo.InvariantCulture), StringComparer.OrdinalIgnoreCase))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!user.HasPermission(PermissionKind.EnableAllChannels)
|
|
&& !user.GetPreference(PreferenceKind.EnabledChannels)
|
|
.Contains(Id.ToString("N", CultureInfo.InvariantCulture), StringComparer.OrdinalIgnoreCase))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return base.IsVisible(user);
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public override bool SupportsInheritedParentImages => false;
|
|
|
|
[JsonIgnore]
|
|
public override SourceType SourceType => 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", CultureInfo.InvariantCulture), "metadata");
|
|
}
|
|
|
|
public override bool CanDelete()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
protected override bool IsAllowTagFilterEnforced()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
internal static bool IsChannelVisible(BaseItem channelItem, Jellyfin.Data.Entities.User user)
|
|
{
|
|
var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString(""));
|
|
|
|
return channel.IsVisible(user);
|
|
}
|
|
}
|
|
}
|