1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

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
This commit is contained in:
Devin Buhl 2017-03-13 22:34:25 -04:00 committed by GitHub
parent 8ece7e8b4d
commit 35e046bb87
11 changed files with 168 additions and 141 deletions

View File

@ -4,6 +4,7 @@ public sealed class HttpAccept
{
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; }

View File

@ -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
}
}
]
}

View File

@ -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
}
}
]
}

View File

@ -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 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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))
});
}
}

View File

@ -101,7 +101,7 @@ public class TorrentQueryResponse
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; }

View File

@ -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
{

View File

@ -64,7 +64,8 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
Seeders = result.Seeders,
Peers = result.Leechers + result.Seeders,
PublishDate = result.Added.ToUniversalTime(),
Internal = internalRelease
Internal = internalRelease,
ImdbId = result.ImdbInfo.Id
});
}

View File

@ -81,7 +81,8 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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

View File

@ -84,9 +84,18 @@ public Movie GetMovieInfo(int TmdbId, Profile profile = null, bool hasPreDBEntry
.Build();
request.AllowAutoRedirect = true;
request.SuppressHttpError = true;
// request.SuppressHttpError = true;
var response = _httpClient.Get<MovieResourceRoot>(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 @@ public Movie GetMovieInfo(int TmdbId, Profile profile = null, bool hasPreDBEntry
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<FindRoot>(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

View File

@ -81,7 +81,7 @@ public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
_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 @@ public void Execute(NetImportSyncCommand message)
// 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<DownloadDecision> decisions;
mapped.AddOptions = new AddMovieOptions {SearchForMovie = true};
//List<DownloadDecision> 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;
}
//// 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;
//var processed = _processDownloadDecisions.ProcessDecisions(decisions);
//downloadedCount += processed.Grabbed.Count;
}
else
{
@ -147,7 +147,7 @@ public void Execute(NetImportSyncCommand message)
}
}
_logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount);
//_logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount);
}
private void CleanLibrary(List<Movie> movies)

View File

@ -2,15 +2,12 @@
<div class="row">
<div class="well col-md-12">
<i class="icon-sonarr-comment"/>
You must be new around here, You should add some movies.
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<a href="/addmovies" class='btn btn-lg btn-block btn-success x-add-movies'>
<i class='icon-sonarr-add'></i>
Add Movie
</a>
&nbsp;You must be new around here, before you start adding movies you may want to check out the following links on our <a href="https://github.com/Radarr/Radarr/wiki">wiki</a>:
<ul>
<li><a href="https://github.com/Radarr/Radarr/wiki/Setup-Guide">Our setup guide</a></li>
<li><a href="https://github.com/Radarr/Radarr/wiki/Common-Problems">Common Problems</a></li>
<li><a href="https://github.com/Radarr/Radarr/wiki/FAQ">FAQ</a></li>
</ul>
</div>
</div>
</div>