TMDb Lists should be working now :) (#775)

* Remove un-used imports

* Some small update to Net Import
Devin Buhl 8 years ago committed by GitHub
parent 363048e68e
commit 68bf97f52c

@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace NzbDrone.Core.NetImport.CouchPotato
{

@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using FluentValidation.Results;
using NLog;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.PassThePopcorn;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.NetImport.CouchPotato
{

@ -1,22 +1,11 @@
using Newtonsoft.Json;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.Tv;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.NetImport.CouchPotato
{

@ -1,8 +1,5 @@
using NzbDrone.Common.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.NetImport.CouchPotato
{

@ -1,7 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.NetImport.CouchPotato

@ -7,12 +7,8 @@ using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Http.CloudFlare;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
@ -21,16 +17,12 @@ namespace NzbDrone.Core.NetImport
public abstract class HttpNetImportBase<TSettings> : NetImportBase<TSettings>
where TSettings : IProviderConfig, new()
{
protected const int MaxNumResultsPerQuery = 1000;
protected readonly IHttpClient _httpClient;
public override bool Enabled => true;
public bool SupportsPaging => PageSize > 20;
public virtual int PageSize => 20;
public virtual TimeSpan RateLimit => TimeSpan.FromSeconds(2);
public abstract INetImportRequestGenerator GetRequestGenerator();
@ -45,7 +37,6 @@ namespace NzbDrone.Core.NetImport
public override IList<Movie> Fetch()
{
var generator = GetRequestGenerator();
return FetchMovies(generator.GetMovies());
}
@ -61,17 +52,13 @@ namespace NzbDrone.Core.NetImport
for (int i = 0; i < pageableRequestChain.Tiers; i++)
{
var pageableRequests = pageableRequestChain.GetTier(i);
foreach (var pageableRequest in pageableRequests)
{
var pagedReleases = new List<Movie>();
foreach (var request in pageableRequest)
{
url = request.Url.FullUri;
var page = FetchPage(request, parser);
pagedReleases.AddRange(page);
}
@ -107,30 +94,6 @@ namespace NzbDrone.Core.NetImport
_logger.Warn("{0} {1}", this, httpException.Message);
}
}
catch (RequestLimitReachedException)
{
_logger.Warn("API Request Limit reached for {0}", this);
}
catch (ApiKeyException)
{
_logger.Warn("Invalid API Key for {0} {1}", this, url);
}
catch (CloudFlareCaptchaException ex)
{
if (ex.IsExpired)
{
_logger.Error(ex, "Expired CAPTCHA token for {0}, please refresh in indexer settings.", this);
}
else
{
_logger.Error(ex, "CAPTCHA token required for {0}, check indexer settings.", this);
}
}
catch (IndexerException ex)
{
var message = string.Format("{0} - {1}", ex.Message, url);
_logger.Warn(ex, message);
}
catch (Exception feedEx)
{
feedEx.Data.Add("FeedUrl", url);
@ -142,7 +105,7 @@ namespace NzbDrone.Core.NetImport
protected virtual IList<Movie> FetchPage(NetImportRequest request, IParseNetImportResponse parser)
{
var response = FetchIndexerResponse(request);
var response = FetchNetImportResponse(request);
return parser.ParseResponse(response).ToList().Select(m =>
{
@ -153,7 +116,7 @@ namespace NzbDrone.Core.NetImport
}).ToList();
}
protected virtual NetImportResponse FetchIndexerResponse(NetImportRequest request)
protected virtual NetImportResponse FetchNetImportResponse(NetImportRequest request)
{
_logger.Debug("Downloading List " + request.HttpRequest.ToString(false));
@ -185,33 +148,6 @@ namespace NzbDrone.Core.NetImport
return new ValidationFailure(string.Empty, "No results were returned from your list, please check your settings.");
}
}
catch (ApiKeyException)
{
_logger.Warn("List returned result for RSS URL, API Key appears to be invalid");
return new ValidationFailure("ApiKey", "Invalid API Key");
}
catch (RequestLimitReachedException)
{
_logger.Warn("Request limit reached");
}
catch (CloudFlareCaptchaException ex)
{
if (ex.IsExpired)
{
return new ValidationFailure("CaptchaToken", "CloudFlare CAPTCHA token expired, please Refresh.");
}
else
{
return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required.");
}
}
catch (UnsupportedFeedException ex)
{
_logger.Warn(ex, "List feed is not supported");
return new ValidationFailure(string.Empty, "List feed is not supported: " + ex.Message);
}
catch (NetImportException ex)
{
_logger.Warn(ex, "Unable to connect to list");

@ -1,6 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;

@ -1,6 +1,4 @@
using NzbDrone.Core.IndexerSearch.Definitions;
namespace NzbDrone.Core.NetImport
namespace NzbDrone.Core.NetImport
{
public interface INetImportRequestGenerator
{

@ -1,5 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.NetImport

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;

@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv;

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using FluentValidation.Results;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.PassThePopcorn;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.NetImport.RSSImport
{

@ -1,12 +1,10 @@
using Newtonsoft.Json;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.Tv;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
@ -15,7 +13,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.NetImport.RSSImport
{

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.IndexerSearch.Definitions;
namespace NzbDrone.Core.NetImport.RSSImport
{

@ -1,8 +1,4 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Core.NetImport.RSSImport
{

@ -1,8 +1,4 @@
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace NzbDrone.Core.NetImport.StevenLu
namespace NzbDrone.Core.NetImport.StevenLu
{
public class StevenLuResponse
{

@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using FluentValidation.Results;
using NLog;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.PassThePopcorn;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.NetImport.StevenLu
{

@ -1,22 +1,9 @@
using Newtonsoft.Json;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.Tv;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.NetImport.StevenLu
{

@ -1,8 +1,5 @@
using NzbDrone.Common.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.NetImport.StevenLu
{
@ -13,9 +10,7 @@ namespace NzbDrone.Core.NetImport.StevenLu
public virtual NetImportPageableRequestChain GetMovies()
{
var pageableRequests = new NetImportPageableRequestChain();
pageableRequests.Add(GetMovies(null));
return pageableRequests;
}

@ -1,8 +1,4 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Core.NetImport.StevenLu
{

@ -14,13 +14,11 @@ namespace NzbDrone.Core.NetImport.TMDb
public IHttpClient HttpClient { get; set; }
public Logger Logger { get; set; }
//public string TMDbApiUrl { get; set; }
public int MaxPages { get; set; }
public TMDbRequestGenerator()
{
MaxPages = 3;
// TMDbApiUrl = "https://api.themoviedb.org";
}
public virtual NetImportPageableRequestChain GetMovies()
@ -45,7 +43,7 @@ namespace NzbDrone.Core.NetImport.TMDb
switch (Settings.ListType)
{
case (int)TMDbListType.List:
tmdbParams = $"/3/list/{Settings.ListId}/?api_key=1a7373301961d03f97f853a876dd1212";
tmdbParams = $"/3/list/{Settings.ListId}?api_key=1a7373301961d03f97f853a876dd1212";
break;
case (int)TMDbListType.Theaters:
tmdbParams = $"/3/discover/movie?api_key=1a7373301961d03f97f853a876dd1212&primary_release_date.gte={threeMonthsAgo}&primary_release_date.lte={todaysDate}&vote_count.gte={minVoteCount}&vote_average.gte={minVoteAverage}{ceritification}&with_genres={includeGenreIds}&without_genres={excludeGenreIds}&with_original_language={languageCode}";
@ -82,15 +80,15 @@ namespace NzbDrone.Core.NetImport.TMDb
var result = Json.Deserialize<MovieSearchRoot>(response.Content);
// @TODO Prolly some error handling to do here
pageableRequests.Add(GetPagedRequests(tmdbParams, result.total_pages));
pageableRequests.Add(GetMovies(tmdbParams, result.total_pages));
return pageableRequests;
}
pageableRequests.Add(GetPagedRequests(tmdbParams, 0));
pageableRequests.Add(GetMovies(tmdbParams, 0));
return pageableRequests;
}
private IEnumerable<NetImportRequest> GetPagedRequests(string tmdbParams, int totalPages)
private IEnumerable<NetImportRequest> GetMovies(string tmdbParams, int totalPages)
{
var baseUrl = $"{Settings.Link.TrimEnd("/")}{tmdbParams}";
if (Settings.ListType != (int)TMDbListType.List)

@ -22,8 +22,8 @@ namespace NzbDrone.Core.NetImport.TMDb
public TMDbSettings()
{
Link = "https://api.themoviedb.org";
MinVoteAverage = "5.5";
MinVotes = 1000;
MinVoteAverage = "5";
MinVotes = 1;
LanguageCode = (int)TMDbLanguageCodes.en;
}

@ -1,8 +1,4 @@
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace NzbDrone.Core.NetImport.Trakt
namespace NzbDrone.Core.NetImport.Trakt
{
public class Ids
{

@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using FluentValidation.Results;
using NLog;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.PassThePopcorn;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.NetImport.Trakt
{

@ -1,22 +1,9 @@
using Newtonsoft.Json;
using NzbDrone.Core.NetImport.Exceptions;
using NzbDrone.Core.Tv;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.NetImport.Trakt
{

@ -1,8 +1,5 @@
using NzbDrone.Common.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.NetImport.Trakt
{

Loading…
Cancel
Save