mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Fixed bug with app not exiting, piratebay now works on mono
This commit is contained in:
@@ -33,10 +33,16 @@ namespace CurlSharp
|
|||||||
private const string CURL_LIB = "libcurl64.dll";
|
private const string CURL_LIB = "libcurl64.dll";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_LIBCURLSHIM
|
#if USE_LIBCURLSHIM
|
||||||
private const string CURLSHIM_LIB = "libcurlshim64.dll";
|
private const string CURLSHIM_LIB = "libcurlshim64.dll";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if LINUX
|
#if LINUX
|
||||||
private const string CURL_LIB = "libcurl";
|
private const string CURL_LIB = "libcurl";
|
||||||
@@ -44,6 +50,9 @@ namespace CurlSharp
|
|||||||
private const string CURL_LIB = "libcurl.dll";
|
private const string CURL_LIB = "libcurl.dll";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_LIBCURLSHIM
|
#if USE_LIBCURLSHIM
|
||||||
private const string CURLSHIM_LIB = "libcurlshim.dll";
|
private const string CURLSHIM_LIB = "libcurlshim.dll";
|
||||||
#endif
|
#endif
|
||||||
|
@@ -10,19 +10,12 @@ using System.Net.Http.Headers;
|
|||||||
|
|
||||||
namespace Jackett
|
namespace Jackett
|
||||||
{
|
{
|
||||||
public class CurlHelper
|
public static class CurlHelper
|
||||||
{
|
{
|
||||||
private const string ChromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36";
|
private const string ChromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36";
|
||||||
|
|
||||||
public static CurlHelper Shared = new CurlHelper();
|
public class CurlRequest
|
||||||
|
|
||||||
private BlockingCollection<CurlRequest> curlRequests = new BlockingCollection<CurlRequest>();
|
|
||||||
|
|
||||||
public bool IsSupported { get; private set; }
|
|
||||||
|
|
||||||
private class CurlRequest
|
|
||||||
{
|
{
|
||||||
public TaskCompletionSource<CurlResponse> TaskCompletion { get; private set; }
|
|
||||||
|
|
||||||
public string Url { get; private set; }
|
public string Url { get; private set; }
|
||||||
|
|
||||||
@@ -36,7 +29,6 @@ namespace Jackett
|
|||||||
|
|
||||||
public CurlRequest(HttpMethod method, string url, string cookies = null, string referer = null)
|
public CurlRequest(HttpMethod method, string url, string cookies = null, string referer = null)
|
||||||
{
|
{
|
||||||
TaskCompletion = new TaskCompletionSource<CurlResponse>();
|
|
||||||
Method = method;
|
Method = method;
|
||||||
Url = url;
|
Url = url;
|
||||||
Cookies = cookies;
|
Cookies = cookies;
|
||||||
@@ -70,13 +62,9 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCookiesFromHeaders(List<string[]> headers)
|
public void AddCookiesFromHeaderValue(string cookieHeaderValue)
|
||||||
{
|
{
|
||||||
foreach (var h in headers)
|
var rawCookies = cookieHeaderValue.Split(';');
|
||||||
{
|
|
||||||
if (h[0] == "set-cookie")
|
|
||||||
{
|
|
||||||
var rawCookies = h[1].Split(';');
|
|
||||||
foreach (var rawCookie in rawCookies)
|
foreach (var rawCookie in rawCookies)
|
||||||
{
|
{
|
||||||
var parts = rawCookie.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
|
var parts = rawCookie.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||||
@@ -86,38 +74,53 @@ namespace Jackett
|
|||||||
Cookies[parts[0].Trim()] = parts[1].Trim();
|
Cookies[parts[0].Trim()] = parts[1].Trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddCookiesFromHeaders(List<string[]> headers)
|
||||||
|
{
|
||||||
|
foreach (var h in headers)
|
||||||
|
{
|
||||||
|
if (h[0] == "set-cookie")
|
||||||
|
{
|
||||||
|
AddCookiesFromHeaderValue(h[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CurlResponse> GetAsync(string url, string cookies = null, string referer = null)
|
public static async Task<CurlResponse> GetAsync(string url, string cookies = null, string referer = null)
|
||||||
{
|
{
|
||||||
var curlRequest = new CurlRequest(HttpMethod.Get, url, cookies, referer);
|
var curlRequest = new CurlRequest(HttpMethod.Get, url, cookies, referer);
|
||||||
curlRequests.Add(curlRequest);
|
var result = await PerformCurlAsync(curlRequest);
|
||||||
var result = await curlRequest.TaskCompletion.Task;
|
|
||||||
var checkedResult = await FollowRedirect(url, result);
|
var checkedResult = await FollowRedirect(url, result);
|
||||||
return checkedResult;
|
return checkedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CurlResponse> PostAsync(string url, Dictionary<string, string> formData, string cookies = null, string referer = null)
|
public static async Task<CurlResponse> PostAsync(string url, Dictionary<string, string> formData, string cookies = null, string referer = null)
|
||||||
{
|
{
|
||||||
var curlRequest = new CurlRequest(HttpMethod.Post, url, cookies, referer);
|
var curlRequest = new CurlRequest(HttpMethod.Post, url, cookies, referer);
|
||||||
curlRequest.PostData = formData;
|
curlRequest.PostData = formData;
|
||||||
curlRequests.Add(curlRequest);
|
var result = await PerformCurlAsync(curlRequest);
|
||||||
var result = await curlRequest.TaskCompletion.Task;
|
|
||||||
var checkedResult = await FollowRedirect(url, result);
|
var checkedResult = await FollowRedirect(url, result);
|
||||||
return checkedResult;
|
return checkedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<CurlResponse> FollowRedirect(string url, CurlResponse response)
|
private static async Task<CurlResponse> FollowRedirect(string url, CurlResponse response)
|
||||||
{
|
{
|
||||||
var uri = new Uri(url);
|
var uri = new Uri(url);
|
||||||
string redirect;
|
string redirect;
|
||||||
if (response.Headers.TryGetValue("location", out redirect))
|
if (response.Headers.TryGetValue("location", out redirect))
|
||||||
{
|
{
|
||||||
string cookie = response.Headers["set-cookie"];
|
string cookie = response.CookieHeader;
|
||||||
var redirectUrl = uri.Scheme + "://" + uri.Host + "/" + redirect;
|
if (!redirect.StartsWith("http://") && !redirect.StartsWith("https://"))
|
||||||
var newRedirect = await GetAsync(redirectUrl, cookie, url);
|
{
|
||||||
|
if (redirect.StartsWith("/"))
|
||||||
|
redirect = string.Format("{0}://{1}{2}", uri.Scheme, uri.Host, redirect);
|
||||||
|
else
|
||||||
|
redirect = string.Format("{0}://{1}/{2}", uri.Scheme, uri.Host, redirect);
|
||||||
|
}
|
||||||
|
var newRedirect = await GetAsync(redirect, cookie);
|
||||||
|
foreach (var c in response.Cookies)
|
||||||
|
newRedirect.Cookies[c.Key] = c.Value;
|
||||||
newRedirect.AddCookiesFromHeaders(response.HeaderList);
|
newRedirect.AddCookiesFromHeaders(response.HeaderList);
|
||||||
return newRedirect;
|
return newRedirect;
|
||||||
}
|
}
|
||||||
@@ -125,34 +128,19 @@ namespace Jackett
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurlHelper()
|
|
||||||
|
public static async Task<CurlResponse> PerformCurlAsync(CurlRequest curlRequest)
|
||||||
{
|
{
|
||||||
try
|
return await Task.Run(() => PerformCurl(curlRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CurlResponse PerformCurl(CurlRequest curlRequest)
|
||||||
{
|
{
|
||||||
Curl.GlobalInit(CurlInitFlag.All);
|
Curl.GlobalInit(CurlInitFlag.All);
|
||||||
IsSupported = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
IsSupported = false;
|
|
||||||
}
|
|
||||||
Task.Run((Action)CurlServicer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CurlServicer()
|
|
||||||
{
|
|
||||||
foreach (var curlRequest in curlRequests.GetConsumingEnumerable())
|
|
||||||
{
|
|
||||||
PerformCurl(curlRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PerformCurl(CurlRequest curlRequest)
|
|
||||||
{
|
|
||||||
var headerBuffers = new List<byte[]>();
|
var headerBuffers = new List<byte[]>();
|
||||||
var contentBuffers = new List<byte[]>();
|
var contentBuffers = new List<byte[]>();
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var easy = new CurlEasy())
|
using (var easy = new CurlEasy())
|
||||||
{
|
{
|
||||||
easy.Url = curlRequest.Url;
|
easy.Url = curlRequest.Url;
|
||||||
@@ -172,6 +160,9 @@ namespace Jackett
|
|||||||
if (!string.IsNullOrEmpty(curlRequest.Cookies))
|
if (!string.IsNullOrEmpty(curlRequest.Cookies))
|
||||||
easy.Cookie = curlRequest.Cookies;
|
easy.Cookie = curlRequest.Cookies;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(curlRequest.Referer))
|
||||||
|
easy.Referer = curlRequest.Referer;
|
||||||
|
|
||||||
if (curlRequest.Method == HttpMethod.Post)
|
if (curlRequest.Method == HttpMethod.Post)
|
||||||
{
|
{
|
||||||
easy.Post = true;
|
easy.Post = true;
|
||||||
@@ -197,16 +188,14 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
var contentBytes = Combine(contentBuffers.ToArray());
|
var contentBytes = Combine(contentBuffers.ToArray());
|
||||||
//var contentString = Encoding.UTF8.GetString (contentBytes);
|
|
||||||
|
|
||||||
var curlResponse = new CurlResponse(headers, contentBytes);
|
var curlResponse = new CurlResponse(headers, contentBytes);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(curlRequest.Cookies))
|
||||||
|
curlResponse.AddCookiesFromHeaderValue(curlRequest.Cookies);
|
||||||
curlResponse.AddCookiesFromHeaders(headers);
|
curlResponse.AddCookiesFromHeaders(headers);
|
||||||
curlRequest.TaskCompletion.SetResult(curlResponse);
|
|
||||||
}
|
return curlResponse;
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
curlRequest.TaskCompletion.TrySetException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] Combine(params byte[][] arrays)
|
public static byte[] Combine(params byte[][] arrays)
|
||||||
|
@@ -61,7 +61,6 @@ namespace Jackett
|
|||||||
|
|
||||||
void newIndexer_OnSaveConfigurationRequested(IndexerInterface indexer, JToken obj)
|
void newIndexer_OnSaveConfigurationRequested(IndexerInterface indexer, JToken obj)
|
||||||
{
|
{
|
||||||
var name = indexer.GetType().Name.Trim().ToLower();
|
|
||||||
var configFilePath = GetIndexerConfigFilePath(indexer);
|
var configFilePath = GetIndexerConfigFilePath(indexer);
|
||||||
if (!Directory.Exists(IndexerConfigDirectory))
|
if (!Directory.Exists(IndexerConfigDirectory))
|
||||||
Directory.CreateDirectory(IndexerConfigDirectory);
|
Directory.CreateDirectory(IndexerConfigDirectory);
|
||||||
|
@@ -73,7 +73,7 @@ namespace Jackett
|
|||||||
|
|
||||||
public async Task<ConfigurationData> GetConfigurationForSetup ()
|
public async Task<ConfigurationData> GetConfigurationForSetup ()
|
||||||
{
|
{
|
||||||
var loginPage = await client.GetAsync (LoginUrl);
|
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;
|
||||||
@@ -138,7 +138,6 @@ namespace Jackett
|
|||||||
foreach (var row in table.Children().Skip(1)) {
|
foreach (var row in table.Children().Skip(1)) {
|
||||||
var release = new ReleaseInfo ();
|
var release = new ReleaseInfo ();
|
||||||
|
|
||||||
CQ qRow = row.Cq ();
|
|
||||||
CQ qDetailsCol = row.ChildElements.ElementAt (1).Cq ();
|
CQ qDetailsCol = row.ChildElements.ElementAt (1).Cq ();
|
||||||
CQ qLink = qDetailsCol.Children ("a").First ();
|
CQ qLink = qDetailsCol.Children ("a").First ();
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ namespace Jackett.Indexers
|
|||||||
string responseContent;
|
string responseContent;
|
||||||
JArray cookieJArray;
|
JArray cookieJArray;
|
||||||
|
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Program.IsWindows)
|
||||||
{
|
{
|
||||||
// If Windows use .net http
|
// If Windows use .net http
|
||||||
var response = await client.PostAsync(LoginUrl, content);
|
var response = await client.PostAsync(LoginUrl, content);
|
||||||
@@ -95,7 +95,7 @@ namespace Jackett.Indexers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If UNIX system use curl
|
// If UNIX system use curl
|
||||||
var response = await CurlHelper.Shared.PostAsync(LoginUrl, pairs);
|
var response = await CurlHelper.PostAsync(LoginUrl, pairs);
|
||||||
responseContent = Encoding.UTF8.GetString(response.Content);
|
responseContent = Encoding.UTF8.GetString(response.Content);
|
||||||
cookieHeader = response.CookieHeader;
|
cookieHeader = response.CookieHeader;
|
||||||
cookieJArray = new JArray(response.CookiesFlat);
|
cookieJArray = new JArray(response.CookiesFlat);
|
||||||
@@ -150,13 +150,13 @@ namespace Jackett.Indexers
|
|||||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
||||||
|
|
||||||
string results;
|
string results;
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Program.IsWindows)
|
||||||
{
|
{
|
||||||
results = await client.GetStringAsync(episodeSearchUrl);
|
results = await client.GetStringAsync(episodeSearchUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var response = await CurlHelper.Shared.GetAsync(episodeSearchUrl, cookieHeader);
|
var response = await CurlHelper.GetAsync(episodeSearchUrl, cookieHeader);
|
||||||
results = Encoding.UTF8.GetString(response.Content);
|
results = Encoding.UTF8.GetString(response.Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,13 +204,13 @@ namespace Jackett.Indexers
|
|||||||
|
|
||||||
public async Task<byte[]> Download(Uri link)
|
public async Task<byte[]> Download(Uri link)
|
||||||
{
|
{
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Program.IsWindows)
|
||||||
{
|
{
|
||||||
return await client.GetByteArrayAsync(link);
|
return await client.GetByteArrayAsync(link);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var response = await CurlHelper.Shared.GetAsync(link.ToString(), cookieHeader);
|
var response = await CurlHelper.GetAsync(link.ToString(), cookieHeader);
|
||||||
return response.Content;
|
return response.Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ namespace Jackett.Indexers
|
|||||||
|
|
||||||
public ThePirateBayConfig()
|
public ThePirateBayConfig()
|
||||||
{
|
{
|
||||||
Url = new StringItem { Name = "Url", Value = "https://thepiratebay.se/" };
|
Url = new StringItem { Name = "Url", Value = "https://thepiratebay.se" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Item[] GetItems()
|
public override Item[] GetItems()
|
||||||
@@ -37,13 +37,12 @@ namespace Jackett.Indexers
|
|||||||
|
|
||||||
public string DisplayDescription { get { return "The worlds largest bittorrent indexer"; } }
|
public string DisplayDescription { get { return "The worlds largest bittorrent indexer"; } }
|
||||||
|
|
||||||
public Uri SiteLink { get { return new Uri("https://thepiratebay.se/"); } }
|
public Uri SiteLink { get { return new Uri("https://thepiratebay.se"); } }
|
||||||
|
|
||||||
public bool IsConfigured { get; private set; }
|
public bool IsConfigured { get; private set; }
|
||||||
|
|
||||||
static string SearchUrl = "s/?q=\"{0}\"&category=205&page=0&orderby=99";
|
static string SearchUrl = "/s/?q=\"{0}\"&category=205&page=0&orderby=99";
|
||||||
static string BrowserUrl = "browse/200";
|
static string SwitchSingleViewUrl = "/switchview.php?view=s";
|
||||||
static string SwitchSingleViewUrl = "switchview.php?view=s";
|
|
||||||
|
|
||||||
string BaseUrl;
|
string BaseUrl;
|
||||||
|
|
||||||
@@ -75,16 +74,14 @@ namespace Jackett.Indexers
|
|||||||
{
|
{
|
||||||
var config = new ThePirateBayConfig();
|
var config = new ThePirateBayConfig();
|
||||||
config.LoadValuesFromJson(configJson);
|
config.LoadValuesFromJson(configJson);
|
||||||
await TestBrowse(config.Url.Value);
|
|
||||||
BaseUrl = new Uri(config.Url.Value).ToString();
|
|
||||||
|
|
||||||
var message = new HttpRequestMessage
|
var uri = new Uri(config.Url.Value);
|
||||||
{
|
var formattedUrl = string.Format("{0}://{1}", uri.Scheme, uri.Host);
|
||||||
Method = HttpMethod.Get,
|
var releases = await PerformQuery(new TorznabQuery(), formattedUrl);
|
||||||
RequestUri = new Uri(BaseUrl + SwitchSingleViewUrl)
|
if (releases.Length == 0)
|
||||||
};
|
throw new Exception("Could not find releases from this URL");
|
||||||
message.Headers.Referrer = new Uri(BaseUrl + BrowserUrl);
|
|
||||||
var response = await client.SendAsync(message);
|
BaseUrl = formattedUrl;
|
||||||
|
|
||||||
var configSaveData = new JObject();
|
var configSaveData = new JObject();
|
||||||
configSaveData["base_url"] = BaseUrl;
|
configSaveData["base_url"] = BaseUrl;
|
||||||
@@ -93,15 +90,7 @@ namespace Jackett.Indexers
|
|||||||
OnSaveConfigurationRequested(this, configSaveData);
|
OnSaveConfigurationRequested(this, configSaveData);
|
||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
}
|
|
||||||
|
|
||||||
async Task TestBrowse(string url)
|
|
||||||
{
|
|
||||||
var result = await client.GetStringAsync(new Uri(url) + BrowserUrl);
|
|
||||||
if (!result.Contains("<table id=\"searchResult\">"))
|
|
||||||
{
|
|
||||||
throw new Exception("Could not detect The Pirate Bay content");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||||
@@ -111,23 +100,39 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||||
|
{
|
||||||
|
return await PerformQuery(query, BaseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query, string baseUrl)
|
||||||
{
|
{
|
||||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||||
{
|
{
|
||||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||||
var episodeSearchUrl = BaseUrl + string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
var episodeSearchUrl = baseUrl + string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||||
|
|
||||||
var message = new HttpRequestMessage
|
var message = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(BaseUrl + SwitchSingleViewUrl)
|
RequestUri = new Uri(baseUrl + SwitchSingleViewUrl)
|
||||||
};
|
};
|
||||||
message.Headers.Referrer = new Uri(episodeSearchUrl);
|
message.Headers.Referrer = new Uri(episodeSearchUrl);
|
||||||
|
|
||||||
|
string results;
|
||||||
|
|
||||||
|
if (Program.IsWindows)
|
||||||
|
{
|
||||||
var response = await client.SendAsync(message);
|
var response = await client.SendAsync(message);
|
||||||
var results = await response.Content.ReadAsStringAsync();
|
results = await response.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var response = await CurlHelper.GetAsync(baseUrl + SwitchSingleViewUrl, null, episodeSearchUrl);
|
||||||
|
//var response = await CurlHelper.GetAsync (episodeSearchUrl, setLayoutResponse.CookieHeader);
|
||||||
|
results = Encoding.UTF8.GetString(response.Content);
|
||||||
|
}
|
||||||
|
|
||||||
CQ dom = results;
|
CQ dom = results;
|
||||||
|
|
||||||
@@ -135,14 +140,14 @@ namespace Jackett.Indexers
|
|||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
var release = new ReleaseInfo();
|
var release = new ReleaseInfo();
|
||||||
CQ qRow = row.Cq();
|
|
||||||
CQ qLink = row.ChildElements.ElementAt(1).Cq().Children("a").First();
|
CQ qLink = row.ChildElements.ElementAt(1).Cq().Children("a").First();
|
||||||
|
|
||||||
release.MinimumRatio = 1;
|
release.MinimumRatio = 1;
|
||||||
release.MinimumSeedTime = 172800;
|
release.MinimumSeedTime = 172800;
|
||||||
release.Title = qLink.Text().Trim();
|
release.Title = qLink.Text().Trim();
|
||||||
release.Description = release.Title;
|
release.Description = release.Title;
|
||||||
release.Comments = new Uri(BaseUrl + qLink.Attr("href").TrimStart('/'));
|
release.Comments = new Uri(baseUrl + qLink.Attr("href").TrimStart('/'));
|
||||||
release.Guid = release.Comments;
|
release.Guid = release.Comments;
|
||||||
|
|
||||||
var timeString = row.ChildElements.ElementAt(2).Cq().Text();
|
var timeString = row.ChildElements.ElementAt(2).Cq().Text();
|
||||||
|
@@ -37,7 +37,7 @@ namespace Jackett
|
|||||||
|
|
||||||
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
|
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Application.Exit();
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolStripMenuItemAutoStart_CheckedChanged(object sender, EventArgs e)
|
void toolStripMenuItemAutoStart_CheckedChanged(object sender, EventArgs e)
|
||||||
|
@@ -26,18 +26,24 @@ namespace Jackett
|
|||||||
|
|
||||||
public static ManualResetEvent ExitEvent { get; private set; }
|
public static ManualResetEvent ExitEvent { get; private set; }
|
||||||
|
|
||||||
|
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
ExitEvent = new ManualResetEvent(false);
|
ExitEvent = new ManualResetEvent(false);
|
||||||
|
|
||||||
try {
|
try
|
||||||
if (!Directory.Exists (AppConfigDirectory)) {
|
{
|
||||||
|
if (!Directory.Exists(AppConfigDirectory))
|
||||||
|
{
|
||||||
IsFirstRun = true;
|
IsFirstRun = true;
|
||||||
Directory.CreateDirectory(AppConfigDirectory);
|
Directory.CreateDirectory(AppConfigDirectory);
|
||||||
}
|
}
|
||||||
Console.WriteLine("App config/log directory: " + AppConfigDirectory);
|
Console.WriteLine("App config/log directory: " + AppConfigDirectory);
|
||||||
} catch (Exception ex) {
|
}
|
||||||
MessageBox.Show ("Could not create settings directory.");
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Could not create settings directory. " + ex.Message);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,7 +57,8 @@ namespace Jackett
|
|||||||
var logFileRule = new LoggingRule("*", LogLevel.Debug, logFile);
|
var logFileRule = new LoggingRule("*", LogLevel.Debug, logFile);
|
||||||
logConfig.LoggingRules.Add(logFileRule);
|
logConfig.LoggingRules.Add(logFileRule);
|
||||||
|
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
if (Program.IsWindows)
|
||||||
|
{
|
||||||
var logAlert = new MessageBoxTarget();
|
var logAlert = new MessageBoxTarget();
|
||||||
logConfig.AddTarget("alert", logAlert);
|
logConfig.AddTarget("alert", logAlert);
|
||||||
logAlert.Layout = "${message}";
|
logAlert.Layout = "${message}";
|
||||||
@@ -69,15 +76,19 @@ namespace Jackett
|
|||||||
LogManager.Configuration = logConfig;
|
LogManager.Configuration = logConfig;
|
||||||
LoggerInstance = LogManager.GetCurrentClassLogger();
|
LoggerInstance = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
var serverTask = Task.Run (async () => {
|
var serverTask = Task.Run(async () =>
|
||||||
|
{
|
||||||
ServerInstance = new Server();
|
ServerInstance = new Server();
|
||||||
await ServerInstance.Start();
|
await ServerInstance.Start();
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
{
|
||||||
|
if (Program.IsWindows)
|
||||||
Application.Run(new Main());
|
Application.Run(new Main());
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ namespace Jackett
|
|||||||
{
|
{
|
||||||
var errorStr = "App must be ran as admin for permission to use port "
|
var errorStr = "App must be ran as admin for permission to use port "
|
||||||
+ Port + Environment.NewLine + "Restart app with admin privileges?";
|
+ Port + Environment.NewLine + "Restart app with admin privileges?";
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Program.IsWindows)
|
||||||
{
|
{
|
||||||
var dialogResult = MessageBox.Show(errorStr, "Error", MessageBoxButtons.YesNo);
|
var dialogResult = MessageBox.Show(errorStr, "Error", MessageBoxButtons.YesNo);
|
||||||
if (dialogResult == DialogResult.No)
|
if (dialogResult == DialogResult.No)
|
||||||
@@ -111,8 +111,6 @@ namespace Jackett
|
|||||||
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
|
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Program.LoggerInstance.Debug("HTTP request servicer thread died");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
@@ -174,8 +172,6 @@ namespace Jackett
|
|||||||
|
|
||||||
var query = HttpUtility.ParseQueryString(context.Request.Url.Query);
|
var query = HttpUtility.ParseQueryString(context.Request.Url.Query);
|
||||||
var inputStream = context.Request.InputStream;
|
var inputStream = context.Request.InputStream;
|
||||||
var reader = new StreamReader(inputStream, context.Request.ContentEncoding);
|
|
||||||
var bytes = await reader.ReadToEndAsync();
|
|
||||||
|
|
||||||
var indexerId = context.Request.Url.Segments[2].TrimEnd('/').ToLower();
|
var indexerId = context.Request.Url.Segments[2].TrimEnd('/').ToLower();
|
||||||
var indexer = indexerManager.GetIndexer(indexerId);
|
var indexer = indexerManager.GetIndexer(indexerId);
|
||||||
|
@@ -27,8 +27,8 @@ namespace Jackett
|
|||||||
ApplySonarrConfig,
|
ApplySonarrConfig,
|
||||||
TestSonarr
|
TestSonarr
|
||||||
}
|
}
|
||||||
static Dictionary<string, WebApiMethod> WebApiMethods = new Dictionary<string, WebApiMethod>
|
|
||||||
{
|
static Dictionary<string, WebApiMethod> WebApiMethods = new Dictionary<string, WebApiMethod> {
|
||||||
{ "get_config_form", WebApiMethod.GetConfigForm },
|
{ "get_config_form", WebApiMethod.GetConfigForm },
|
||||||
{ "configure_indexer", WebApiMethod.ConfigureIndexer },
|
{ "configure_indexer", WebApiMethod.ConfigureIndexer },
|
||||||
{ "get_indexers", WebApiMethod.GetIndexers },
|
{ "get_indexers", WebApiMethod.GetIndexers },
|
||||||
@@ -80,7 +80,9 @@ namespace Jackett
|
|||||||
{
|
{
|
||||||
await context.Response.OutputStream.WriteAsync(contentFile, 0, contentFile.Length);
|
await context.Response.OutputStream.WriteAsync(contentFile, 0, contentFile.Length);
|
||||||
}
|
}
|
||||||
catch (HttpListenerException) { }
|
catch (HttpListenerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<JToken> ReadPostDataJson(Stream stream)
|
async Task<JToken> ReadPostDataJson(Stream stream)
|
||||||
@@ -93,8 +95,6 @@ namespace Jackett
|
|||||||
|
|
||||||
async Task ProcessWebApiRequest(HttpListenerContext context, WebApiMethod method)
|
async Task ProcessWebApiRequest(HttpListenerContext context, WebApiMethod method)
|
||||||
{
|
{
|
||||||
var query = HttpUtility.ParseQueryString(context.Request.Url.Query);
|
|
||||||
|
|
||||||
context.Response.ContentType = "text/json";
|
context.Response.ContentType = "text/json";
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user