From c6628aa637325b0c5ee2d999d8f7b76a2e98fe6e Mon Sep 17 00:00:00 2001 From: Kevin Jilissen Date: Mon, 4 Jul 2022 22:40:04 +0200 Subject: [PATCH] Remove the old Live Channel, as Live TV integration has matured. --- Jellyfin.Xtream/LiveChannel.cs | 189 --------------------------------- 1 file changed, 189 deletions(-) delete mode 100644 Jellyfin.Xtream/LiveChannel.cs diff --git a/Jellyfin.Xtream/LiveChannel.cs b/Jellyfin.Xtream/LiveChannel.cs deleted file mode 100644 index b60c6c4..0000000 --- a/Jellyfin.Xtream/LiveChannel.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2022 Kevin Jilissen - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Jellyfin.Xtream.Client; -using Jellyfin.Xtream.Client.Models; -using Jellyfin.Xtream.Service; -using MediaBrowser.Controller.Channels; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Channels; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; -using Microsoft.Extensions.Logging; - -namespace Jellyfin.Xtream -{ - /// - /// The Xtream Codes API channel. - /// - public class LiveChannel : IChannel - { - private readonly ILogger logger; - - /// - /// Initializes a new instance of the class. - /// - /// Instance of the interface. - public LiveChannel(ILogger logger) - { - this.logger = logger; - } - - /// - public string? Name => "Xtream Live"; - - /// - public string? Description => "Live IPTV streamed from the Xtream-compatible server."; - - /// - public string DataVersion => Plugin.Instance.Creds.ToString(); - - /// - public string HomePageUrl => string.Empty; - - /// - public ChannelParentalRating ParentalRating => ChannelParentalRating.GeneralAudience; - - /// - public InternalChannelFeatures GetChannelFeatures() - { - return new InternalChannelFeatures - { - ContentTypes = new List - { - ChannelMediaContentType.TvExtra, - }, - - MediaTypes = new List - { - ChannelMediaType.Video - }, - }; - } - - /// - public Task GetChannelImage(ImageType type, CancellationToken cancellationToken) - { - switch (type) - { - default: - throw new ArgumentException("Unsupported image type: " + type); - } - } - - /// - public IEnumerable GetSupportedChannelImages() - { - return new List - { - // ImageType.Primary - }; - } - - /// - public async Task GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken) - { - if (string.IsNullOrEmpty(query.FolderId)) - { - return await GetCategories(cancellationToken).ConfigureAwait(false); - } - - int categoryId = int.Parse(query.FolderId, CultureInfo.InvariantCulture); - return await GetVideos(categoryId, cancellationToken).ConfigureAwait(false); - } - - private async Task GetCategories(CancellationToken cancellationToken) - { - Plugin plugin = Plugin.Instance; - using (XtreamClient client = new XtreamClient()) - { - List categories = await client.GetLiveCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false); - List items = new List(); - - foreach (Category category in categories) - { - ParsedName parsedName = plugin.StreamService.ParseName(category.CategoryName); - items.Add(new ChannelItemInfo() - { - Id = category.CategoryId.ToString(System.Globalization.CultureInfo.InvariantCulture), - Name = category.CategoryName, - Tags = new List(parsedName.Tags), - Type = ChannelItemType.Folder, - }); - } - - ChannelItemResult result = new ChannelItemResult() - { - Items = items, - TotalRecordCount = items.Count - }; - return result; - } - } - - private async Task GetVideos(int categoryId, CancellationToken cancellationToken) - { - Plugin plugin = Plugin.Instance; - using (XtreamClient client = new XtreamClient()) - { - IEnumerable channels = await client.GetLiveStreamsByCategoryAsync(plugin.Creds, categoryId, cancellationToken).ConfigureAwait(false); - List items = new List(); - - foreach (StreamInfo channel in channels) - { - long added = long.Parse(channel.Added, System.Globalization.CultureInfo.InvariantCulture); - ParsedName parsedName = plugin.StreamService.ParseName(channel.Name); - List sources = new List() - { - plugin.StreamService.GetMediaSourceInfo(StreamType.Live, channel.StreamId) - }; - - items.Add(new ChannelItemInfo() - { - ContentType = ChannelMediaContentType.TvExtra, - DateCreated = DateTimeOffset.FromUnixTimeSeconds(added).DateTime, - FolderType = ChannelFolderType.Container, - Id = channel.StreamId.ToString(CultureInfo.InvariantCulture), - ImageUrl = channel.StreamIcon, - IsLiveStream = true, - MediaSources = sources, - MediaType = ChannelMediaType.Video, - Name = parsedName.Title, - Tags = new List(parsedName.Tags), - Type = ChannelItemType.Media, - }); - } - - ChannelItemResult result = new ChannelItemResult() - { - Items = items, - TotalRecordCount = items.Count - }; - return result; - } - } - - /// - public bool IsEnabledFor(string userId) - { - return true; - } - } -} -- 2.51.0