using System.Collections.Generic; using Kyoo.Abstractions.Models; using Kyoo.Utils; using TMDbLib.Objects.Search; namespace Kyoo.TheMovieDb { /// /// A class containing extensions methods to convert from TMDB's types to Kyoo's types. /// public static partial class Convertors { /// /// Convert a into a . /// /// The collection to convert. /// The provider representing TheMovieDb. /// The converted collection as a . public static Collection ToCollection(this TMDbLib.Objects.Collections.Collection collection, Provider provider) { return new Collection { Slug = Utility.ToSlug(collection.Name), Name = collection.Name, Overview = collection.Overview, Images = new Dictionary { [Images.Poster] = collection.PosterPath != null ? $"https://image.tmdb.org/t/p/original{collection.PosterPath}" : null, [Images.Thumbnail] = collection.BackdropPath != null ? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}" : null }, ExternalIDs = new [] { new MetadataID { Provider = provider, Link = $"https://www.themoviedb.org/collection/{collection.Id}", DataID = collection.Id.ToString() } } }; } /// /// Convert a into a . /// /// The collection to convert. /// The provider representing TheMovieDb. /// The converted collection as a . public static Collection ToCollection(this SearchCollection collection, Provider provider) { return new Collection { Slug = Utility.ToSlug(collection.Name), Name = collection.Name, Images = new Dictionary { [Images.Poster] = collection.PosterPath != null ? $"https://image.tmdb.org/t/p/original{collection.PosterPath}" : null, [Images.Thumbnail] = collection.BackdropPath != null ? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}" : null }, ExternalIDs = new [] { new MetadataID { Provider = provider, Link = $"https://www.themoviedb.org/collection/{collection.Id}", DataID = collection.Id.ToString() } } }; } } }