using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Jellyfin.Plugin.TubeArchivistMetadata.Utilities; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using Newtonsoft.Json; namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist { /// /// A class representing TubeArchivist API channel data. /// public class Channel { /// /// Initializes a new instance of the class. /// /// URL of the channel banner image. /// Channel description. /// Channel YouTube id. /// Channel name. /// Channel tags. /// URL of the channel thumb image. /// URL of the channel tvart image. public Channel( string bannerUrl, string description, string id, string name, Collection tags, string thumbUrl, string tvartUrl) { this.BannerUrl = bannerUrl; this.Description = description; this.Id = id; this.Name = name; this.Tags = tags; this.ThumbUrl = thumbUrl; this.TvartUrl = tvartUrl; } /// /// Gets or sets the URL of the channel banner image. /// [JsonProperty(PropertyName = "channel_banner_url")] public string BannerUrl { get; set; } /// /// Gets or sets the channel description. /// [JsonProperty(PropertyName = "channel_description")] public string Description { get; set; } /// /// Gets or sets the channel YouTube id. /// [JsonProperty(PropertyName = "channel_id")] public string Id { get; set; } /// /// Gets or sets the channel name. /// [JsonProperty(PropertyName = "channel_name")] public string Name { get; set; } /// /// Gets channel tags. /// [JsonProperty(PropertyName = "channel_tags")] [JsonConverter(typeof(TagsJsonConverter))] public Collection Tags { get; } /// /// Gets or sets the URL of the channel thumb image. /// [JsonProperty(PropertyName = "channel_thumb_url")] public string ThumbUrl { get; set; } /// /// Gets or sets the URL of the channel tvart image. /// [JsonProperty(PropertyName = "channel_tvart_url")] public string TvartUrl { get; set; } /// /// Converts the TubeArchivist API channel to a Jellyfin object. /// /// The channel equivalent Jellyfin object. public RemoteSearchResult ToSearchResult() { return new RemoteSearchResult { Name = Name, SearchProviderName = Constants.ProviderName, ImageUrl = Utils.HasImageUrl(ThumbUrl) ? ThumbUrl : null, ProviderIds = new Dictionary() { { Constants.ProviderName, Id } } }; } /// /// Converts the TubeArchivist API channel to a Jellyfin object. /// /// The channel equivalent Jellyfin object. public Series ToSeries() { return new Series { Name = Name, Overview = Utils.FormatDescription(Description), Studios = new[] { Name }, ProviderIds = new Dictionary() { { Constants.ProviderName, Id } }, ImageInfos = Utils.HasImageUrl(ThumbUrl) ? [ new ItemImageInfo { Path = ThumbUrl, Type = ImageType.Primary } ] : [], Tags = this.Tags != null ? this.Tags.ToArray() : [] }; } } }