From 817d9b3389a4a15584e322e88793596468c8028a Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 18 Aug 2019 13:20:52 +0200 Subject: [PATCH 1/6] Move and rename tmdb providers for better separation --- .../Movies/MovieExternalIds.cs | 79 ------ .../Tmdb/BoxSets/TmdbBoxSetExternalId.cs | 21 ++ .../BoxSets/TmdbBoxSetImageProvider.cs} | 29 ++- .../BoxSets/TmdbBoxSetProvider.cs} | 106 +++----- .../Models/Collections/CollectionImages.cs | 11 + .../Models/Collections/CollectionResult.cs | 15 ++ .../Tmdb/Models/Collections/Part.cs | 11 + .../Tmdb/Models/General/Backdrop.cs | 13 + .../Tmdb/Models/General/Crew.cs | 12 + .../Tmdb/Models/General/ExternalIds.cs | 11 + .../Tmdb/Models/General/Genre.cs | 8 + .../Tmdb/Models/General/Images.cs | 10 + .../Tmdb/Models/General/Keyword.cs | 8 + .../Tmdb/Models/General/Keywords.cs | 9 + .../Tmdb/Models/General/Poster.cs | 13 + .../Tmdb/Models/General/Profile.cs | 11 + .../Tmdb/Models/General/Still.cs | 14 + .../Tmdb/Models/General/StillImages.cs | 9 + .../Tmdb/Models/General/Video.cs | 14 + .../Tmdb/Models/General/Videos.cs | 9 + .../Tmdb/Models/Movies/BelongsToCollection.cs | 10 + .../Tmdb/Models/Movies/Cast.cs | 12 + .../Tmdb/Models/Movies/Casts.cs | 11 + .../Tmdb/Models/Movies/Country.cs | 11 + .../Tmdb/Models/Movies/MovieResult.cs | 49 ++++ .../Tmdb/Models/Movies/ProductionCompany.cs | 8 + .../Tmdb/Models/Movies/ProductionCountry.cs | 8 + .../Tmdb/Models/Movies/Releases.cs | 9 + .../Tmdb/Models/Movies/SpokenLanguage.cs | 8 + .../Tmdb/Models/Movies/Trailers.cs | 9 + .../Tmdb/Models/Movies/Youtube.cs | 9 + .../Tmdb/Models/People/PersonImages.cs | 10 + .../Tmdb/Models/People/PersonResult.cs | 23 ++ .../Tmdb/Models/People/PersonSearchResult.cs | 26 ++ .../Tmdb/Models/People/PersonSearchResults.cs | 28 ++ .../Models/Search/ExternalIdLookupResult.cs | 10 + .../Tmdb/Models/Search/MovieResult.cs | 65 +++++ .../Tmdb/Models/Search/MovieSearchResults.cs | 28 ++ .../Tmdb/Models/Search/TvResult.cs | 15 ++ .../Tmdb/Models/Search/TvSearchResults.cs | 28 ++ MediaBrowser.Providers/Tmdb/Models/TV/Cast.cs | 12 + .../Tmdb/Models/TV/ContentRating.cs | 8 + .../Tmdb/Models/TV/ContentRatings.cs | 9 + .../Tmdb/Models/TV/CreatedBy.cs | 9 + .../Tmdb/Models/TV/Credits.cs | 11 + .../Tmdb/Models/TV/Episode.cs | 14 + .../Tmdb/Models/TV/EpisodeCredits.cs | 12 + .../Tmdb/Models/TV/EpisodeResult.cs | 23 ++ .../Tmdb/Models/TV/GuestStar.cs | 12 + .../Tmdb/Models/TV/Network.cs | 8 + .../Tmdb/Models/TV/Season.cs | 11 + .../Tmdb/Models/TV/SeasonImages.cs | 10 + .../Tmdb/Models/TV/SeasonResult.cs | 21 ++ .../Tmdb/Models/TV/SeriesResult.cs | 40 +++ .../Movies/GenericTmdbMovieInfo.cs} | 34 +-- .../Movies/TmdbImageProvider.cs} | 33 +-- .../Tmdb/Movies/TmdbMovieExternalId.cs | 28 ++ .../Movies/TmdbMovieProvider.cs} | 246 ++---------------- .../Movies/TmdbSearch.cs} | 176 ++----------- .../{ => Tmdb}/Movies/TmdbSettings.cs | 2 +- .../Music/TmdbMusicVideoProvider.cs} | 9 +- .../Tmdb/People/TmdbPersonExternalId.cs | 20 ++ .../People/TmdbPersonImageProvider.cs} | 27 +- .../People/TmdbPersonProvider.cs} | 159 ++--------- .../TV/TmdbEpisodeImageProvider.cs} | 19 +- .../TV/TmdbEpisodeProvider.cs} | 10 +- .../TV/TmdbEpisodeProviderBase.cs} | 127 ++------- .../TV/TmdbSeasonProvider.cs} | 117 ++------- .../Tmdb/TV/TmdbSeriesExternalId.cs | 20 ++ .../TV/TmdbSeriesImageProvider.cs} | 32 +-- .../TV/TmdbSeriesProvider.cs} | 226 +++------------- MediaBrowser.Providers/Tmdb/TmdbUtils.cs | 30 +++ .../Trailers/TmdbTrailerProvider.cs} | 14 +- 73 files changed, 1142 insertions(+), 1177 deletions(-) create mode 100644 MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetExternalId.cs rename MediaBrowser.Providers/{BoxSets/MovieDbBoxSetImageProvider.cs => Tmdb/BoxSets/TmdbBoxSetImageProvider.cs} (79%) rename MediaBrowser.Providers/{BoxSets/MovieDbBoxSetProvider.cs => Tmdb/BoxSets/TmdbBoxSetProvider.cs} (65%) create mode 100644 MediaBrowser.Providers/Tmdb/Models/Collections/CollectionImages.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Collections/CollectionResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Collections/Part.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Backdrop.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Crew.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/ExternalIds.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Genre.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Images.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Keyword.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Keywords.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Poster.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Profile.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Still.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/StillImages.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Video.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/General/Videos.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/BelongsToCollection.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Cast.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Casts.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Country.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/MovieResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/ProductionCompany.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/ProductionCountry.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Releases.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/SpokenLanguage.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Trailers.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Movies/Youtube.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/People/PersonImages.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/People/PersonResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/People/PersonSearchResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/People/PersonSearchResults.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Search/ExternalIdLookupResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Search/MovieResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Search/MovieSearchResults.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Search/TvResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/Search/TvSearchResults.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/Cast.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/ContentRating.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/ContentRatings.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/CreatedBy.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/Credits.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/Episode.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/EpisodeCredits.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/EpisodeResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/GuestStar.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/Network.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/Season.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/SeasonImages.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/SeasonResult.cs create mode 100644 MediaBrowser.Providers/Tmdb/Models/TV/SeriesResult.cs rename MediaBrowser.Providers/{Movies/GenericMovieDbInfo.cs => Tmdb/Movies/GenericTmdbMovieInfo.cs} (89%) rename MediaBrowser.Providers/{Movies/MovieDbImageProvider.cs => Tmdb/Movies/TmdbImageProvider.cs} (81%) create mode 100644 MediaBrowser.Providers/Tmdb/Movies/TmdbMovieExternalId.cs rename MediaBrowser.Providers/{Movies/MovieDbProvider.cs => Tmdb/Movies/TmdbMovieProvider.cs} (64%) rename MediaBrowser.Providers/{Movies/MovieDbSearch.cs => Tmdb/Movies/TmdbSearch.cs} (59%) rename MediaBrowser.Providers/{ => Tmdb}/Movies/TmdbSettings.cs (92%) rename MediaBrowser.Providers/{Music/MovieDbMusicVideoProvider.cs => Tmdb/Music/TmdbMusicVideoProvider.cs} (71%) create mode 100644 MediaBrowser.Providers/Tmdb/People/TmdbPersonExternalId.cs rename MediaBrowser.Providers/{People/MovieDbPersonImageProvider.cs => Tmdb/People/TmdbPersonImageProvider.cs} (75%) rename MediaBrowser.Providers/{People/MovieDbPersonProvider.cs => Tmdb/People/TmdbPersonProvider.cs} (60%) rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbEpisodeImageProvider.cs => Tmdb/TV/TmdbEpisodeImageProvider.cs} (82%) rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbEpisodeProvider.cs => Tmdb/TV/TmdbEpisodeProvider.cs} (95%) rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbProviderBase.cs => Tmdb/TV/TmdbEpisodeProviderBase.cs} (50%) rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbSeasonProvider.cs => Tmdb/TV/TmdbSeasonProvider.cs} (64%) create mode 100644 MediaBrowser.Providers/Tmdb/TV/TmdbSeriesExternalId.cs rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbSeriesImageProvider.cs => Tmdb/TV/TmdbSeriesImageProvider.cs} (78%) rename MediaBrowser.Providers/{TV/TheMovieDb/MovieDbSeriesProvider.cs => Tmdb/TV/TmdbSeriesProvider.cs} (66%) create mode 100644 MediaBrowser.Providers/Tmdb/TmdbUtils.cs rename MediaBrowser.Providers/{Movies/MovieDbTrailerProvider.cs => Tmdb/Trailers/TmdbTrailerProvider.cs} (64%) diff --git a/MediaBrowser.Providers/Movies/MovieExternalIds.cs b/MediaBrowser.Providers/Movies/MovieExternalIds.cs index 3783c50324..09ed6034c8 100644 --- a/MediaBrowser.Providers/Movies/MovieExternalIds.cs +++ b/MediaBrowser.Providers/Movies/MovieExternalIds.cs @@ -7,85 +7,6 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Providers.Movies { - public class MovieDbMovieExternalId : IExternalId - { - public const string BaseMovieDbUrl = "https://www.themoviedb.org/"; - - public string Name => "TheMovieDb"; - - public string Key => MetadataProviders.Tmdb.ToString(); - - public string UrlFormatString => BaseMovieDbUrl + "movie/{0}"; - - public bool Supports(IHasProviderIds item) - { - // Supports images for tv movies - var tvProgram = item as LiveTvProgram; - if (tvProgram != null && tvProgram.IsMovie) - { - return true; - } - - return item is Movie || item is MusicVideo || item is Trailer; - } - } - - public class MovieDbSeriesExternalId : IExternalId - { - public string Name => "TheMovieDb"; - - public string Key => MetadataProviders.Tmdb.ToString(); - - public string UrlFormatString => MovieDbMovieExternalId.BaseMovieDbUrl + "tv/{0}"; - - public bool Supports(IHasProviderIds item) - { - return item is Series; - } - } - - public class MovieDbMovieCollectionExternalId : IExternalId - { - public string Name => "TheMovieDb Collection"; - - public string Key => MetadataProviders.TmdbCollection.ToString(); - - public string UrlFormatString => MovieDbMovieExternalId.BaseMovieDbUrl + "collection/{0}"; - - public bool Supports(IHasProviderIds item) - { - return item is Movie || item is MusicVideo || item is Trailer; - } - } - - public class MovieDbPersonExternalId : IExternalId - { - public string Name => "TheMovieDb"; - - public string Key => MetadataProviders.Tmdb.ToString(); - - public string UrlFormatString => MovieDbMovieExternalId.BaseMovieDbUrl + "person/{0}"; - - public bool Supports(IHasProviderIds item) - { - return item is Person; - } - } - - public class MovieDbCollectionExternalId : IExternalId - { - public string Name => "TheMovieDb"; - - public string Key => MetadataProviders.Tmdb.ToString(); - - public string UrlFormatString => MovieDbMovieExternalId.BaseMovieDbUrl + "collection/{0}"; - - public bool Supports(IHasProviderIds item) - { - return item is BoxSet; - } - } - public class ImdbExternalId : IExternalId { public string Name => "IMDb"; diff --git a/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetExternalId.cs b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetExternalId.cs new file mode 100644 index 0000000000..739e05b88f --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetExternalId.cs @@ -0,0 +1,21 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Tmdb.BoxSets +{ + public class TmdbBoxSetExternalId : IExternalId + { + public string Name => TmdbUtils.ProviderName; + + public string Key => MetadataProviders.TmdbCollection.ToString(); + + public string UrlFormatString => TmdbUtils.BaseMovieDbUrl + "collection/{0}"; + + public bool Supports(IHasProviderIds item) + { + return item is Movie || item is MusicVideo || item is Trailer; + } + } +} diff --git a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetImageProvider.cs b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs similarity index 79% rename from MediaBrowser.Providers/BoxSets/MovieDbBoxSetImageProvider.cs rename to MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs index 4d12b2f4ab..23db6b90d4 100644 --- a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetImageProvider.cs +++ b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs @@ -11,21 +11,24 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Providers.Movies; +using MediaBrowser.Providers.Tmdb.Models.Collections; +using MediaBrowser.Providers.Tmdb.Models.General; +using MediaBrowser.Providers.Tmdb.Movies; -namespace MediaBrowser.Providers.BoxSets +namespace MediaBrowser.Providers.Tmdb.BoxSets { - public class MovieDbBoxSetImageProvider : IRemoteImageProvider, IHasOrder + public class TmdbBoxSetImageProvider : IRemoteImageProvider, IHasOrder { private readonly IHttpClient _httpClient; - public MovieDbBoxSetImageProvider(IHttpClient httpClient) + public TmdbBoxSetImageProvider(IHttpClient httpClient) { _httpClient = httpClient; } public string Name => ProviderName; - public static string ProviderName => "TheMovieDb"; + public static string ProviderName => TmdbUtils.ProviderName; public bool Supports(BaseItem item) { @@ -49,11 +52,11 @@ namespace MediaBrowser.Providers.BoxSets { var language = item.GetPreferredMetadataLanguage(); - var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, null, cancellationToken).ConfigureAwait(false); + var mainResult = await TmdbBoxSetProvider.Current.GetMovieDbResult(tmdbId, null, cancellationToken).ConfigureAwait(false); if (mainResult != null) { - var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); + var tmdbSettings = await TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); var tmdbImageUrl = tmdbSettings.images.GetImageUrl("original"); @@ -64,11 +67,11 @@ namespace MediaBrowser.Providers.BoxSets return new List(); } - private IEnumerable GetImages(MovieDbBoxSetProvider.RootObject obj, string language, string baseUrl) + private IEnumerable GetImages(CollectionResult obj, string language, string baseUrl) { var list = new List(); - var images = obj.images ?? new MovieDbBoxSetProvider.Images(); + var images = obj.images ?? new CollectionImages(); list.AddRange(GetPosters(images).Select(i => new RemoteImageInfo { @@ -77,7 +80,7 @@ namespace MediaBrowser.Providers.BoxSets VoteCount = i.vote_count, Width = i.width, Height = i.height, - Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language), + Language = TmdbMovieProvider.AdjustImageLanguage(i.iso_639_1, language), ProviderName = Name, Type = ImageType.Primary, RatingType = RatingType.Score @@ -125,9 +128,9 @@ namespace MediaBrowser.Providers.BoxSets /// /// The images. /// IEnumerable{MovieDbProvider.Poster}. - private IEnumerable GetPosters(MovieDbBoxSetProvider.Images images) + private IEnumerable GetPosters(CollectionImages images) { - return images.posters ?? new List(); + return images.posters ?? new List(); } /// @@ -135,9 +138,9 @@ namespace MediaBrowser.Providers.BoxSets /// /// The images. /// IEnumerable{MovieDbProvider.Backdrop}. - private IEnumerable GetBackdrops(MovieDbBoxSetProvider.Images images) + private IEnumerable GetBackdrops(CollectionImages images) { - var eligibleBackdrops = images.backdrops == null ? new List() : + var eligibleBackdrops = images.backdrops == null ? new List() : images.backdrops; return eligibleBackdrops.OrderByDescending(i => i.vote_average) diff --git a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetProvider.cs similarity index 65% rename from MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs rename to MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetProvider.cs index 4e41694c4d..f8255f8736 100644 --- a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs +++ b/MediaBrowser.Providers/Tmdb/BoxSets/TmdbBoxSetProvider.cs @@ -16,16 +16,18 @@ using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Providers.Movies; +using MediaBrowser.Providers.Tmdb.Models.Collections; +using MediaBrowser.Providers.Tmdb.Models.General; +using MediaBrowser.Providers.Tmdb.Movies; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Providers.BoxSets +namespace MediaBrowser.Providers.Tmdb.BoxSets { - public class MovieDbBoxSetProvider : IRemoteMetadataProvider + public class TmdbBoxSetProvider : IRemoteMetadataProvider { - private const string GetCollectionInfo3 = MovieDbProvider.BaseMovieDbUrl + @"3/collection/{0}?api_key={1}&append_to_response=images"; + private const string GetCollectionInfo3 = TmdbUtils.BaseMovieDbUrl + @"3/collection/{0}?api_key={1}&append_to_response=images"; - internal static MovieDbBoxSetProvider Current; + internal static TmdbBoxSetProvider Current; private readonly ILogger _logger; private readonly IJsonSerializer _json; @@ -35,7 +37,7 @@ namespace MediaBrowser.Providers.BoxSets private readonly IHttpClient _httpClient; private readonly ILibraryManager _libraryManager; - public MovieDbBoxSetProvider(ILogger logger, IJsonSerializer json, IServerConfigurationManager config, IFileSystem fileSystem, ILocalizationManager localization, IHttpClient httpClient, ILibraryManager libraryManager) + public TmdbBoxSetProvider(ILogger logger, IJsonSerializer json, IServerConfigurationManager config, IFileSystem fileSystem, ILocalizationManager localization, IHttpClient httpClient, ILibraryManager libraryManager) { _logger = logger; _json = json; @@ -58,11 +60,11 @@ namespace MediaBrowser.Providers.BoxSets await EnsureInfo(tmdbId, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false); var dataFilePath = GetDataFilePath(_config.ApplicationPaths, tmdbId, searchInfo.MetadataLanguage); - var info = _json.DeserializeFromFile(dataFilePath); + var info = _json.DeserializeFromFile(dataFilePath); - var images = (info.images ?? new Images()).posters ?? new List(); + var images = (info.images ?? new CollectionImages()).posters ?? new List(); - var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); + var tmdbSettings = await TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); var tmdbImageUrl = tmdbSettings.images.GetImageUrl("original"); @@ -80,7 +82,7 @@ namespace MediaBrowser.Providers.BoxSets return new[] { result }; } - return await new MovieDbSearch(_logger, _json, _libraryManager).GetSearchResults(searchInfo, cancellationToken).ConfigureAwait(false); + return await new TmdbSearch(_logger, _json, _libraryManager).GetSearchResults(searchInfo, cancellationToken).ConfigureAwait(false); } public async Task> GetMetadata(BoxSetInfo id, CancellationToken cancellationToken) @@ -90,7 +92,7 @@ namespace MediaBrowser.Providers.BoxSets // We don't already have an Id, need to fetch it if (string.IsNullOrEmpty(tmdbId)) { - var searchResults = await new MovieDbSearch(_logger, _json, _libraryManager).GetSearchResults(id, cancellationToken).ConfigureAwait(false); + var searchResults = await new TmdbSearch(_logger, _json, _libraryManager).GetSearchResults(id, cancellationToken).ConfigureAwait(false); var searchResult = searchResults.FirstOrDefault(); @@ -116,7 +118,7 @@ namespace MediaBrowser.Providers.BoxSets return result; } - internal async Task GetMovieDbResult(string tmdbId, string language, CancellationToken cancellationToken) + internal async Task GetMovieDbResult(string tmdbId, string language, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(tmdbId)) { @@ -129,13 +131,13 @@ namespace MediaBrowser.Providers.BoxSets if (!string.IsNullOrEmpty(dataFilePath)) { - return _json.DeserializeFromFile(dataFilePath); + return _json.DeserializeFromFile(dataFilePath); } return null; } - private BoxSet GetItem(RootObject obj) + private BoxSet GetItem(CollectionResult obj) { var item = new BoxSet { @@ -161,33 +163,33 @@ namespace MediaBrowser.Providers.BoxSets _json.SerializeToFile(mainResult, dataFilePath); } - private async Task FetchMainResult(string id, string language, CancellationToken cancellationToken) + private async Task FetchMainResult(string id, string language, CancellationToken cancellationToken) { - var url = string.Format(GetCollectionInfo3, id, MovieDbProvider.ApiKey); + var url = string.Format(GetCollectionInfo3, id, TmdbUtils.ApiKey); if (!string.IsNullOrEmpty(language)) { - url += string.Format("&language={0}", MovieDbProvider.NormalizeLanguage(language)); + url += string.Format("&language={0}", TmdbMovieProvider.NormalizeLanguage(language)); // Get images in english and with no language - url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language); + url += "&include_image_language=" + TmdbMovieProvider.GetImageLanguagesParam(language); } cancellationToken.ThrowIfCancellationRequested(); - RootObject mainResult = null; + CollectionResult mainResult; - using (var response = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions + using (var response = await TmdbMovieProvider.Current.GetMovieDbResponse(new HttpRequestOptions { Url = url, CancellationToken = cancellationToken, - AcceptHeader = MovieDbSearch.AcceptHeader + AcceptHeader = TmdbUtils.AcceptHeader }).ConfigureAwait(false)) { using (var json = response.Content) { - mainResult = await _json.DeserializeFromStreamAsync(json).ConfigureAwait(false); + mainResult = await _json.DeserializeFromStreamAsync(json).ConfigureAwait(false); } } @@ -197,25 +199,25 @@ namespace MediaBrowser.Providers.BoxSets { if (!string.IsNullOrEmpty(language) && !string.Equals(language, "en", StringComparison.OrdinalIgnoreCase)) { - url = string.Format(GetCollectionInfo3, id, MovieDbSearch.ApiKey) + "&language=en"; + url = string.Format(GetCollectionInfo3, id, TmdbUtils.ApiKey) + "&language=en"; if (!string.IsNullOrEmpty(language)) { // Get images in english and with no language - url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language); + url += "&include_image_language=" + TmdbMovieProvider.GetImageLanguagesParam(language); } - using (var response = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions + using (var response = await TmdbMovieProvider.Current.GetMovieDbResponse(new HttpRequestOptions { Url = url, CancellationToken = cancellationToken, - AcceptHeader = MovieDbSearch.AcceptHeader + AcceptHeader = TmdbUtils.AcceptHeader }).ConfigureAwait(false)) { using (var json = response.Content) { - mainResult = await _json.DeserializeFromStreamAsync(json).ConfigureAwait(false); + mainResult = await _json.DeserializeFromStreamAsync(json).ConfigureAwait(false); } } } @@ -241,7 +243,7 @@ namespace MediaBrowser.Providers.BoxSets return DownloadInfo(tmdbId, preferredMetadataLanguage, cancellationToken); } - public string Name => "TheMovieDb"; + public string Name => TmdbUtils.ProviderName; private static string GetDataFilePath(IApplicationPaths appPaths, string tmdbId, string preferredLanguage) { @@ -266,54 +268,6 @@ namespace MediaBrowser.Providers.BoxSets return dataPath; } - internal class Part - { - public string title { get; set; } - public int id { get; set; } - public string release_date { get; set; } - public string poster_path { get; set; } - public string backdrop_path { get; set; } - } - - internal class Backdrop - { - public double aspect_ratio { get; set; } - public string file_path { get; set; } - public int height { get; set; } - public string iso_639_1 { get; set; } - public double vote_average { get; set; } - public int vote_count { get; set; } - public int width { get; set; } - } - - internal class Poster - { - public double aspect_ratio { get; set; } - public string file_path { get; set; } - public int height { get; set; } - public string iso_639_1 { get; set; } - public double vote_average { get; set; } - public int vote_count { get; set; } - public int width { get; set; } - } - - internal class Images - { - public List backdrops { get; set; } - public List posters { get; set; } - } - - internal class RootObject - { - public int id { get; set; } - public string name { get; set; } - public string overview { get; set; } - public string poster_path { get; set; } - public string backdrop_path { get; set; } - public List parts { get; set; } - public Images images { get; set; } - } - public Task GetImageResponse(string url, CancellationToken cancellationToken) { return _httpClient.GetResponse(new HttpRequestOptions diff --git a/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionImages.cs b/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionImages.cs new file mode 100644 index 0000000000..fc4fc6f649 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionImages.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using MediaBrowser.Providers.Tmdb.Models.General; + +namespace MediaBrowser.Providers.Tmdb.Models.Collections +{ + public class CollectionImages + { + public List backdrops { get; set; } + public List posters { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionResult.cs b/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionResult.cs new file mode 100644 index 0000000000..6bc47d9acc --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/Collections/CollectionResult.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Providers.Tmdb.Models.Collections +{ + public class CollectionResult + { + public int id { get; set; } + public string name { get; set; } + public string overview { get; set; } + public string poster_path { get; set; } + public string backdrop_path { get; set; } + public List parts { get; set; } + public CollectionImages images { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/Collections/Part.cs b/MediaBrowser.Providers/Tmdb/Models/Collections/Part.cs new file mode 100644 index 0000000000..a5611d69f1 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/Collections/Part.cs @@ -0,0 +1,11 @@ +namespace MediaBrowser.Providers.Tmdb.Models.Collections +{ + public class Part + { + public string title { get; set; } + public int id { get; set; } + public string release_date { get; set; } + public string poster_path { get; set; } + public string backdrop_path { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Backdrop.cs b/MediaBrowser.Providers/Tmdb/Models/General/Backdrop.cs new file mode 100644 index 0000000000..6a3ff824f8 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Backdrop.cs @@ -0,0 +1,13 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Backdrop + { + public double aspect_ratio { get; set; } + public string file_path { get; set; } + public int height { get; set; } + public string iso_639_1 { get; set; } + public double vote_average { get; set; } + public int vote_count { get; set; } + public int width { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Crew.cs b/MediaBrowser.Providers/Tmdb/Models/General/Crew.cs new file mode 100644 index 0000000000..de229f8309 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Crew.cs @@ -0,0 +1,12 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Crew + { + public int id { get; set; } + public string credit_id { get; set; } + public string name { get; set; } + public string department { get; set; } + public string job { get; set; } + public string profile_path { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/ExternalIds.cs b/MediaBrowser.Providers/Tmdb/Models/General/ExternalIds.cs new file mode 100644 index 0000000000..e70fe2b98c --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/ExternalIds.cs @@ -0,0 +1,11 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class ExternalIds + { + public string imdb_id { get; set; } + public object freebase_id { get; set; } + public string freebase_mid { get; set; } + public int tvdb_id { get; set; } + public int tvrage_id { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Genre.cs b/MediaBrowser.Providers/Tmdb/Models/General/Genre.cs new file mode 100644 index 0000000000..5dda289692 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Genre.cs @@ -0,0 +1,8 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Genre + { + public int id { get; set; } + public string name { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Images.cs b/MediaBrowser.Providers/Tmdb/Models/General/Images.cs new file mode 100644 index 0000000000..ee5401aa14 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Images.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Images + { + public List backdrops { get; set; } + public List posters { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Keyword.cs b/MediaBrowser.Providers/Tmdb/Models/General/Keyword.cs new file mode 100644 index 0000000000..590814005f --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Keyword.cs @@ -0,0 +1,8 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Keyword + { + public int id { get; set; } + public string name { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Keywords.cs b/MediaBrowser.Providers/Tmdb/Models/General/Keywords.cs new file mode 100644 index 0000000000..3986e06f8a --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Keywords.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Keywords + { + public List results { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Poster.cs b/MediaBrowser.Providers/Tmdb/Models/General/Poster.cs new file mode 100644 index 0000000000..4acb16a2b7 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Poster.cs @@ -0,0 +1,13 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Poster + { + public double aspect_ratio { get; set; } + public string file_path { get; set; } + public int height { get; set; } + public string iso_639_1 { get; set; } + public double vote_average { get; set; } + public int vote_count { get; set; } + public int width { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Profile.cs b/MediaBrowser.Providers/Tmdb/Models/General/Profile.cs new file mode 100644 index 0000000000..51e0bb6ca9 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Profile.cs @@ -0,0 +1,11 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Profile + { + public string file_path { get; set; } + public int width { get; set; } + public int height { get; set; } + public object iso_639_1 { get; set; } + public double aspect_ratio { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Still.cs b/MediaBrowser.Providers/Tmdb/Models/General/Still.cs new file mode 100644 index 0000000000..75f57ddadc --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Still.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Still + { + public double aspect_ratio { get; set; } + public string file_path { get; set; } + public int height { get; set; } + public string id { get; set; } + public string iso_639_1 { get; set; } + public double vote_average { get; set; } + public int vote_count { get; set; } + public int width { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/StillImages.cs b/MediaBrowser.Providers/Tmdb/Models/General/StillImages.cs new file mode 100644 index 0000000000..323c2131c6 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/StillImages.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class StillImages + { + public List stills { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Video.cs b/MediaBrowser.Providers/Tmdb/Models/General/Video.cs new file mode 100644 index 0000000000..746b7f02b1 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Video.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Video + { + public string id { get; set; } + public string iso_639_1 { get; set; } + public string iso_3166_1 { get; set; } + public string key { get; set; } + public string name { get; set; } + public string site { get; set; } + public string size { get; set; } + public string type { get; set; } + } +} diff --git a/MediaBrowser.Providers/Tmdb/Models/General/Videos.cs b/MediaBrowser.Providers/Tmdb/Models/General/Videos.cs new file mode 100644 index 0000000000..64d7d6e623 --- /dev/null +++ b/MediaBrowser.Providers/Tmdb/Models/General/Videos.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Providers.Tmdb.Models.General +{ + public class Videos + { + public List