* Stylecop Rules and Fixes
This commit is contained in:
Qstick
2020-01-03 07:49:24 -05:00
committed by GitHub
parent 63d669178d
commit f77a2feeef
1307 changed files with 8704 additions and 7404 deletions
@@ -4,11 +4,13 @@ namespace NzbDrone.Core.Indexers.Exceptions
{
public class ApiKeyException : NzbDroneException
{
public ApiKeyException(string message, params object[] args) : base(message, args)
public ApiKeyException(string message, params object[] args)
: base(message, args)
{
}
public ApiKeyException(string message) : base(message)
public ApiKeyException(string message)
: base(message)
{
}
}
@@ -4,7 +4,8 @@ namespace NzbDrone.Core.Indexers.Exceptions
{
public class SizeParsingException : NzbDroneException
{
public SizeParsingException(string message, params object[] args) : base(message, args)
public SizeParsingException(string message, params object[] args)
: base(message, args)
{
}
}
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NLog;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Common.TPL;
using System;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers
{
public interface IFetchAndParseRss
@@ -1,13 +1,11 @@
using System.Collections.Generic;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Indexers.Gazelle
{
@@ -21,8 +19,12 @@ namespace NzbDrone.Core.Indexers.Gazelle
private readonly ICached<Dictionary<string, string>> _authCookieCache;
public Gazelle(IHttpClient httpClient, ICacheManager cacheManager, IIndexerStatusService indexerStatusService,
IConfigService configService, IParsingService parsingService, Logger logger)
public Gazelle(IHttpClient httpClient,
ICacheManager cacheManager,
IIndexerStatusService indexerStatusService,
IConfigService configService,
IParsingService parsingService,
Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
_authCookieCache = cacheManager.GetCache<Dictionary<string, string>>(GetType(), "authCookies");
@@ -51,7 +53,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
yield return GetDefinition("Orpheus Network", GetSettings("https://orpheus.network"));
yield return GetDefinition("REDacted", GetSettings("https://redacted.ch"));
yield return GetDefinition("Not What CD", GetSettings("https://notwhat.cd"));
}
}
@@ -72,7 +72,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
{
public string Status { get; set; }
public GazelleIndexResponse Response { get; set; }
}
public class GazelleIndexResponse
@@ -81,7 +80,5 @@ namespace NzbDrone.Core.Indexers.Gazelle
public string Id { get; set; }
public string Authkey { get; set; }
public string Passkey { get; set; }
}
}
@@ -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.Gazelle
{
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
using System.Linq;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Indexers.Gazelle
{
@@ -47,7 +47,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
return torrentInfos;
}
foreach (var result in jsonResponse.Resource.Response.Results)
{
if (result.Torrents != null)
@@ -62,8 +61,9 @@ namespace NzbDrone.Core.Indexers.Gazelle
{
Guid = string.Format("Gazelle-{0}", id),
Artist = artist,
// Splice Title from info to avoid calling API again for every torrent.
Title = WebUtility.HtmlDecode(result.Artist + " - " + result.GroupName + " (" + result.GroupYear +") [" + torrent.Format + " " + torrent.Encoding + "]"),
Title = WebUtility.HtmlDecode(result.Artist + " - " + result.GroupName + " (" + result.GroupYear + ") [" + torrent.Format + " " + torrent.Encoding + "]"),
Album = album,
Container = torrent.Encoding,
Codec = torrent.Format,
@@ -80,12 +80,12 @@ namespace NzbDrone.Core.Indexers.Gazelle
}
var torr = torrentInfos;
// order by date
return
torrentInfos
.OrderByDescending(o => o.PublishDate)
.ToArray();
}
private string GetDownloadUrl(int torrentId, string authKey, string passKey)
@@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using NzbDrone.Common.Http;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Common.Cache;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.IndexerSearch.Definitions;
namespace NzbDrone.Core.Indexers.Gazelle
{
public class GazelleRequestGenerator : IIndexerRequestGenerator
{
public GazelleSettings Settings { get; set; }
public ICached<Dictionary<string, string>> AuthCookieCache { get; set; }
@@ -37,7 +36,7 @@ namespace NzbDrone.Core.Indexers.Gazelle
public IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria)
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetRequest(string.Format("&artistname={0}",searchCriteria.ArtistQuery)));
pageableRequests.Add(GetRequest(string.Format("&artistname={0}", searchCriteria.ArtistQuery)));
return pageableRequests;
}
@@ -48,7 +47,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
var filter = "";
if (searchParameters == null)
{
}
var request =
@@ -65,7 +63,7 @@ namespace NzbDrone.Core.Indexers.Gazelle
yield return request;
}
private GazelleAuthResponse GetIndex(Dictionary<string,string> cookies)
private GazelleAuthResponse GetIndex(Dictionary<string, string> cookies)
{
var indexRequestBuilder = new HttpRequestBuilder($"{Settings.BaseUrl.Trim().TrimEnd('/')}")
{
@@ -89,7 +87,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
private void Authenticate()
{
var requestBuilder = new HttpRequestBuilder($"{Settings.BaseUrl.Trim().TrimEnd('/')}")
{
LogResponseContent = true
@@ -133,7 +130,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
Settings.AuthKey = index.Response.Authkey;
Settings.PassKey = index.Response.Passkey;
}
}
}
}
@@ -7,7 +7,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Indexers.Newznab;
namespace NzbDrone.Core.Indexers.Headphones
{
@@ -48,7 +47,11 @@ namespace NzbDrone.Core.Indexers.Headphones
{
base.Test(failures);
if (failures.Any()) return;
if (failures.Any())
{
return;
}
failures.AddIfNotNull(TestCapabilities());
}
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Xml;
using System.Xml.Linq;
using NLog;
@@ -142,7 +141,6 @@ namespace NzbDrone.Core.Indexers.Headphones
Id = int.Parse(xmlSubcat.Attribute("id").Value),
Name = xmlSubcat.Attribute("name").Value,
Description = xmlSubcat.Attribute("description") != null ? xmlSubcat.Attribute("description").Value : string.Empty
});
}
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
@@ -35,10 +34,12 @@ namespace NzbDrone.Core.Indexers.Headphones
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.AddTier();
pageableRequests.AddTier();
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search",
NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}+{searchCriteria.AlbumQuery}")));
pageableRequests.Add(GetPagedRequests(MaxPages,
Settings.Categories,
"search",
NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}+{searchCriteria.AlbumQuery}")));
return pageableRequests;
}
@@ -49,7 +50,9 @@ namespace NzbDrone.Core.Indexers.Headphones
pageableRequests.AddTier();
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search",
pageableRequests.Add(GetPagedRequests(MaxPages,
Settings.Categories,
"search",
NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}")));
return pageableRequests;
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Headphones
protected override string GetBasicAuth()
{
return Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{Settings.Username}:{Settings.Password}")); ;
return Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{Settings.Username}:{Settings.Password}"));
}
}
}
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
@@ -12,7 +12,6 @@ using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers
{
@@ -81,7 +80,6 @@ namespace NzbDrone.Core.Indexers
var pageableRequestChain = pageableRequestChainSelector(generator);
var fullyUpdated = false;
ReleaseInfo lastReleaseInfo = null;
if (isRecent)
@@ -112,6 +110,7 @@ namespace NzbDrone.Core.Indexers
fullyUpdated = true;
break;
}
var oldestReleaseDate = page.Select(v => v.PublishDate).Min();
if (oldestReleaseDate < lastReleaseInfo.PublishDate || page.Any(v => v.DownloadUrl == lastReleaseInfo.DownloadUrl))
{
@@ -156,6 +155,7 @@ namespace NzbDrone.Core.Indexers
var gapEnd = ordered.Last().PublishDate;
_logger.Warn("Indexer {0} rss sync didn't cover the period between {1} and {2} UTC. Search may be required.", Definition.Name, gapStart, gapEnd);
}
lastReleaseInfo = ordered.First();
_indexerStatusService.UpdateRssSyncStatus(Definition.Id, lastReleaseInfo);
}
@@ -194,6 +194,7 @@ namespace NzbDrone.Core.Indexers
{
_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
}
_logger.Warn("API Request Limit reached for {0}", this);
}
catch (HttpException ex)
@@ -343,5 +344,4 @@ namespace NzbDrone.Core.Indexers
return null;
}
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ namespace NzbDrone.Core.Indexers
bool SupportsRss { get; }
bool SupportsSearch { get; }
DownloadProtocol Protocol { get; }
IList<ReleaseInfo> FetchRecent();
IList<ReleaseInfo> Fetch(AlbumSearchCriteria searchCriteria);
IList<ReleaseInfo> Fetch(ArtistSearchCriteria searchCriteria);
@@ -1,7 +1,7 @@
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using NLog;
namespace NzbDrone.Core.Indexers.IPTorrents
{
@@ -16,7 +16,6 @@ namespace NzbDrone.Core.Indexers.IPTorrents
public IPTorrents(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
@@ -29,4 +28,4 @@ namespace NzbDrone.Core.Indexers.IPTorrents
return new TorrentRssParser() { ParseSizeInDescription = true };
}
}
}
}
@@ -7,7 +7,7 @@ namespace NzbDrone.Core.Indexers.IPTorrents
public class IPTorrentsRequestGenerator : IIndexerRequestGenerator
{
public IPTorrentsSettings Settings { get; set; }
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
+4 -1
View File
@@ -58,7 +58,10 @@ namespace NzbDrone.Core.Indexers
public virtual ProviderDefinition Definition { get; set; }
public virtual object RequestAction(string action, IDictionary<string, string> query) { return null; }
public virtual object RequestAction(string action, IDictionary<string, string> query)
{
return null;
}
protected TSettings Settings => (TSettings)Definition.Settings;
@@ -27,7 +27,10 @@ namespace NzbDrone.Core.Indexers
public void Add(IEnumerable<IndexerRequest> request)
{
if (request == null) return;
if (request == null)
{
return;
}
_chains.Last().Add(new IndexerPageableRequest(request));
}
@@ -40,9 +43,12 @@ namespace NzbDrone.Core.Indexers
public void AddTier()
{
if (_chains.Last().Count == 0) return;
if (_chains.Last().Count == 0)
{
return;
}
_chains.Add(new List<IndexerPageableRequest>());
}
}
}
}
@@ -2,7 +2,6 @@
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers
{
public interface IIndexerRepository : IProviderRepository<IndexerDefinition>
@@ -14,4 +14,4 @@ namespace NzbDrone.Core.Indexers
IndexerSetting = indexerSetting;
}
}
}
}
@@ -2,7 +2,6 @@ using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider.Status;
namespace NzbDrone.Core.Indexers
{
public interface IIndexerStatusRepository : IProviderStatusRepository<IndexerStatus>
@@ -10,7 +9,6 @@ namespace NzbDrone.Core.Indexers
}
public class IndexerStatusRepository : ProviderStatusRepository<IndexerStatus>, IIndexerStatusRepository
{
public IndexerStatusRepository(IMainDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
@@ -25,7 +25,6 @@ namespace NzbDrone.Core.Indexers
return GetProviderStatus(indexerId).LastRssSyncReleaseInfo;
}
public void UpdateRssSyncStatus(int indexerId, ReleaseInfo releaseInfo)
{
lock (_syncRoot)
+16 -12
View File
@@ -64,17 +64,17 @@ namespace NzbDrone.Core.Indexers.Newznab
private IndexerDefinition GetDefinition(string name, NewznabSettings settings)
{
return new IndexerDefinition
{
EnableRss = false,
EnableAutomaticSearch = false,
EnableInteractiveSearch = false,
Name = name,
Implementation = GetType().Name,
Settings = settings,
Protocol = DownloadProtocol.Usenet,
SupportsRss = SupportsRss,
SupportsSearch = SupportsSearch
};
{
EnableRss = false,
EnableAutomaticSearch = false,
EnableInteractiveSearch = false,
Name = name,
Implementation = GetType().Name,
Settings = settings,
Protocol = DownloadProtocol.Usenet,
SupportsRss = SupportsRss,
SupportsSearch = SupportsSearch
};
}
private NewznabSettings GetSettings(string url, params int[] categories)
@@ -92,7 +92,11 @@ namespace NzbDrone.Core.Indexers.Newznab
protected override void Test(List<ValidationFailure> failures)
{
base.Test(failures);
if (failures.HasErrors()) return;
if (failures.HasErrors())
{
return;
}
failures.AddIfNotNull(TestCapabilities());
}
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Xml;
using System.Xml.Linq;
using NLog;
@@ -160,7 +159,6 @@ namespace NzbDrone.Core.Indexers.Newznab
Id = int.Parse(xmlSubcat.Attribute("id").Value),
Name = xmlSubcat.Attribute("name").Value,
Description = xmlSubcat.Attribute("description") != null ? xmlSubcat.Attribute("description").Value : string.Empty
});
}
@@ -69,7 +69,8 @@ namespace NzbDrone.Core.Indexers.Newznab
if (SupportsAudioSearch)
{
AddAudioPageableRequests(pageableRequests, searchCriteria,
AddAudioPageableRequests(pageableRequests,
searchCriteria,
NewsnabifyTitle($"&artist={searchCriteria.ArtistQuery}&album={searchCriteria.AlbumQuery}"));
}
@@ -77,7 +78,9 @@ namespace NzbDrone.Core.Indexers.Newznab
{
pageableRequests.AddTier();
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search",
pageableRequests.Add(GetPagedRequests(MaxPages,
Settings.Categories,
"search",
NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}+{searchCriteria.AlbumQuery}")));
}
@@ -90,7 +93,8 @@ namespace NzbDrone.Core.Indexers.Newznab
if (SupportsAudioSearch)
{
AddAudioPageableRequests(pageableRequests, searchCriteria,
AddAudioPageableRequests(pageableRequests,
searchCriteria,
NewsnabifyTitle($"&artist={searchCriteria.ArtistQuery}"));
}
@@ -98,7 +102,9 @@ namespace NzbDrone.Core.Indexers.Newznab
{
pageableRequests.AddTier();
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search",
pageableRequests.Add(GetPagedRequests(MaxPages,
Settings.Categories,
"search",
NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}")));
}
@@ -23,7 +23,10 @@ namespace NzbDrone.Core.Indexers.Newznab
var xdoc = LoadXmlDocument(indexerResponse);
var error = xdoc.Descendants("error").FirstOrDefault();
if (error == null) return true;
if (error == null)
{
return true;
}
var code = Convert.ToInt32(error.Attribute("code").Value);
var errorMessage = error.Attribute("description").Value;
@@ -68,10 +71,10 @@ namespace NzbDrone.Core.Indexers.Newznab
protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo)
{
releaseInfo = base.ProcessItem(item, releaseInfo);
releaseInfo.Artist = GetArtist(item);
releaseInfo.Album = GetAlbum(item);
return releaseInfo;
}
@@ -122,7 +125,7 @@ namespace NzbDrone.Core.Indexers.Newznab
return "";
}
protected virtual string GetAlbum(XElement item)
{
var albumString = TryGetNewznabAttribute(item, "album");
@@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
@@ -82,7 +81,6 @@ namespace NzbDrone.Core.Indexers.Newznab
// Field 6 is used by TorznabSettings MinimumSeeders
// If you need to add another field here, update TorznabSettings as well and this comment
public virtual NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
+1 -2
View File
@@ -15,7 +15,6 @@ namespace NzbDrone.Core.Indexers.Nyaa
public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
@@ -28,4 +27,4 @@ namespace NzbDrone.Core.Indexers.Nyaa
return new TorrentRssParser() { UseGuidInfoUrl = true, ParseSizeInDescription = true, ParseSeedersInDescription = true };
}
}
}
}
@@ -1,7 +1,7 @@
using System.Text.RegularExpressions;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Indexers.Nyaa
{
public class NyaaSettingsValidator : AbstractValidator<NyaaSettings>
@@ -14,7 +14,6 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
public Omgwtfnzbs(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
@@ -29,12 +29,10 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}+{1}",
searchCriteria.ArtistQuery,
searchCriteria.AlbumQuery)));
return pageableRequests;
}
@@ -42,11 +40,9 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}",
searchCriteria.ArtistQuery)));
return pageableRequests;
}
@@ -19,9 +19,15 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
var xdoc = LoadXmlDocument(indexerResponse);
var notice = xdoc.Descendants("notice").FirstOrDefault();
if (notice == null) return true;
if (notice == null)
{
return true;
}
if (!notice.Value.ContainsIgnoreCase("api")) return true;
if (!notice.Value.ContainsIgnoreCase("api"))
{
return true;
}
throw new ApiKeyException(notice.Value);
}
@@ -29,8 +35,9 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
protected override string GetInfoUrl(XElement item)
{
//Todo: Me thinks I need to parse details to get this...
var match = Regex.Match(item.Description(), @"(?:\<b\>View NZB\:\<\/b\>\s\<a\shref\=\"")(?<URL>.+)(?:\""\starget)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
var match = Regex.Match(item.Description(),
@"(?:\<b\>View NZB\:\<\/b\>\s\<a\shref\=\"")(?<URL>.+)(?:\""\starget)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
if (match.Success)
{
@@ -40,4 +47,4 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
return string.Empty;
}
}
}
}
@@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
+2 -2
View File
@@ -63,7 +63,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
siteKey = ex.CaptchaRequest.SiteKey,
secretToken = ex.CaptchaRequest.SecretToken,
responseUrl = ex.CaptchaRequest.ResponseUrl.FullUri,
}
}
};
}
@@ -110,4 +110,4 @@ namespace NzbDrone.Core.Indexers.Rarbg
return new { };
}
}
}
}
@@ -22,6 +22,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
{
throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode);
}
break;
}
@@ -75,6 +76,5 @@ namespace NzbDrone.Core.Indexers.Rarbg
return string.Format("rarbg-{0}", torrent.download);
}
}
}
}
@@ -30,7 +30,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
[FieldDefinition(1, Type = FieldType.Checkbox, Label = "Ranked Only", HelpText = "Only include ranked results.")]
public bool RankedOnly { get; set; }
[FieldDefinition(2, Type = FieldType.Captcha, Label = "CAPTCHA Token", HelpText = "CAPTCHA Clearance token used to handle CloudFlare Anti-DDOS measures on shared-ip VPNs.")]
public string CaptchaToken { get; set; }
@@ -27,7 +27,8 @@ namespace NzbDrone.Core.Indexers.Rarbg
public string GetToken(RarbgSettings settings)
{
return _tokenCache.Get(settings.BaseUrl, () =>
return _tokenCache.Get(settings.BaseUrl,
() =>
{
var requestBuilder = new HttpRequestBuilder(settings.BaseUrl.Trim('/'))
.WithRateLimit(3.0)
@@ -43,7 +44,8 @@ namespace NzbDrone.Core.Indexers.Rarbg
var response = _httpClient.Get<JObject>(requestBuilder.Build());
return response.Resource["token"].ToString();
}, TimeSpan.FromMinutes(14.0));
},
TimeSpan.FromMinutes(14.0));
}
}
}
@@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Indexers
{
public class RssEnclosure
@@ -12,7 +12,6 @@ namespace NzbDrone.Core.Indexers
_baseUrl = baseUrl;
}
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
+2 -1
View File
@@ -236,6 +236,7 @@ namespace NzbDrone.Core.Indexers
{
return GetEnclosureLength(item);
}
if (ParseSizeInDescription && item.Element("description") != null)
{
return ParseSize(item.Element("description").Value, true);
@@ -292,7 +293,6 @@ namespace NzbDrone.Core.Indexers
protected virtual RssEnclosure GetEnclosure(RssEnclosure[] enclosures, bool enforceMimeType = true)
{
if (enclosures.Length == 0)
{
return null;
@@ -399,6 +399,7 @@ namespace NzbDrone.Core.Indexers
return (long)value;
}
}
return 0;
}
+1 -2
View File
@@ -4,7 +4,6 @@ namespace NzbDrone.Core.Indexers
{
public class RssSyncCommand : Command
{
public override bool SendUpdatesToClient => true;
}
}
}
@@ -39,7 +39,6 @@ namespace NzbDrone.Core.Indexers
_logger = logger;
}
private ProcessedDecisions Sync()
{
_logger.ProgressInfo("Starting RSS Sync");
@@ -1,9 +1,6 @@
using System;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
@@ -39,7 +35,7 @@ namespace NzbDrone.Core.Indexers
.AsWarning()
.WithMessage($"Under {seedTimeMinimum} leads to H&R");
}
if (discographySeedTimeMinimum != 0)
{
RuleFor(c => c.DiscographySeedTime).GreaterThanOrEqualTo(discographySeedTimeMinimum)
@@ -8,7 +8,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
public class TorrentRssIndexerRequestGenerator : IIndexerRequestGenerator
{
public TorrentRssIndexerSettings Settings { get; set; }
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
public class TorrentRssIndexerSettings : ITorrentIndexerSettings
{
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator();
private static readonly TorrentRssIndexerSettingsValidator Validator = new TorrentRssIndexerSettingsValidator();
public TorrentRssIndexerSettings()
{
@@ -31,7 +31,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
[FieldDefinition(1, Label = "Cookie", HelpText = "If you site requires a login cookie to access the rss, you'll have to retrieve it via a browser.")]
public string Cookie { get; set; }
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Allow Zero Size", HelpText="Enabling this will allow you to use feeds that don't specify release size, but be careful, size related checks will not be performed.")]
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Allow Zero Size", HelpText = "Enabling this will allow you to use feeds that don't specify release size, but be careful, size related checks will not be performed.")]
public bool AllowZeroSize { get; set; }
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
@@ -45,7 +45,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(validator.Validate(this));
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}
@@ -14,7 +14,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
public class TorrentRssParserFactory : ITorrentRssParserFactory
{
protected readonly Logger _logger;
private readonly ICached<TorrentRssIndexerParserSettings> _settingsCache;
private readonly ITorrentRssSettingsDetector _torrentRssSettingsDetector;
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using NLog;
@@ -19,12 +18,12 @@ namespace NzbDrone.Core.Indexers.TorrentRss
public class TorrentRssSettingsDetector : ITorrentRssSettingsDetector
{
private const long ValidSizeThreshold = 2 * 1024 * 1024;
protected readonly Logger _logger;
private readonly IHttpClient _httpClient;
private const long ValidSizeThreshold = 2 * 1024 * 1024;
public TorrentRssSettingsDetector(IHttpClient httpClient, Logger logger)
{
_httpClient = httpClient;
@@ -148,7 +147,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
_logger.Trace("Feed doesn't have Seeders in Description, disabling option.");
parser.ParseSeedersInDescription = settings.ParseSeedersInDescription = false;
}
if (!releases.Any(r => r.Size < ValidSizeThreshold))
{
_logger.Trace("Feed has valid size in enclosure.");
@@ -183,6 +182,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
{
_logger.Debug("Feed {0} contains very small releases.", response.Request.Url);
}
_logger.Trace("Feed has valid size in description.");
return settings;
}
@@ -244,7 +244,6 @@ namespace NzbDrone.Core.Indexers.TorrentRss
{
var releases = parser.ParseResponse(response).Cast<TorrentInfo>().ToArray();
return releases;
}
catch (Exception ex)
{
@@ -279,7 +278,6 @@ namespace NzbDrone.Core.Indexers.TorrentRss
if (distinct.Length != total.Length)
{
throw new UnsupportedFeedException("Feed contains releases with same guid, rejecting malformed rss feed.");
}
}
@@ -1,7 +1,7 @@
using NzbDrone.Common.Http;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using NLog;
namespace NzbDrone.Core.Indexers.Torrentleech
{
@@ -16,7 +16,6 @@ namespace NzbDrone.Core.Indexers.Torrentleech
public Torrentleech(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
@@ -7,7 +7,7 @@ namespace NzbDrone.Core.Indexers.Torrentleech
public class TorrentleechRequestGenerator : IIndexerRequestGenerator
{
public TorrentleechSettings Settings { get; set; }
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
+16 -13
View File
@@ -8,7 +8,6 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Torznab
@@ -45,17 +44,17 @@ namespace NzbDrone.Core.Indexers.Torznab
private IndexerDefinition GetDefinition(string name, TorznabSettings settings)
{
return new IndexerDefinition
{
EnableRss = false,
EnableAutomaticSearch = false,
EnableInteractiveSearch = false,
Name = name,
Implementation = GetType().Name,
Settings = settings,
Protocol = DownloadProtocol.Usenet,
SupportsRss = SupportsRss,
SupportsSearch = SupportsSearch
};
{
EnableRss = false,
EnableAutomaticSearch = false,
EnableInteractiveSearch = false,
Name = name,
Implementation = GetType().Name,
Settings = settings,
Protocol = DownloadProtocol.Usenet,
SupportsRss = SupportsRss,
SupportsSearch = SupportsSearch
};
}
private TorznabSettings GetSettings(string url, params int[] categories)
@@ -73,7 +72,11 @@ namespace NzbDrone.Core.Indexers.Torznab
protected override void Test(List<ValidationFailure> failures)
{
base.Test(failures);
if (failures.HasErrors()) return;
if (failures.HasErrors())
{
return;
}
failures.AddIfNotNull(TestCapabilities());
}
@@ -4,11 +4,13 @@ namespace NzbDrone.Core.Indexers.Torznab
{
public class TorznabException : NzbDroneException
{
public TorznabException(string message, params object[] args) : base(message, args)
public TorznabException(string message, params object[] args)
: base(message, args)
{
}
public TorznabException(string message) : base(message)
public TorznabException(string message)
: base(message)
{
}
}
@@ -22,12 +22,18 @@ namespace NzbDrone.Core.Indexers.Torznab
var xdoc = LoadXmlDocument(indexerResponse);
var error = xdoc.Descendants("error").FirstOrDefault();
if (error == null) return true;
if (error == null)
{
return true;
}
var code = Convert.ToInt32(error.Attribute("code").Value);
var errorMessage = error.Attribute("description").Value;
if (code >= 100 && code <= 199) throw new ApiKeyException("Invalid API key");
if (code >= 100 && code <= 199)
{
throw new ApiKeyException("Invalid API key");
}
if (!indexerResponse.Request.Url.FullUri.Contains("apikey=") && errorMessage == "Missing parameter")
{
@@ -60,7 +66,6 @@ namespace NzbDrone.Core.Indexers.Torznab
return true;
}
protected override string GetInfoUrl(XElement item)
{
return ParseUrl(item.TryGetValue("comments").TrimEnd("#comments"));
@@ -1,7 +1,6 @@
using System.Linq;
using System.Text.RegularExpressions;
using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers.Newznab;
@@ -1,6 +1,6 @@
using NzbDrone.Common.Http;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NLog;
using NzbDrone.Core.Parser;
namespace NzbDrone.Core.Indexers.Waffles
@@ -15,7 +15,6 @@ namespace NzbDrone.Core.Indexers.Waffles
public Waffles(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger)
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
@@ -28,4 +27,4 @@ namespace NzbDrone.Core.Indexers.Waffles
return new WafflesRssParser() { ParseSizeInDescription = true, ParseSeedersInDescription = true };
}
}
}
}
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Text;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using System.Text;
using System;
using NzbDrone.Core.IndexerSearch.Definitions;
namespace NzbDrone.Core.Indexers.Waffles
@@ -30,7 +29,7 @@ namespace NzbDrone.Core.Indexers.Waffles
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(MaxPages, string.Format("&q=artist:{0} album:{1}",searchCriteria.ArtistQuery,searchCriteria.AlbumQuery)));
pageableRequests.Add(GetPagedRequests(MaxPages, string.Format("&q=artist:{0} album:{1}", searchCriteria.ArtistQuery, searchCriteria.AlbumQuery)));
return pageableRequests;
}
@@ -45,10 +44,9 @@ namespace NzbDrone.Core.Indexers.Waffles
}
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string query)
{
{
var url = new StringBuilder();
url.AppendFormat("{0}/browse.php?rss=1&c0=1&uid={1}&passkey={2}", Settings.BaseUrl.Trim().TrimEnd('/'), Settings.UserId, Settings.RssPasskey);
if (query.IsNotNullOrWhiteSpace())
@@ -1,16 +1,15 @@
using System;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Waffles
{
public class WafflesRssParser : TorrentRssParser
public class WafflesRssParser : TorrentRssParser
{
public const string ns = "{http://purl.org/rss/1.0/}";
public const string dc = "{http://purl.org/dc/elements/1.1/}";
@@ -20,12 +19,18 @@ namespace NzbDrone.Core.Indexers.Waffles
var xdoc = LoadXmlDocument(indexerResponse);
var error = xdoc.Descendants("error").FirstOrDefault();
if (error == null) return true;
if (error == null)
{
return true;
}
var code = Convert.ToInt32(error.Attribute("code").Value);
var errorMessage = error.Attribute("description").Value;
if (code >= 100 && code <= 199) throw new ApiKeyException("Invalid Pass key");
if (code >= 100 && code <= 199)
{
throw new ApiKeyException("Invalid Pass key");
}
if (!indexerResponse.Request.Url.FullUri.Contains("passkey=") && errorMessage == "Missing parameter")
{
@@ -57,8 +62,8 @@ namespace NzbDrone.Core.Indexers.Waffles
return ParseUrl(item.TryGetValue("comments"));
}
private static readonly Regex ParseSizeRegex = new Regex(@"(?:Size: )(?<value>\d+)<",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex ParseSizeRegex = new Regex(@"(?:Size: )(?<value>\d+)<",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
protected override long GetSize(XElement item)
{
@@ -1,4 +1,3 @@
using System.Text.RegularExpressions;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
@@ -43,7 +42,6 @@ namespace NzbDrone.Core.Indexers.Waffles
[FieldDefinition(5, Type = FieldType.Number, Label = "Early Download Limit", Unit = "days", HelpText = "Time before release date Lidarr will download from this indexer, empty is no limit", Advanced = true)]
public int? EarlyReleaseLimit { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
@@ -27,8 +27,7 @@ namespace NzbDrone.Core.Indexers
root.Name.LocalName,
root.HasElements ?
root.Elements().Select(StripNameSpace) :
(object)root.Value
);
(object)root.Value);
res.ReplaceAttributes(
root.Attributes().Where(attr => (!attr.IsNamespaceDeclaration)));
@@ -46,6 +45,7 @@ namespace NzbDrone.Core.Indexers
dateString = RemoveTimeZoneRegex.Replace(dateString, "");
result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal);
}
return result.ToUniversalTime();
}
catch (FormatException e)
@@ -109,7 +109,6 @@ namespace NzbDrone.Core.Indexers
{
return (T)Convert.ChangeType(element.Value, typeof(T));
}
catch (InvalidCastException)
{
return defaultValue;
+1 -3
View File
@@ -1,12 +1,10 @@
using System.Globalization;
using System.Net;
using System.Net;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Indexers
{
public static class XmlCleaner
{
private static readonly Regex ReplaceEntitiesRegex = new Regex("&[a-z]+;", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ReplaceUnicodeRegex = new Regex(@"[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]", RegexOptions.Compiled | RegexOptions.IgnoreCase);