mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Fixed unnecessary Task runs
This commit is contained in:
@@ -67,21 +67,16 @@ namespace Jackett
|
|||||||
|
|
||||||
public bool IsConfigured { get; private set; }
|
public bool IsConfigured { get; private set; }
|
||||||
|
|
||||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
public async Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var loginPage = await client.GetAsync(LoginUrl);
|
var loginPage = await client.GetAsync(LoginUrl);
|
||||||
var captchaImage = await client.GetByteArrayAsync(CaptchaUrl);
|
var captchaImage = await client.GetByteArrayAsync(CaptchaUrl);
|
||||||
var config = new BmtvConfig();
|
var config = new BmtvConfig();
|
||||||
config.CaptchaImage.Value = captchaImage;
|
config.CaptchaImage.Value = captchaImage;
|
||||||
return (ConfigurationData)config;
|
return (ConfigurationData)config;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ApplyConfiguration(JToken configJson)
|
public async Task ApplyConfiguration(JToken configJson)
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var config = new BmtvConfig();
|
var config = new BmtvConfig();
|
||||||
config.LoadValuesFromJson(configJson);
|
config.LoadValuesFromJson(configJson);
|
||||||
@@ -121,17 +116,13 @@ namespace Jackett
|
|||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task VerifyConnection()
|
public async Task VerifyConnection()
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var result = await client.GetStringAsync(new Uri(SearchUrl));
|
var result = await client.GetStringAsync(new Uri(SearchUrl));
|
||||||
if (result.Contains("<h1>Not logged in!</h1>"))
|
if (result.Contains("<h1>Not logged in!</h1>"))
|
||||||
throw new Exception("Detected as not logged in");
|
throw new Exception("Detected as not logged in");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||||
@@ -140,10 +131,9 @@ namespace Jackett
|
|||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||||
{
|
|
||||||
return Task<ReleaseInfo[]>.Run(async () =>
|
|
||||||
{
|
{
|
||||||
|
|
||||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
var searchUrl = string.Format("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode("game of thrones s03e09"));
|
var searchUrl = string.Format("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode("game of thrones s03e09"));
|
||||||
@@ -193,7 +183,7 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
return releases.ToArray();
|
return releases.ToArray();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<byte[]> Download(Uri link)
|
public Task<byte[]> Download(Uri link)
|
||||||
|
@@ -50,17 +50,12 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
{
|
|
||||||
return Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
var config = new ConfigurationDataBasicLogin();
|
var config = new ConfigurationDataBasicLogin();
|
||||||
return (ConfigurationData)config;
|
return Task.FromResult<ConfigurationData>(config);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ApplyConfiguration(JToken configJson)
|
public async Task ApplyConfiguration(JToken configJson)
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var config = new ConfigurationDataBasicLogin();
|
var config = new ConfigurationDataBasicLogin();
|
||||||
config.LoadValuesFromJson(configJson);
|
config.LoadValuesFromJson(configJson);
|
||||||
@@ -102,12 +97,9 @@ namespace Jackett
|
|||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task VerifyConnection()
|
public async Task VerifyConnection()
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var message = new HttpRequestMessage();
|
var message = new HttpRequestMessage();
|
||||||
message.Method = HttpMethod.Get;
|
message.Method = HttpMethod.Get;
|
||||||
@@ -118,7 +110,6 @@ namespace Jackett
|
|||||||
var result = await response.Content.ReadAsStringAsync();
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
if (!result.Contains("/logout.php"))
|
if (!result.Contains("/logout.php"))
|
||||||
throw new Exception("Detected as not logged in");
|
throw new Exception("Detected as not logged in");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||||
@@ -128,12 +119,9 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
public Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||||
{
|
|
||||||
return Task<ReleaseInfo[]>.Run(async () =>
|
|
||||||
{
|
{
|
||||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||||
return releases.ToArray();
|
return Task.FromResult<ReleaseInfo[]>(releases.ToArray());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<byte[]> Download(Uri link)
|
public Task<byte[]> Download(Uri link)
|
||||||
|
@@ -66,17 +66,12 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
{
|
|
||||||
return Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
var config = new ThePirateBayConfig();
|
var config = new ThePirateBayConfig();
|
||||||
return (ConfigurationData)config;
|
return Task.FromResult<ConfigurationData>(config);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
|
public async Task ApplyConfiguration(JToken configJson)
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var config = new ThePirateBayConfig();
|
var config = new ThePirateBayConfig();
|
||||||
config.LoadValuesFromJson(configJson);
|
config.LoadValuesFromJson(configJson);
|
||||||
@@ -98,29 +93,21 @@ namespace Jackett.Indexers
|
|||||||
OnSaveConfigurationRequested(this, configSaveData);
|
OnSaveConfigurationRequested(this, configSaveData);
|
||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task VerifyConnection()
|
public async Task VerifyConnection()
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
await TestBrowse(BaseUrl);
|
await TestBrowse(BaseUrl);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Task TestBrowse(string url)
|
async Task TestBrowse(string url)
|
||||||
{
|
|
||||||
return Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var result = await client.GetStringAsync(new Uri(url) + BrowserUrl);
|
var result = await client.GetStringAsync(new Uri(url) + BrowserUrl);
|
||||||
if (!result.Contains("<table id=\"searchResult\">"))
|
if (!result.Contains("<table id=\"searchResult\">"))
|
||||||
{
|
{
|
||||||
throw new Exception("Could not detect The Pirate Bay content");
|
throw new Exception("Could not detect The Pirate Bay content");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||||
@@ -129,9 +116,7 @@ namespace Jackett.Indexers
|
|||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||||
{
|
|
||||||
return Task<ReleaseInfo[]>.Run(async () =>
|
|
||||||
{
|
{
|
||||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
@@ -202,7 +187,7 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return releases.ToArray();
|
return releases.ToArray();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -91,6 +91,7 @@
|
|||||||
<Compile Include="ResultPage.cs" />
|
<Compile Include="ResultPage.cs" />
|
||||||
<Compile Include="Server.cs" />
|
<Compile Include="Server.cs" />
|
||||||
<Compile Include="TorznabQuery.cs" />
|
<Compile Include="TorznabQuery.cs" />
|
||||||
|
<Compile Include="TVRage.cs" />
|
||||||
<Compile Include="WebApi.cs" />
|
<Compile Include="WebApi.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
12
src/Jackett/TVRage.cs
Normal file
12
src/Jackett/TVRage.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Jackett
|
||||||
|
{
|
||||||
|
class TVRage
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@@ -183,8 +183,6 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
Task<JToken> HandleGetIndexers(HttpListenerContext context)
|
Task<JToken> HandleGetIndexers(HttpListenerContext context)
|
||||||
{
|
|
||||||
return Task<JToken>.Run(() =>
|
|
||||||
{
|
{
|
||||||
JToken jsonReply = new JObject();
|
JToken jsonReply = new JObject();
|
||||||
try
|
try
|
||||||
@@ -210,8 +208,7 @@ namespace Jackett
|
|||||||
jsonReply["result"] = "error";
|
jsonReply["result"] = "error";
|
||||||
jsonReply["error"] = ex.Message;
|
jsonReply["error"] = ex.Message;
|
||||||
}
|
}
|
||||||
return jsonReply;
|
return Task.FromResult<JToken>(jsonReply);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<JToken> HandleTestIndexer(HttpListenerContext context)
|
async Task<JToken> HandleTestIndexer(HttpListenerContext context)
|
||||||
|
Reference in New Issue
Block a user