From 35e046bb87efdc8e40a31eee18d6546f95e28d3c Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Mon, 13 Mar 2017 22:34:25 -0400 Subject: [PATCH] Patch/onedr0p 3 13 17 (#1166) * Update message when the person has no movies with helpful links * Added ImdbId to the release info from AwesomeHD * Add ImdbId to release info for PTP and HDBits * ImdbId is required for HDBits * Added some error handling in SkyHook for TMDb * Remove un-needed imports * DIsable movie search after list sync (causing issues) * small change * Fix HDBits tests --- src/NzbDrone.Common/Http/HttpAccept.cs | 1 + .../Indexers/HdBits/RecentFeedLongIDs.json | 106 +++++++++--------- .../Indexers/HdBits/RecentFeedStringIDs.json | 106 +++++++++--------- .../Indexers/AwesomeHD/AwesomeHDRssParser.cs | 6 +- .../Indexers/HDBits/HDBitsApi.cs | 2 +- .../Indexers/HDBits/HDBitsInfo.cs | 4 - .../Indexers/HDBits/HDBitsParser.cs | 3 +- .../PassThePopcorn/PassThePopcornParser.cs | 6 +- .../MetadataSource/SkyHook/SkyHookProxy.cs | 26 ++++- .../NetImport/NetImportSearchService.cs | 36 +++--- src/UI/Movies/Index/EmptyTemplate.hbs | 15 +-- 11 files changed, 169 insertions(+), 142 deletions(-) diff --git a/src/NzbDrone.Common/Http/HttpAccept.cs b/src/NzbDrone.Common/Http/HttpAccept.cs index 3da3ee443..40e77b340 100644 --- a/src/NzbDrone.Common/Http/HttpAccept.cs +++ b/src/NzbDrone.Common/Http/HttpAccept.cs @@ -4,6 +4,7 @@ { public static readonly HttpAccept Rss = new HttpAccept("application/rss+xml, text/rss+xml, application/xml, text/xml"); public static readonly HttpAccept Json = new HttpAccept("application/json"); + public static readonly HttpAccept JsonCharset = new HttpAccept("application/json;charset=utf-8"); public static readonly HttpAccept Html = new HttpAccept("text/html"); public string Value { get; private set; } diff --git a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json index 9e4b114f7..4337f732f 100644 --- a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json +++ b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json @@ -1,57 +1,63 @@ { "status": 0, "data": [ - { - "id": 257142, - "hash": "EABC50AEF9F53CEDED84ADF14144D3368E586F3A", - "leechers": 1, - "seeders": 46, - "name": "Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI", - "times_completed": 49, - "size": 1718009717, - "utadded": 1428179446, - "added": "2015-04-04T20:30:46+0000", - "comments": 0, - "numfiles": 1, - "filename": "Supernatural.S10E17.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", - "freeleech": "no", - "type_category": 2, - "type_codec": 1, - "type_medium": 6, - "type_origin": 0, - "username": "abc", - "owner": 1107944, - "tvdb": { - "id": 78901, - "season": 10, - "episode": 17 - } + { + "id": 257142, + "hash": "EABC50AEF9F53CEDED84ADF14144D3368E586F3A", + "leechers": 1, + "seeders": 46, + "name": "Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 49, + "size": 1718009717, + "utadded": 1428179446, + "added": "2015-04-04T20:30:46+0000", + "comments": 0, + "numfiles": 1, + "filename": "Supernatural.S10E17.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 78901, + "season": 10, + "episode": 17 }, - { - "id": 257140, - "hash": "BE3BA5396B9A30544353B55FDD89EDE46C8FB72A", - "leechers": 0, - "seeders": 18, - "name": "Scandal S04E18 1080p WEB-DL DD5.1 H.264-ECI", - "times_completed": 19, - "size": 1789106197, - "utadded": 1428179128, - "added": "2015-04-04T20:25:28+0000", - "comments": 0, - "numfiles": 1, - "filename": "Scandal.2012.S04E18.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", - "freeleech": "no", - "type_category": 2, - "type_codec": 1, - "type_medium": 6, - "type_origin": 0, - "username": "abc", - "owner": 1107944, - "tvdb": { - "id": 248841, - "season": 4, - "episode": 18 - } + "imdb": { + "id": 78901 } + }, + { + "id": 257140, + "hash": "BE3BA5396B9A30544353B55FDD89EDE46C8FB72A", + "leechers": 0, + "seeders": 18, + "name": "Scandal S04E18 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 19, + "size": 1789106197, + "utadded": 1428179128, + "added": "2015-04-04T20:25:28+0000", + "comments": 0, + "numfiles": 1, + "filename": "Scandal.2012.S04E18.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 248841, + "season": 4, + "episode": 18 + }, + "imdb": { + "id": 78901 + } + } ] } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json index 2c533f5c4..97390575a 100644 --- a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json +++ b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json @@ -1,57 +1,63 @@ { "status": 0, "data": [ - { - "id": "257142", - "hash": "EABC50AEF9F53CEDED84ADF14144D3368E586F3A", - "leechers": 1, - "seeders": 46, - "name": "Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI", - "times_completed": 49, - "size": 1718009717, - "utadded": 1428179446, - "added": "2015-04-04T20:30:46+0000", - "comments": 0, - "numfiles": 1, - "filename": "Supernatural.S10E17.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", - "freeleech": "no", - "type_category": 2, - "type_codec": 1, - "type_medium": 6, - "type_origin": 0, - "username": "abc", - "owner": 1107944, - "tvdb": { - "id": 78901, - "season": 10, - "episode": 17 - } + { + "id": "257142", + "hash": "EABC50AEF9F53CEDED84ADF14144D3368E586F3A", + "leechers": 1, + "seeders": 46, + "name": "Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 49, + "size": 1718009717, + "utadded": 1428179446, + "added": "2015-04-04T20:30:46+0000", + "comments": 0, + "numfiles": 1, + "filename": "Supernatural.S10E17.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 78901, + "season": 10, + "episode": 17 }, - { - "id": "257140", - "hash": "BE3BA5396B9A30544353B55FDD89EDE46C8FB72A", - "leechers": 0, - "seeders": 18, - "name": "Scandal S04E18 1080p WEB-DL DD5.1 H.264-ECI", - "times_completed": 19, - "size": 1789106197, - "utadded": 1428179128, - "added": "2015-04-04T20:25:28+0000", - "comments": 0, - "numfiles": 1, - "filename": "Scandal.2012.S04E18.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", - "freeleech": "no", - "type_category": 2, - "type_codec": 1, - "type_medium": 6, - "type_origin": 0, - "username": "abc", - "owner": 1107944, - "tvdb": { - "id": 248841, - "season": 4, - "episode": 18 - } + "imdb": { + "id": 78901 } + }, + { + "id": "257140", + "hash": "BE3BA5396B9A30544353B55FDD89EDE46C8FB72A", + "leechers": 0, + "seeders": 18, + "name": "Scandal S04E18 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 19, + "size": 1789106197, + "utadded": 1428179128, + "added": "2015-04-04T20:25:28+0000", + "comments": 0, + "numfiles": 1, + "filename": "Scandal.2012.S04E18.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 248841, + "season": 4, + "episode": 18 + }, + "imdb": { + "id": 78901 + } + } ] } \ No newline at end of file diff --git a/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRssParser.cs b/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRssParser.cs index 38cc4b496..2c254dd9c 100644 --- a/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRssParser.cs +++ b/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRssParser.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Parser.Model; @@ -64,6 +62,7 @@ namespace NzbDrone.Core.Indexers.AwesomeHD Subtitles = x.Element("subtitles").Value, EncodeStatus = x.Element("encodestatus").Value, Freeleech = x.Element("freeleech").Value, + ImdbId = x.Element("imdb").Value }).ToList(); foreach (var torrent in torrents) @@ -80,7 +79,8 @@ namespace NzbDrone.Core.Indexers.AwesomeHD InfoUrl = GetInfoUrl(torrent.GroupId, id), Seeders = int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), - PublishDate = torrent.Time.ToUniversalTime() + PublishDate = torrent.Time.ToUniversalTime(), + ImdbId = int.Parse(torrent.ImdbId.Substring(2)) }); } } diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs index bf8b2e784..1e6f5f9c1 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Indexers.HDBits public class ImdbInfo { - public int? Id { get; set; } + public int Id { get; set; } public string EnglishTitle { get; set; } public string OriginalTitle { get; set; } public int? Year { get; set; } diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs index 74c866309..b1f6d173a 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs @@ -1,8 +1,4 @@ using NzbDrone.Core.Parser.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace NzbDrone.Core.Indexers.HDBits { diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs index 63be85a7e..4c00a7d32 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs @@ -64,7 +64,8 @@ namespace NzbDrone.Core.Indexers.HDBits Seeders = result.Seeders, Peers = result.Leechers + result.Seeders, PublishDate = result.Added.ToUniversalTime(), - Internal = internalRelease + Internal = internalRelease, + ImdbId = result.ImdbInfo.Id }); } diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs index 1b935a787..dfaf0ab92 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs @@ -81,7 +81,8 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn PublishDate = torrent.UploadTime.ToUniversalTime(), Golden = torrent.GoldenPopcorn, Scene = torrent.Scene, - Approved = torrent.Checked + Approved = torrent.Checked, + ImdbId = int.Parse(result.ImdbId) }); } // Add all torrents @@ -99,7 +100,8 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn PublishDate = torrent.UploadTime.ToUniversalTime(), Golden = torrent.GoldenPopcorn, Scene = torrent.Scene, - Approved = torrent.Checked + Approved = torrent.Checked, + ImdbId = int.Parse(result.ImdbId) }); } // Don't add any torrents diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 296a1aa5c..2dd45a69b 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -84,9 +84,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook .Build(); request.AllowAutoRedirect = true; - request.SuppressHttpError = true; + // request.SuppressHttpError = true; var response = _httpClient.Get(request); + if (response.StatusCode != HttpStatusCode.OK) + { + throw new HttpException(request, response); + } + + if (response.Headers.ContentType != HttpAccept.JsonCharset.Value) + { + throw new HttpException(request, response); + } // The dude abides, so should us, Lets be nice to TMDb // var allowed = int.Parse(response.Headers.GetValues("X-RateLimit-Limit").First()); // get allowed @@ -301,19 +310,28 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return movie; } - public Movie GetMovieInfo(string ImdbId) + public Movie GetMovieInfo(string imdbId) { var request = _movieBuilder.Create() .SetSegment("route", "find") - .SetSegment("id", ImdbId) + .SetSegment("id", imdbId) .SetSegment("secondaryRoute", "") .AddQueryParam("external_source", "imdb_id") .Build(); request.AllowAutoRedirect = true; - request.SuppressHttpError = true; + // request.SuppressHttpError = true; var response = _httpClient.Get(request); + if (response.StatusCode != HttpStatusCode.OK) + { + throw new HttpException(request, response); + } + + if (response.Headers.ContentType != HttpAccept.JsonCharset.Value) + { + throw new HttpException(request, response); + } // The dude abides, so should us, Lets be nice to TMDb // var allowed = int.Parse(response.Headers.GetValues("X-RateLimit-Limit").First()); // get allowed diff --git a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs index 1f49a3f96..6b4682a7c 100644 --- a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs +++ b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs @@ -81,7 +81,7 @@ namespace NzbDrone.Core.NetImport _logger.Debug("Found {0} movies from list(s) {1}", movies.Count, string.Join(", ", lists.Select(l => l.Definition.Name))); - return movies; + return movies.DistinctBy(x => x.TmdbId).ToList(); } @@ -114,29 +114,29 @@ namespace NzbDrone.Core.NetImport // listedMovies = listedMovies.Where(ah => importExclusions.Any(h => ah.TmdbId.ToString() != h)).ToList(); } - var downloadedCount = 0; + //var downloadedCount = 0; foreach (var movie in listedMovies) { var mapped = _movieSearch.MapMovieToTmdbMovie(movie); if (mapped != null && !importExclusions.Any(x => x == mapped.TmdbId.ToString())) { - List decisions; - mapped.AddOptions = new AddMovieOptions {SearchForMovie = true}; + //List decisions; + //mapped.AddOptions = new AddMovieOptions {SearchForMovie = true}; _movieService.AddMovie(mapped); - // Search for movie - try - { - decisions = _nzbSearchService.MovieSearch(mapped.Id, false); - } - catch (Exception ex) - { - _logger.Error(ex, $"Unable to search in list for movie {mapped.Id}"); - continue; - } - - var processed = _processDownloadDecisions.ProcessDecisions(decisions); - downloadedCount += processed.Grabbed.Count; + //// Search for movie + //try + //{ + // decisions = _nzbSearchService.MovieSearch(mapped.Id, false); + //} + //catch (Exception ex) + //{ + // _logger.Error(ex, $"Unable to search in list for movie {mapped.Id}"); + // continue; + //} + + //var processed = _processDownloadDecisions.ProcessDecisions(decisions); + //downloadedCount += processed.Grabbed.Count; } else { @@ -147,7 +147,7 @@ namespace NzbDrone.Core.NetImport } } - _logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount); + //_logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount); } private void CleanLibrary(List movies) diff --git a/src/UI/Movies/Index/EmptyTemplate.hbs b/src/UI/Movies/Index/EmptyTemplate.hbs index 42cb619d2..95bebed3f 100644 --- a/src/UI/Movies/Index/EmptyTemplate.hbs +++ b/src/UI/Movies/Index/EmptyTemplate.hbs @@ -2,15 +2,12 @@
- You must be new around here, You should add some movies. -
-
-
-
- - - Add Movie - +  You must be new around here, before you start adding movies you may want to check out the following links on our wiki: +