1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2025-03-09 05:16:55 +00:00

core: code cleanup (#9908)

This commit is contained in:
Diego Heras 2020-10-19 22:50:19 +02:00 committed by GitHub
parent 74d08c937f
commit 1d6980c0e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 23 additions and 37 deletions

View file

@ -21,7 +21,7 @@ using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using WebRequest = Jackett.Common.Utils.Clients.WebRequest;
using WebClient = Jackett.Common.Utils.Clients.WebClient;
namespace Jackett.Common.Indexers
{
@ -48,10 +48,10 @@ namespace Jackett.Common.Indexers
private ConfigurationDataAbnormal ConfigData
{
get => (ConfigurationDataAbnormal)configData;
set => base.configData = value;
set => configData = value;
}
public Abnormal(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps)
public Abnormal(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
: base(id: "abnormal",
name: "Abnormal",
description: "General French Private Tracker",

View file

@ -14,7 +14,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
@ -162,13 +161,13 @@ namespace Jackett.Common.Indexers
var response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
// Check for DDOS Guard
if (response.Status == System.Net.HttpStatusCode.Forbidden)
if (response.Status == HttpStatusCode.Forbidden)
{
await ConfigureDDoSGuardCookie();
response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
}
if (response.Status != System.Net.HttpStatusCode.OK)
if (response.Status != HttpStatusCode.OK)
throw new WebException($"Anidex search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
// Search seems to have been a success so parse it
@ -224,7 +223,7 @@ namespace Jackett.Common.Indexers
{
const string ddosPostUrl = "https://check.ddos-guard.net/check.js";
var response = await RequestWithCookiesAsync(ddosPostUrl, string.Empty);
if (response.Status != System.Net.HttpStatusCode.OK)
if (response.Status != HttpStatusCode.OK)
throw new WebException($"Unexpected DDOS Guard response: Status: {response.Status}", WebExceptionStatus.ProtocolError);
if (response.IsRedirect)
throw new WebException($"Unexpected DDOS Guard response: Redirect: {response.RedirectingTo}", WebExceptionStatus.UnknownError);

View file

@ -12,7 +12,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig.Bespoke;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -10,7 +10,6 @@ using System.Threading.Tasks;
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Models.IndexerConfig.Bespoke;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils.Clients;

View file

@ -459,7 +459,7 @@ namespace Jackett.Common.Indexers
protected async Task<WebResult> RequestLoginAndFollowRedirect(string url, IEnumerable<KeyValuePair<string, string>> data, string cookies, bool returnCookiesFromFirstCall, string redirectUrlOverride = null, string referer = null, bool accumulateCookies = false)
{
var request = new Utils.Clients.WebRequest()
var request = new WebRequest()
{
Url = url,
Type = RequestType.POST,

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;

View file

@ -150,7 +150,7 @@ namespace Jackett.Common.Indexers
{
//var json = JArray.Parse(results.Content);
dynamic json = JsonConvert.DeserializeObject<dynamic>(results.ContentString);
foreach (var row in json ?? System.Linq.Enumerable.Empty<dynamic>())
foreach (var row in json ?? Enumerable.Empty<dynamic>())
{
var release = new ReleaseInfo();
var descriptions = new List<string>();

View file

@ -9,7 +9,6 @@ using AngleSharp.Html.Parser;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -36,7 +36,7 @@ namespace Jackett.Common.Indexers
set => base.configData = value;
}
public Fuzer(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps)
public Fuzer(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
: base(id: "fuzer",
name: "Fuzer",
description: "Fuzer is a private torrent website with israeli torrents.",

View file

@ -11,7 +11,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -15,7 +15,6 @@ using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
namespace Jackett.Common.Indexers
{

View file

@ -42,7 +42,7 @@ namespace Jackett.Common.Indexers
private ConfigurationDataNorbits ConfigData => (ConfigurationDataNorbits)configData;
public NorBits(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps)
public NorBits(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
: base(id: "norbits",
name: "NorBits",
description: "NorBits is a Norwegian Private site for MOVIES / TV / GENERAL",
@ -134,7 +134,7 @@ namespace Jackett.Common.Indexers
private async Task DoLogin()
{
// Build WebRequest for index
var myIndexRequest = new Utils.Clients.WebRequest()
var myIndexRequest = new WebRequest()
{
Type = RequestType.GET,
Url = SiteLink,
@ -153,7 +153,7 @@ namespace Jackett.Common.Indexers
};
// Build WebRequest for login
var myRequestLogin = new Utils.Clients.WebRequest()
var myRequestLogin = new WebRequest()
{
Type = RequestType.GET,
Url = LoginUrl,
@ -169,7 +169,7 @@ namespace Jackett.Common.Indexers
await webclient.GetResultAsync(myRequestLogin);
// Build WebRequest for submitting authentification
var request = new Utils.Clients.WebRequest()
var request = new WebRequest()
{
PostData = pairs,
Referer = LoginUrl,
@ -504,11 +504,11 @@ namespace Jackett.Common.Indexers
var file = Directory + request.GetHashCode() + ".json";
// Checking modes states
if (System.IO.File.Exists(file))
if (File.Exists(file))
{
// File exist... loading it right now !
Output("Loading results from hard drive cache ..." + request.GetHashCode() + ".json");
results = JsonConvert.DeserializeObject<WebResult>(System.IO.File.ReadAllText(file));
results = JsonConvert.DeserializeObject<WebResult>(File.ReadAllText(file));
}
else
{
@ -517,7 +517,7 @@ namespace Jackett.Common.Indexers
// Cached file didn't exist for our query, writing it right now !
Output("Writing results to hard drive cache ..." + request.GetHashCode() + ".json");
System.IO.File.WriteAllText(file, JsonConvert.SerializeObject(results));
File.WriteAllText(file, JsonConvert.SerializeObject(results));
}
return results;
}
@ -571,7 +571,7 @@ namespace Jackett.Common.Indexers
// Check if there is file older than ... and delete them
Output("\nCleaning Provider Storage folder... in progress.");
System.IO.Directory.GetFiles(Directory)
.Select(f => new System.IO.FileInfo(f))
.Select(f => new FileInfo(f))
.Where(f => f.LastAccessTime < DateTime.Now.AddMilliseconds(-Convert.ToInt32(ConfigData.HardDriveCacheKeepTime.Value)))
.ToList()
.ForEach(f =>

View file

@ -11,7 +11,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -11,7 +11,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;

View file

@ -9,7 +9,6 @@ using System.Xml;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -142,7 +142,7 @@ namespace Jackett.Common.Indexers
{
//var json = JArray.Parse(results.Content);
dynamic json = JsonConvert.DeserializeObject<dynamic>(results.ContentString);
foreach (var row in json ?? System.Linq.Enumerable.Empty<dynamic>())
foreach (var row in json ?? Enumerable.Empty<dynamic>())
{
var release = new ReleaseInfo();
var descriptions = new List<string>();

View file

@ -12,7 +12,6 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;

View file

@ -9,7 +9,6 @@ using AngleSharp.Html.Parser;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

View file

@ -7,12 +7,10 @@ using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AngleSharp.Html.Parser;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using WebClient = Jackett.Common.Utils.Clients.WebClient;
@ -26,8 +24,8 @@ namespace Jackett.Common.Indexers
private ConfigurationDataAPIKey ConfigData
{
get => (ConfigurationDataAPIKey)base.configData;
set => base.configData = value;
get => (ConfigurationDataAPIKey)configData;
set => configData = value;
}
public TorrentSyndikat(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
@ -155,7 +153,7 @@ namespace Jackett.Common.Indexers
foreach (var row in jsonContent.Value<JArray>("rows"))
{
var dateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
var dateTime = new DateTime(1970,1,1,0,0,0,0,DateTimeKind.Utc);
var id = row.Value<string>("id");
var comments = new Uri(SiteLink + "details.php?id=" + id);
@ -250,7 +248,7 @@ namespace Jackett.Common.Indexers
return response.ContentBytes;
}
private static void CheckResponseStatus(System.Net.HttpStatusCode status, string scope)
private static void CheckResponseStatus(HttpStatusCode status, string scope)
{
switch (status)
{

View file

@ -490,7 +490,7 @@ namespace Jackett.Common.Indexers
Output("\nQuerying tracker for results....");
// Build WebRequest for index
var myIndexRequest = new Utils.Clients.WebRequest()
var myIndexRequest = new WebRequest()
{
Type = RequestType.GET,
Url = request,