diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 6f39189f5..09081fae9 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -60,9 +60,9 @@ public HashSet GetChangedMovies(DateTime startTime) request.AllowAutoRedirect = true; request.SuppressHttpError = true; - var response = _httpClient.Get(request); + var response = _httpClient.Get(request); - return new HashSet(response.Resource.Results.Select(c => c.id)); + return new HashSet(response.Resource.Results.Select(c => c.Id)); } public async Task>> GetMovieInfoAsync(int tmdbId) diff --git a/src/NzbDrone.Core/NetImport/RadarrList/RadarrListParser.cs b/src/NzbDrone.Core/NetImport/RadarrList/RadarrListParser.cs index a873aa071..0f12f2510 100644 --- a/src/NzbDrone.Core/NetImport/RadarrList/RadarrListParser.cs +++ b/src/NzbDrone.Core/NetImport/RadarrList/RadarrListParser.cs @@ -24,7 +24,7 @@ public IList ParseResponse(NetImportResponse netMovieImporterResponse) return movies; } - var jsonResponse = JsonConvert.DeserializeObject>(importResponse.Content); + var jsonResponse = JsonConvert.DeserializeObject>(importResponse.Content); // no movies were return if (jsonResponse == null) @@ -32,7 +32,7 @@ public IList ParseResponse(NetImportResponse netMovieImporterResponse) return movies; } - return jsonResponse.SelectList(m => new Movie { TmdbId = m.id }); + return jsonResponse.SelectList(m => new Movie { TmdbId = m.Id }); } protected virtual bool PreProcess(NetImportResponse netImportResponse) diff --git a/src/NzbDrone.Core/NetImport/TMDb/Collection/TMDbCollectionParser.cs b/src/NzbDrone.Core/NetImport/TMDb/Collection/TMDbCollectionParser.cs index 22a58d74b..6ca163f9a 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/Collection/TMDbCollectionParser.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/Collection/TMDbCollectionParser.cs @@ -17,7 +17,7 @@ public override IList ParseResponse(NetImportResponse importResponse) return movies; } - var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); + var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); // no movies were return if (jsonResponse == null) @@ -25,10 +25,10 @@ public override IList ParseResponse(NetImportResponse importResponse) return movies; } - foreach (var movie in jsonResponse.parts) + foreach (var movie in jsonResponse.Parts) { // Movies with no Year Fix - if (string.IsNullOrWhiteSpace(movie.release_date)) + if (string.IsNullOrWhiteSpace(movie.ReleaseDate)) { continue; } diff --git a/src/NzbDrone.Core/NetImport/TMDb/List/TMDbListParser.cs b/src/NzbDrone.Core/NetImport/TMDb/List/TMDbListParser.cs index 56dace7d2..89c114c8e 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/List/TMDbListParser.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/List/TMDbListParser.cs @@ -17,7 +17,7 @@ public override IList ParseResponse(NetImportResponse importResponse) return movies; } - var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); + var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); // no movies were return if (jsonResponse == null) @@ -25,10 +25,10 @@ public override IList ParseResponse(NetImportResponse importResponse) return movies; } - foreach (var movie in jsonResponse.items) + foreach (var movie in jsonResponse.Items) { // Movies with no Year Fix - if (string.IsNullOrWhiteSpace(movie.release_date)) + if (string.IsNullOrWhiteSpace(movie.ReleaseDate)) { continue; } diff --git a/src/NzbDrone.Core/NetImport/TMDb/Person/TMDbPersonParser.cs b/src/NzbDrone.Core/NetImport/TMDb/Person/TMDbPersonParser.cs index e7176b23e..4f44aa407 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/Person/TMDbPersonParser.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/Person/TMDbPersonParser.cs @@ -24,7 +24,7 @@ public override IList ParseResponse(NetImportResponse importResponse) return movies; } - var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); + var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); // no movies were return if (jsonResponse == null) @@ -36,31 +36,31 @@ public override IList ParseResponse(NetImportResponse importResponse) if (_settings.PersonCast) { - foreach (var movie in jsonResponse.cast) + foreach (var movie in jsonResponse.Cast) { // Movies with no Year Fix - if (string.IsNullOrWhiteSpace(movie.release_date)) + if (string.IsNullOrWhiteSpace(movie.ReleaseDate)) { continue; } - movies.AddIfNotNull(new Movie { TmdbId = movie.id }); + movies.AddIfNotNull(new Movie { TmdbId = movie.Id }); } } if (crewTypes.Count > 0) { - foreach (var movie in jsonResponse.crew) + foreach (var movie in jsonResponse.Crew) { // Movies with no Year Fix - if (string.IsNullOrWhiteSpace(movie.release_date)) + if (string.IsNullOrWhiteSpace(movie.ReleaseDate)) { continue; } - if (crewTypes.Contains(movie.department)) + if (crewTypes.Contains(movie.Department)) { - movies.AddIfNotNull(new Movie { TmdbId = movie.id }); + movies.AddIfNotNull(new Movie { TmdbId = movie.Id }); } } } diff --git a/src/NzbDrone.Core/NetImport/TMDb/TMDBResources.cs b/src/NzbDrone.Core/NetImport/TMDb/TMDBResources.cs index ffc557f14..8cbf37427 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/TMDBResources.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/TMDBResources.cs @@ -1,86 +1,133 @@ +using Newtonsoft.Json; + namespace NzbDrone.Core.NetImport.TMDb { - public class MovieSearchRoot + public class MovieSearchResource { public int Page { get; set; } - public MovieResult[] Results { get; set; } - public int total_results { get; set; } - public int total_pages { get; set; } + public MovieResultResource[] Results { get; set; } + + [JsonProperty("total_results")] + public int TotalResults { get; set; } + + [JsonProperty("total_pages")] + public int TotalPages { get; set; } } - public class AuthRefreshTokenResponse + public class AuthRefreshTokenResource { - public string request_token { get; set; } + [JsonProperty("request_token")] + public string RequestToken { get; set; } } - public class AuthAccessTokenResponse + public class AuthAccessTokenResource { - public string access_token { get; set; } - public string account_id { get; set; } + [JsonProperty("access_token")] + public string AccessToken { get; set; } + + [JsonProperty("account_id")] + public string AccountId { get; set; } } - public class MovieResult + public class MovieResultResource { - public string poster_path { get; set; } - public bool adult { get; set; } - public string overview { get; set; } - public string release_date { get; set; } - public int?[] genre_ids { get; set; } - public int id { get; set; } - public string original_title { get; set; } - public string original_language { get; set; } - public string title { get; set; } - public string backdrop_path { get; set; } - public float popularity { get; set; } - public int vote_count { get; set; } - public bool video { get; set; } - public float vote_average { get; set; } - public string trailer_key { get; set; } - public string trailer_site { get; set; } - public string physical_release { get; set; } - public string physical_release_note { get; set; } + [JsonProperty("poster_path")] + public string PosterPath { get; set; } + public bool Adult { get; set; } + public string Overview { get; set; } + + [JsonProperty("release_date")] + public string ReleaseDate { get; set; } + + [JsonProperty("genre_ids")] + public int?[] GenreIds { get; set; } + public int Id { get; set; } + + [JsonProperty("original_title")] + public string OriginalTitle { get; set; } + + [JsonProperty("original_language")] + public string OriginalLanguage { get; set; } + public string Title { get; set; } + + [JsonProperty("backdrop_path")] + public string BackdropPath { get; set; } + public float Popularity { get; set; } + + [JsonProperty("vote_count")] + public int VoteCount { get; set; } + public bool Video { get; set; } + + [JsonProperty("vote_average")] + public float VoteAverage { get; set; } + + [JsonProperty("trailer_key")] + public string TrailerKey { get; set; } + + [JsonProperty("trailer_site")] + public string TrailerSite { get; set; } + + [JsonProperty("physical_release")] + public string PhysicalRelease { get; set; } + + [JsonProperty("physical_release_note")] + public string PhysicalReleaseNote { get; set; } } - public class CreditsResult : MovieResult + public class CreditsResultResource : MovieResultResource { - public string department { get; set; } - public string job { get; set; } - public string credit_id { get; set; } + public string Department { get; set; } + public string Job { get; set; } + + [JsonProperty("credit_id")] + public string CreditId { get; set; } } - public class ListResponseRoot + public class ListResponseResource { - public string id { get; set; } - public Item[] items { get; set; } - public int item_count { get; set; } - public string iso_639_1 { get; set; } - public string name { get; set; } - public object poster_path { get; set; } + public string Id { get; set; } + public ListItemResource[] Items { get; set; } + + [JsonProperty("item_count")] + public int ItemCount { get; set; } + + [JsonProperty("iso_639_1")] + public string Iso639 { get; set; } + public string Name { get; set; } + + [JsonProperty("poster_path")] + public object PosterPath { get; set; } } - public class CollectionResponseRoot + public class CollectionResponseResource { - 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 MovieResult[] parts { get; set; } + public int Id { get; set; } + public string Name { get; set; } + public string Overview { get; set; } + + [JsonProperty("poster_path")] + public string PosterPath { get; set; } + + [JsonProperty("backdrop_path")] + public string BackdropPath { get; set; } + public MovieResultResource[] Parts { get; set; } } - public class PersonCreditsRoot + public class PersonCreditsResource { - public CreditsResult[] cast { get; set; } - public CreditsResult[] crew { get; set; } - public int id { get; set; } + public CreditsResultResource[] Cast { get; set; } + public CreditsResultResource[] Crew { get; set; } + public int Id { get; set; } } - public class Item : MovieResult + public class ListItemResource : MovieResultResource { - public string media_type { get; set; } - public string first_air_date { get; set; } - public string[] origin_country { get; set; } - public string name { get; set; } - public string original_name { get; set; } + [JsonProperty("media_type")] + public string MediaType { get; set; } + [JsonProperty("origin_country")] + public string[] OriginCountry { get; set; } + public string Name { get; set; } + [JsonProperty("original_name")] + public string OriginalName { get; set; } } } diff --git a/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs b/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs index bead01687..339afa587 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs @@ -22,7 +22,7 @@ public virtual IList ParseResponse(NetImportResponse importResponse) return movies; } - var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); + var jsonResponse = JsonConvert.DeserializeObject(importResponse.Content); // no movies were return if (jsonResponse == null) @@ -33,24 +33,24 @@ public virtual IList ParseResponse(NetImportResponse importResponse) return jsonResponse.Results.SelectList(MapListMovie); } - protected Movie MapListMovie(MovieResult movieResult) + protected Movie MapListMovie(MovieResultResource movieResult) { var movie = new Movie { - TmdbId = movieResult.id, - Overview = movieResult.overview, - Title = movieResult.original_title, - SortTitle = Parser.Parser.NormalizeTitle(movieResult.original_title), + TmdbId = movieResult.Id, + Overview = movieResult.Overview, + Title = movieResult.OriginalTitle, + SortTitle = Parser.Parser.NormalizeTitle(movieResult.OriginalTitle), Images = new List() }; - if (movieResult.release_date.IsNotNullOrWhiteSpace()) + if (movieResult.ReleaseDate.IsNotNullOrWhiteSpace()) { - DateTime.TryParse(movieResult.release_date, out var releaseDate); + DateTime.TryParse(movieResult.ReleaseDate, out var releaseDate); movie.Year = releaseDate.Year; } - movie.Images.AddIfNotNull(MapPosterImage(movieResult.poster_path)); + movie.Images.AddIfNotNull(MapPosterImage(movieResult.PosterPath)); return movie; } diff --git a/src/NzbDrone.Core/NetImport/TMDb/User/TMDbUserImport.cs b/src/NzbDrone.Core/NetImport/TMDb/User/TMDbUserImport.cs index 862580008..ba5509394 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/User/TMDbUserImport.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/User/TMDbUserImport.cs @@ -56,16 +56,16 @@ public override object RequestAction(string action, IDictionary var request = requestBuilder.Build(); - var response = Json.Deserialize(_httpClient.Execute(request).Content); + var response = Json.Deserialize(_httpClient.Execute(request).Content); var oAuthRequest = new HttpRequestBuilder(Settings.OAuthUrl) - .AddQueryParam("request_token", response.request_token) + .AddQueryParam("request_token", response.RequestToken) .Build(); return new { OauthUrl = oAuthRequest.Url.ToString(), - RequestToken = response.request_token + RequestToken = response.RequestToken }; } else if (action == "getOAuthToken") @@ -81,12 +81,12 @@ public override object RequestAction(string action, IDictionary var request = requestBuilder.Build(); - var response = Json.Deserialize(_httpClient.Execute(request).Content); + var response = Json.Deserialize(_httpClient.Execute(request).Content); return new { - accountId = response.account_id, - accessToken = response.access_token, + accountId = response.AccountId, + accessToken = response.AccessToken, }; }