| | 1 | | #nullable disable |
| | 2 | |
|
| | 3 | | #pragma warning disable CS1591 |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | | using System.Globalization; |
| | 7 | | using System.Linq; |
| | 8 | | using System.Text.Json.Serialization; |
| | 9 | | using System.Threading; |
| | 10 | | using Jellyfin.Data.Entities; |
| | 11 | | using Jellyfin.Data.Enums; |
| | 12 | | using MediaBrowser.Controller.Entities; |
| | 13 | | using MediaBrowser.Model.Querying; |
| | 14 | |
|
| | 15 | | namespace MediaBrowser.Controller.Channels |
| | 16 | | { |
| | 17 | | public class Channel : Folder |
| | 18 | | { |
| | 19 | | [JsonIgnore] |
| 0 | 20 | | public override bool SupportsInheritedParentImages => false; |
| | 21 | |
|
| | 22 | | [JsonIgnore] |
| 1 | 23 | | public override SourceType SourceType => SourceType.Channel; |
| | 24 | |
|
| | 25 | | public override bool IsVisible(User user) |
| | 26 | | { |
| 0 | 27 | | var blockedChannelsPreference = user.GetPreferenceValues<Guid>(PreferenceKind.BlockedChannels); |
| 0 | 28 | | if (blockedChannelsPreference.Length != 0) |
| | 29 | | { |
| 0 | 30 | | if (blockedChannelsPreference.Contains(Id)) |
| | 31 | | { |
| 0 | 32 | | return false; |
| | 33 | | } |
| | 34 | | } |
| | 35 | | else |
| | 36 | | { |
| 0 | 37 | | if (!user.HasPermission(PermissionKind.EnableAllChannels) |
| 0 | 38 | | && !user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels).Contains(Id)) |
| | 39 | | { |
| 0 | 40 | | return false; |
| | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| 0 | 44 | | return base.IsVisible(user); |
| | 45 | | } |
| | 46 | |
|
| | 47 | | protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) |
| | 48 | | { |
| | 49 | | try |
| | 50 | | { |
| 0 | 51 | | query.Parent = this; |
| 0 | 52 | | query.ChannelIds = new Guid[] { Id }; |
| | 53 | |
|
| | 54 | | // Don't blow up here because it could cause parent screens with other content to fail |
| 0 | 55 | | return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).Get |
| | 56 | | } |
| 0 | 57 | | catch |
| | 58 | | { |
| | 59 | | // Already logged at lower levels |
| 0 | 60 | | return new QueryResult<BaseItem>(); |
| | 61 | | } |
| 0 | 62 | | } |
| | 63 | |
|
| | 64 | | protected override string GetInternalMetadataPath(string basePath) |
| | 65 | | { |
| 0 | 66 | | return GetInternalMetadataPath(basePath, Id); |
| | 67 | | } |
| | 68 | |
|
| | 69 | | public static string GetInternalMetadataPath(string basePath, Guid id) |
| | 70 | | { |
| 0 | 71 | | return System.IO.Path.Combine(basePath, "channels", id.ToString("N", CultureInfo.InvariantCulture), "metadat |
| | 72 | | } |
| | 73 | |
|
| | 74 | | public override bool CanDelete() |
| | 75 | | { |
| 0 | 76 | | return false; |
| | 77 | | } |
| | 78 | |
|
| | 79 | | internal static bool IsChannelVisible(BaseItem channelItem, User user) |
| | 80 | | { |
| 0 | 81 | | var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString(string.Empty)); |
| | 82 | |
|
| 0 | 83 | | return channel.IsVisible(user); |
| | 84 | | } |
| | 85 | | } |
| | 86 | | } |