From 9adbf4e9d8e52ed42619b4413d1eaccaa752b37d Mon Sep 17 00:00:00 2001 From: cvium Date: Thu, 10 Sep 2020 11:05:46 +0200 Subject: [PATCH] Add keywords as tags to series + cleanup --- .../Plugins/Tmdb/Movies/TmdbMovieProvider.cs | 2 +- .../Tmdb/People/TmdbPersonImageProvider.cs | 2 -- .../Plugins/Tmdb/People/TmdbPersonProvider.cs | 4 --- .../Plugins/Tmdb/TV/TmdbEpisodeProvider.cs | 5 ---- .../Tmdb/TV/TmdbSeriesImageProvider.cs | 1 - .../Plugins/Tmdb/TV/TmdbSeriesProvider.cs | 26 ++++++++----------- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs index b736dede1..3984e4953 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs @@ -190,7 +190,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies movie.AddGenre(genre); } - if (movieResult.Keywords.Keywords != null) + if (movieResult.Keywords?.Keywords != null) { for (var i = 0; i < movieResult.Keywords.Keywords.Count; i++) { diff --git a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs index 99e417698..6e5066223 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs @@ -8,13 +8,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Providers; -using MediaBrowser.Model.Serialization; namespace MediaBrowser.Providers.Plugins.Tmdb.People { diff --git a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs index 8c5e8590f..856d985e4 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs @@ -7,14 +7,10 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; -using MediaBrowser.Model.Serialization; -using Microsoft.Extensions.Logging; namespace MediaBrowser.Providers.Plugins.Tmdb.People { diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs index b9d4a895d..55f1ba7dc 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs @@ -8,16 +8,11 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Globalization; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; -using MediaBrowser.Model.Serialization; -using Microsoft.Extensions.Logging; namespace MediaBrowser.Providers.Plugins.Tmdb.TV { diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs index 0b477f75b..122e1d47d 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs index f110785df..7944dfe27 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs @@ -1,28 +1,18 @@ #pragma warning disable CS1591 using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Linq; using System.Net.Http; -using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Globalization; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Providers.Plugins.Tmdb.Movies; -using Microsoft.Extensions.Logging; using TMDbLib.Objects.Find; using TMDbLib.Objects.Search; using TMDbLib.Objects.TvShows; @@ -34,8 +24,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV private readonly IHttpClientFactory _httpClientFactory; private readonly TmdbClientManager _tmdbClientManager; - private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - public TmdbSeriesProvider( IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager) @@ -136,7 +124,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV Overview = series.Overview }; - remoteResult.SetProviderId(MetadataProvider.Tmdb, series.Id.ToString(_usCulture)); + remoteResult.SetProviderId(MetadataProvider.Tmdb, series.Id.ToString(CultureInfo.InvariantCulture)); if (series.ExternalIds != null) { if (!string.IsNullOrEmpty(series.ExternalIds.ImdbId)) @@ -165,7 +153,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV Overview = series.Overview }; - remoteResult.SetProviderId(MetadataProvider.Tmdb, series.Id.ToString(_usCulture)); + remoteResult.SetProviderId(MetadataProvider.Tmdb, series.Id.ToString(CultureInfo.InvariantCulture)); remoteResult.PremiereDate = series.FirstAirDate?.ToUniversalTime(); return remoteResult; @@ -250,7 +238,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV { var series = new Series {Name = seriesResult.Name, OriginalTitle = seriesResult.OriginalName}; - series.SetProviderId(MetadataProvider.Tmdb, seriesResult.Id.ToString(_usCulture)); + series.SetProviderId(MetadataProvider.Tmdb, seriesResult.Id.ToString(CultureInfo.InvariantCulture)); series.CommunityRating = Convert.ToSingle(seriesResult.VoteAverage); @@ -266,6 +254,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV series.Genres = seriesResult.Genres.Select(i => i.Name).ToArray(); } + if (seriesResult.Keywords?.Results != null) + { + for (var i = 0; i < seriesResult.Keywords.Results.Count; i++) + { + series.AddTag(seriesResult.Keywords.Results[i].Name); + } + } + series.HomePageUrl = seriesResult.Homepage; series.RunTimeTicks = seriesResult.EpisodeRunTime.Select(i => TimeSpan.FromMinutes(i).Ticks).FirstOrDefault();