mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-13 23:44:10 +02:00
Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
eb4b068d54 | ||
![]() |
489c900e00 | ||
![]() |
7753ffdad4 | ||
![]() |
4aca537a92 | ||
![]() |
c0a7d00ffc | ||
![]() |
68dd53b962 | ||
![]() |
9ba12621a5 | ||
![]() |
1faf5099f5 | ||
![]() |
bc8b1d14d5 | ||
![]() |
f781deb4a9 | ||
![]() |
8d39a4b1a7 | ||
![]() |
edf97f5d05 | ||
![]() |
507ef9424b | ||
![]() |
4cd12332d2 | ||
![]() |
335e16dd3e | ||
![]() |
26f1ba7016 | ||
![]() |
59cf8c3e9f | ||
![]() |
dfd68d16aa | ||
![]() |
9a4c5ffe5c | ||
![]() |
8cf45a5e45 | ||
![]() |
7834411bbd |
@@ -15,7 +15,7 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
|
||||
|
||||
### Instructions for Mono
|
||||
* Install Mono: http://www.mono-project.com/download/
|
||||
* Install libcurl-dev for your system: http://curl.haxx.se/dlwiz/?type=devel
|
||||
* *For MoreThanTV & ThePirateBay* install libcurl-dev for your system, [tutorial](http://curl.haxx.se/dlwiz/?type=devel)
|
||||
* For apt-get systems its simply: `apt-get install libcurl4-openssl-dev`
|
||||
|
||||
|
||||
@@ -25,7 +25,12 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
|
||||
* [BIT-HDTV](https://www.bit-hdtv.com)
|
||||
* [Freshon](https://freshon.tv/)
|
||||
* [IPTorrents](https://iptorrents.com/)
|
||||
* [TorrentLeech](http://www.torrentleech.org/)
|
||||
* [Strike](https://getstrike.net/)
|
||||
* [The Pirate Bay](https://thepiratebay.se/)
|
||||
* [RARBG](https://rarbg.com)
|
||||
* [TorrentDay](https://torrentday.eu/)
|
||||
* [TorrentShack](http://torrentshack.me/)
|
||||
|
||||
|
||||
### Additional Trackers
|
||||
@@ -36,4 +41,4 @@ I can be contact on IRC at [irc.freenode.net#sonarr](http://webchat.freenode.net
|
||||
|
||||
### Screenshots
|
||||
|
||||

|
||||

|
||||
|
@@ -30,6 +30,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>LINUX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@@ -33,10 +33,16 @@ namespace CurlSharp
|
||||
private const string CURL_LIB = "libcurl64.dll";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if USE_LIBCURLSHIM
|
||||
private const string CURLSHIM_LIB = "libcurlshim64.dll";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#else
|
||||
#if LINUX
|
||||
private const string CURL_LIB = "libcurl";
|
||||
@@ -44,6 +50,9 @@ namespace CurlSharp
|
||||
private const string CURL_LIB = "libcurl.dll";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if USE_LIBCURLSHIM
|
||||
private const string CURLSHIM_LIB = "libcurlshim.dll";
|
||||
#endif
|
||||
|
29
src/Jackett/ConfigurationDataUrl.cs
Normal file
29
src/Jackett/ConfigurationDataUrl.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public class ConfigurationDataUrl : ConfigurationData
|
||||
{
|
||||
public StringItem Url { get; private set; }
|
||||
|
||||
public ConfigurationDataUrl(string defaultUrl)
|
||||
{
|
||||
Url = new StringItem { Name = "Url", Value = defaultUrl };
|
||||
}
|
||||
|
||||
public override Item[] GetItems()
|
||||
{
|
||||
return new Item[] { Url };
|
||||
}
|
||||
|
||||
public string GetFormattedHostUrl()
|
||||
{
|
||||
var uri = new Uri(Url.Value);
|
||||
return string.Format("{0}://{1}", uri.Scheme, uri.Host);
|
||||
}
|
||||
}
|
||||
}
|
213
src/Jackett/CurlHelper.cs
Normal file
213
src/Jackett/CurlHelper.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using CurlSharp;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
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";
|
||||
|
||||
public class CurlRequest
|
||||
{
|
||||
|
||||
public string Url { get; private set; }
|
||||
|
||||
public string Cookies { get; private set; }
|
||||
|
||||
public string Referer { get; private set; }
|
||||
|
||||
public HttpMethod Method { get; private set; }
|
||||
|
||||
public Dictionary<string, string> PostData { get; set; }
|
||||
|
||||
public CurlRequest(HttpMethod method, string url, string cookies = null, string referer = null)
|
||||
{
|
||||
Method = method;
|
||||
Url = url;
|
||||
Cookies = cookies;
|
||||
Referer = referer;
|
||||
}
|
||||
}
|
||||
|
||||
public class CurlResponse
|
||||
{
|
||||
public Dictionary<string, string> Headers { get; private set; }
|
||||
|
||||
public List<string[]> HeaderList { get; private set; }
|
||||
|
||||
public byte[] Content { get; private set; }
|
||||
|
||||
public Dictionary<string, string> Cookies { get; private set; }
|
||||
|
||||
public List<string> CookiesFlat { get { return Cookies.Select(c => c.Key + "=" + c.Value).ToList(); } }
|
||||
|
||||
public string CookieHeader { get { return string.Join("; ", CookiesFlat); } }
|
||||
|
||||
public CurlResponse(List<string[]> headers, byte[] content)
|
||||
{
|
||||
Headers = new Dictionary<string, string>();
|
||||
Cookies = new Dictionary<string, string>();
|
||||
HeaderList = headers;
|
||||
Content = content;
|
||||
foreach (var h in headers)
|
||||
{
|
||||
Headers[h[0]] = h[1];
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCookiesFromHeaderValue(string cookieHeaderValue)
|
||||
{
|
||||
var rawCookies = cookieHeaderValue.Split(';');
|
||||
foreach (var rawCookie in rawCookies)
|
||||
{
|
||||
var parts = rawCookie.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 1)
|
||||
Cookies[rawCookie.Trim()] = string.Empty;
|
||||
else
|
||||
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 static async Task<CurlResponse> GetAsync(string url, string cookies = null, string referer = null)
|
||||
{
|
||||
var curlRequest = new CurlRequest(HttpMethod.Get, url, cookies, referer);
|
||||
var result = await PerformCurlAsync(curlRequest);
|
||||
var checkedResult = await FollowRedirect(url, result);
|
||||
return checkedResult;
|
||||
}
|
||||
|
||||
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);
|
||||
curlRequest.PostData = formData;
|
||||
var result = await PerformCurlAsync(curlRequest);
|
||||
var checkedResult = await FollowRedirect(url, result);
|
||||
return checkedResult;
|
||||
}
|
||||
|
||||
private static async Task<CurlResponse> FollowRedirect(string url, CurlResponse response)
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
string redirect;
|
||||
if (response.Headers.TryGetValue("location", out redirect))
|
||||
{
|
||||
string cookie = response.CookieHeader;
|
||||
if (!redirect.StartsWith("http://") && !redirect.StartsWith("https://"))
|
||||
{
|
||||
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);
|
||||
return newRedirect;
|
||||
}
|
||||
else
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public static async Task<CurlResponse> PerformCurlAsync(CurlRequest curlRequest)
|
||||
{
|
||||
return await Task.Run(() => PerformCurl(curlRequest));
|
||||
}
|
||||
|
||||
public static CurlResponse PerformCurl(CurlRequest curlRequest)
|
||||
{
|
||||
Curl.GlobalInit(CurlInitFlag.All);
|
||||
|
||||
var headerBuffers = new List<byte[]>();
|
||||
var contentBuffers = new List<byte[]>();
|
||||
|
||||
using (var easy = new CurlEasy())
|
||||
{
|
||||
easy.Url = curlRequest.Url;
|
||||
easy.BufferSize = 64 * 1024;
|
||||
easy.UserAgent = ChromeUserAgent;
|
||||
easy.WriteFunction = (byte[] buf, int size, int nmemb, object data) =>
|
||||
{
|
||||
contentBuffers.Add(buf);
|
||||
return size * nmemb;
|
||||
};
|
||||
easy.HeaderFunction = (byte[] buf, int size, int nmemb, object extraData) =>
|
||||
{
|
||||
headerBuffers.Add(buf);
|
||||
return size * nmemb;
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(curlRequest.Cookies))
|
||||
easy.Cookie = curlRequest.Cookies;
|
||||
|
||||
if (!string.IsNullOrEmpty(curlRequest.Referer))
|
||||
easy.Referer = curlRequest.Referer;
|
||||
|
||||
if (curlRequest.Method == HttpMethod.Post)
|
||||
{
|
||||
easy.Post = true;
|
||||
var postString = new FormUrlEncodedContent(curlRequest.PostData).ReadAsStringAsync().Result;
|
||||
easy.PostFields = postString;
|
||||
easy.PostFieldSize = Encoding.UTF8.GetByteCount(postString);
|
||||
}
|
||||
|
||||
easy.Perform();
|
||||
}
|
||||
|
||||
var headerBytes = Combine(headerBuffers.ToArray());
|
||||
var headerString = Encoding.UTF8.GetString(headerBytes);
|
||||
var headerParts = headerString.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var headers = new List<string[]>();
|
||||
foreach (var headerPart in headerParts.Skip(1))
|
||||
{
|
||||
var keyVal = headerPart.Split(new char[] { ':' }, 2);
|
||||
if (keyVal.Length > 1)
|
||||
{
|
||||
headers.Add(new[] { keyVal[0].ToLower().Trim(), keyVal[1].Trim() });
|
||||
}
|
||||
}
|
||||
|
||||
var contentBytes = Combine(contentBuffers.ToArray());
|
||||
var curlResponse = new CurlResponse(headers, contentBytes);
|
||||
|
||||
if (!string.IsNullOrEmpty(curlRequest.Cookies))
|
||||
curlResponse.AddCookiesFromHeaderValue(curlRequest.Cookies);
|
||||
curlResponse.AddCookiesFromHeaders(headers);
|
||||
|
||||
return curlResponse;
|
||||
|
||||
}
|
||||
|
||||
public static byte[] Combine(params byte[][] arrays)
|
||||
{
|
||||
byte[] ret = new byte[arrays.Sum(x => x.Length)];
|
||||
int offset = 0;
|
||||
foreach (byte[] data in arrays)
|
||||
{
|
||||
Buffer.BlockCopy(data, 0, ret, offset, data.Length);
|
||||
offset += data.Length;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,22 +10,25 @@ namespace Jackett
|
||||
{
|
||||
public interface IndexerInterface
|
||||
{
|
||||
|
||||
// Invoked when the indexer configuration has been applied and verified so the cookie needs to be saved
|
||||
event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
string DisplayName { get; }
|
||||
string DisplayDescription { get; }
|
||||
Uri SiteLink { get; }
|
||||
|
||||
// Whether this indexer has been configured, verified and saved in the past and has the settings required for functioning
|
||||
bool IsConfigured { get; }
|
||||
|
||||
// Retrieved for starting setup for the indexer via web API
|
||||
Task<ConfigurationData> GetConfigurationForSetup();
|
||||
|
||||
// Called when web API wants to apply setup configuration via web API, usually this is where login and storing cookie happens
|
||||
Task ApplyConfiguration(JToken configJson);
|
||||
|
||||
// Invoked when the indexer configuration has been applied and verified so the cookie needs to be saved
|
||||
event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
// Whether this indexer has been configured, verified and saved in the past and has the settings required for functioning
|
||||
bool IsConfigured { get; }
|
||||
|
||||
// Called on startup when initializing indexers from saved configuration
|
||||
void LoadFromSavedConfiguration(JToken jsonConfig);
|
||||
|
||||
|
@@ -43,6 +43,7 @@ namespace Jackett
|
||||
|
||||
IndexerInterface newIndexer = (IndexerInterface)Activator.CreateInstance(indexerType);
|
||||
newIndexer.OnSaveConfigurationRequested += newIndexer_OnSaveConfigurationRequested;
|
||||
newIndexer.OnResultParsingError += newIndexer_OnResultParsingError;
|
||||
|
||||
var configFilePath = GetIndexerConfigFilePath(newIndexer);
|
||||
if (File.Exists(configFilePath))
|
||||
@@ -54,6 +55,14 @@ namespace Jackett
|
||||
Indexers.Add(name, newIndexer);
|
||||
}
|
||||
|
||||
void newIndexer_OnResultParsingError(IndexerInterface indexer, string results, Exception ex)
|
||||
{
|
||||
var fileName = string.Format("Error on {0} for {1}.txt", DateTime.Now.ToString("yyyyMMddHHmmss"), indexer.DisplayName);
|
||||
var spacing = string.Join("", Enumerable.Repeat(Environment.NewLine, 5));
|
||||
var fileContents = string.Format("{0}{1}{2}", ex, spacing, results);
|
||||
File.WriteAllText(Path.Combine(Program.AppConfigDirectory, fileName), fileContents);
|
||||
}
|
||||
|
||||
string GetIndexerConfigFilePath(IndexerInterface indexer)
|
||||
{
|
||||
return Path.Combine(IndexerConfigDirectory, indexer.GetType().Name.ToLower() + ".json");
|
||||
@@ -61,7 +70,6 @@ namespace Jackett
|
||||
|
||||
void newIndexer_OnSaveConfigurationRequested(IndexerInterface indexer, JToken obj)
|
||||
{
|
||||
var name = indexer.GetType().Name.Trim().ToLower();
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer);
|
||||
if (!Directory.Exists(IndexerConfigDirectory))
|
||||
Directory.CreateDirectory(IndexerConfigDirectory);
|
||||
|
@@ -12,139 +12,159 @@ using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class BitHdtv : IndexerInterface
|
||||
{
|
||||
public string DisplayName {
|
||||
get { return "BIT-HDTV"; }
|
||||
}
|
||||
public class BitHdtv : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayDescription {
|
||||
get { return "Home of high definition invites"; }
|
||||
}
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "BIT-HDTV"; }
|
||||
}
|
||||
|
||||
public Uri SiteLink {
|
||||
get { return new Uri (BaseUrl); }
|
||||
}
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return "Home of high definition invites"; }
|
||||
}
|
||||
|
||||
static string BaseUrl = "https://www.bit-hdtv.com";
|
||||
static string LoginUrl = BaseUrl + "/takelogin.php";
|
||||
static string SearchUrl = BaseUrl + "/torrents.php?cat=0&search=";
|
||||
static string DownloadUrl = BaseUrl + "/download.php?/{0}/dl.torrent";
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(BaseUrl); }
|
||||
}
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
static string BaseUrl = "https://www.bit-hdtv.com";
|
||||
static string LoginUrl = BaseUrl + "/takelogin.php";
|
||||
static string SearchUrl = BaseUrl + "/torrents.php?cat=0&search=";
|
||||
static string DownloadUrl = BaseUrl + "/download.php?/{0}/dl.torrent";
|
||||
|
||||
public BitHdtv ()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer ();
|
||||
handler = new HttpClientHandler {
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient (handler);
|
||||
}
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup ()
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
return Task.FromResult<ConfigurationData> (config);
|
||||
}
|
||||
public BitHdtv()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration (JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
config.LoadValuesFromJson (configJson);
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent (pairs);
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
var response = await client.PostAsync (LoginUrl, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync ();
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains ("logout.php")) {
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom ["table.detail td.text"].Last ();
|
||||
messageEl.Children ("a").Remove ();
|
||||
messageEl.Children ("style").Remove ();
|
||||
var errorMessage = messageEl.Text ().Trim ();
|
||||
throw new ExceptionWithConfigData (errorMessage, (ConfigurationData)config);
|
||||
} else {
|
||||
var configSaveData = new JObject ();
|
||||
configSaveData ["cookies"] = cookies.ToJson (SiteLink);
|
||||
if (!responseContent.Contains("logout.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom["table.detail td.text"].Last();
|
||||
messageEl.Children("a").Remove();
|
||||
messageEl.Children("style").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested (this, configSaveData);
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
public void LoadFromSavedConfiguration (JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson (new Uri (BaseUrl), (JArray)jsonConfig ["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery (TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo> ();
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
dom["#needseed"].Remove();
|
||||
var rows = dom["table[width='750'] > tbody"].Children();
|
||||
foreach (var row in rows.Skip(1))
|
||||
{
|
||||
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
var qRow = row.Cq();
|
||||
var qLink = qRow.Children().ElementAt(2).Cq().Children("a").First();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Attr("title");
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(string.Format(DownloadUrl, qLink.Attr("href").Split('=')[1]));
|
||||
|
||||
var dateString = qRow.Children().ElementAt(5).Cq().Text().Trim();
|
||||
var pubDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
release.PublishDate = pubDate;
|
||||
|
||||
var sizeCol = qRow.Children().ElementAt(6);
|
||||
var sizeVal = sizeCol.ChildNodes[0].NodeValue;
|
||||
var sizeUnit = sizeCol.ChildNodes[2].NodeValue;
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, float.Parse(sizeVal));
|
||||
|
||||
release.Seeders = int.Parse(qRow.Children().ElementAt(8).Cq().Text().Trim(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(qRow.Children().ElementAt(9).Cq().Text().Trim(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty }) {
|
||||
var searchString = title + " " + query.GetEpisodeSearchString ();
|
||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode (searchString);
|
||||
var results = await client.GetStringAsync (episodeSearchUrl);
|
||||
CQ dom = results;
|
||||
dom ["#needseed"].Remove ();
|
||||
var rows = dom ["table[width='750'] > tbody"].Children ();
|
||||
foreach (var row in rows.Skip(1)) {
|
||||
|
||||
var release = new ReleaseInfo ();
|
||||
|
||||
var qRow = row.Cq ();
|
||||
var qLink = qRow.Children ().ElementAt (2).Cq ().Children ("a").First ();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Attr ("title");
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri (BaseUrl + qLink.Attr ("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri (string.Format (DownloadUrl, qLink.Attr ("href").Split ('=') [1]));
|
||||
|
||||
var dateString = qRow.Children ().ElementAt (5).Cq ().Text ().Trim ();
|
||||
var pubDate = DateTime.ParseExact (dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
release.PublishDate = pubDate;
|
||||
|
||||
var sizeCol = qRow.Children ().ElementAt (6);
|
||||
var sizeVal = sizeCol.ChildNodes [0].NodeValue;
|
||||
var sizeUnit = sizeCol.ChildNodes [2].NodeValue;
|
||||
release.Size = ReleaseInfo.GetBytes (sizeUnit, float.Parse (sizeVal));
|
||||
|
||||
release.Seeders = int.Parse (qRow.Children ().ElementAt (8).Cq ().Text ().Trim ());
|
||||
release.Peers = int.Parse (qRow.Children ().ElementAt (9).Cq ().Text ().Trim ()) + release.Seeders;
|
||||
|
||||
releases.Add (release);
|
||||
}
|
||||
}
|
||||
|
||||
return releases.ToArray ();
|
||||
}
|
||||
|
||||
public Task<byte[]> Download (Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync (link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,170 +13,189 @@ using System.Web;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public class BitMeTV : IndexerInterface
|
||||
{
|
||||
class BmtvConfig : ConfigurationData
|
||||
{
|
||||
public StringItem Username { get; private set; }
|
||||
public class BitMeTV : IndexerInterface
|
||||
{
|
||||
class BmtvConfig : ConfigurationData
|
||||
{
|
||||
public StringItem Username { get; private set; }
|
||||
|
||||
public StringItem Password { get; private set; }
|
||||
public StringItem Password { get; private set; }
|
||||
|
||||
public ImageItem CaptchaImage { get; private set; }
|
||||
public ImageItem CaptchaImage { get; private set; }
|
||||
|
||||
public StringItem CaptchaText { get; private set; }
|
||||
public StringItem CaptchaText { get; private set; }
|
||||
|
||||
public BmtvConfig ()
|
||||
{
|
||||
Username = new StringItem { Name = "Username" };
|
||||
Password = new StringItem { Name = "Password" };
|
||||
CaptchaImage = new ImageItem { Name = "Captcha Image" };
|
||||
CaptchaText = new StringItem { Name = "Captcha Text" };
|
||||
}
|
||||
public BmtvConfig()
|
||||
{
|
||||
Username = new StringItem { Name = "Username" };
|
||||
Password = new StringItem { Name = "Password" };
|
||||
CaptchaImage = new ImageItem { Name = "Captcha Image" };
|
||||
CaptchaText = new StringItem { Name = "Captcha Text" };
|
||||
}
|
||||
|
||||
public override Item[] GetItems ()
|
||||
{
|
||||
return new Item[] { Username, Password, CaptchaImage, CaptchaText };
|
||||
}
|
||||
}
|
||||
public override Item[] GetItems()
|
||||
{
|
||||
return new Item[] { Username, Password, CaptchaImage, CaptchaText };
|
||||
}
|
||||
}
|
||||
|
||||
static string BaseUrl = "http://www.bitmetv.org";
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
static string LoginPost = BaseUrl + "/takelogin.php";
|
||||
static string CaptchaUrl = BaseUrl + "/visual.php";
|
||||
static string SearchUrl = BaseUrl + "/browse.php";
|
||||
static string BaseUrl = "http://www.bitmetv.org";
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
static string LoginPost = BaseUrl + "/takelogin.php";
|
||||
static string CaptchaUrl = BaseUrl + "/visual.php";
|
||||
static string SearchUrl = BaseUrl + "/browse.php";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public BitMeTV ()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer ();
|
||||
handler = new HttpClientHandler {
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient (handler);
|
||||
}
|
||||
public BitMeTV()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public string DisplayName { get { return "BitMeTV"; } }
|
||||
public string DisplayName { get { return "BitMeTV"; } }
|
||||
|
||||
public string DisplayDescription { get { return "TV Episode specialty tracker"; } }
|
||||
public string DisplayDescription { get { return "TV Episode specialty tracker"; } }
|
||||
|
||||
public Uri SiteLink { get { return new Uri (BaseUrl); } }
|
||||
public Uri SiteLink { get { return new Uri(BaseUrl); } }
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup ()
|
||||
{
|
||||
var loginPage = await client.GetAsync (LoginUrl);
|
||||
var captchaImage = await client.GetByteArrayAsync (CaptchaUrl);
|
||||
var config = new BmtvConfig ();
|
||||
config.CaptchaImage.Value = captchaImage;
|
||||
return (ConfigurationData)config;
|
||||
}
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
await client.GetAsync(LoginUrl);
|
||||
var captchaImage = await client.GetByteArrayAsync(CaptchaUrl);
|
||||
var config = new BmtvConfig();
|
||||
config.CaptchaImage.Value = captchaImage;
|
||||
return (ConfigurationData)config;
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration (JToken configJson)
|
||||
{
|
||||
var config = new BmtvConfig ();
|
||||
config.LoadValuesFromJson (configJson);
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new BmtvConfig();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "secimage", config.CaptchaText.Value }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent (pairs);
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
var response = await client.PostAsync (LoginPost, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync ();
|
||||
var response = await client.PostAsync(LoginPost, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains ("/logout.php")) {
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom ["table tr > td.embedded > h2"].Last ();
|
||||
var errorMessage = messageEl.Text ();
|
||||
var captchaImage = await client.GetByteArrayAsync (CaptchaUrl);
|
||||
config.CaptchaImage.Value = captchaImage;
|
||||
config.CaptchaText.Value = "";
|
||||
throw new ExceptionWithConfigData (errorMessage, (ConfigurationData)config);
|
||||
} else {
|
||||
var configSaveData = new JObject ();
|
||||
configSaveData ["cookies"] = cookies.ToJson (SiteLink);
|
||||
if (!responseContent.Contains("/logout.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom["table tr > td.embedded > h2"].Last();
|
||||
var errorMessage = messageEl.Text();
|
||||
var captchaImage = await client.GetByteArrayAsync(CaptchaUrl);
|
||||
config.CaptchaImage.Value = captchaImage;
|
||||
config.CaptchaText.Value = "";
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested (this, configSaveData);
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration (JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson (new Uri (BaseUrl), (JArray)jsonConfig ["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery (TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo> ();
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
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 episodeSearchUrl = string.Format ("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode (searchString));
|
||||
var results = await client.GetStringAsync (episodeSearchUrl);
|
||||
CQ dom = results;
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
var table = dom ["tbody > tr > .latest"].Parent ().Parent ();
|
||||
var table = dom["tbody > tr > .latest"].Parent().Parent();
|
||||
|
||||
foreach (var row in table.Children().Skip(1)) {
|
||||
var release = new ReleaseInfo ();
|
||||
foreach (var row in table.Children().Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
CQ qRow = row.Cq ();
|
||||
CQ qDetailsCol = row.ChildElements.ElementAt (1).Cq ();
|
||||
CQ qLink = qDetailsCol.Children ("a").First ();
|
||||
CQ qDetailsCol = row.ChildElements.ElementAt(1).Cq();
|
||||
CQ qLink = qDetailsCol.Children("a").First();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Comments = new Uri (BaseUrl + "/" + qLink.Attr ("href"));
|
||||
release.Guid = release.Comments;
|
||||
release.Title = qLink.Attr ("title");
|
||||
release.Description = release.Title;
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Comments = new Uri(BaseUrl + "/" + qLink.Attr("href"));
|
||||
release.Guid = release.Comments;
|
||||
release.Title = qLink.Attr("title");
|
||||
release.Description = release.Title;
|
||||
|
||||
//"Tuesday, June 11th 2013 at 03:52:53 AM" to...
|
||||
//"Tuesday June 11 2013 03:52:53 AM"
|
||||
var timestamp = qDetailsCol.Children ("font").Text ().Trim () + " ";
|
||||
var timeParts = new List<string> (timestamp.Replace (" at", "").Replace (",", "").Split (' '));
|
||||
timeParts [2] = Regex.Replace (timeParts [2], "[^0-9.]", "");
|
||||
var formattedTimeString = string.Join (" ", timeParts.ToArray ()).Trim ();
|
||||
release.PublishDate = DateTime.ParseExact (formattedTimeString, "dddd MMMM d yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
|
||||
//"Tuesday, June 11th 2013 at 03:52:53 AM" to...
|
||||
//"Tuesday June 11 2013 03:52:53 AM"
|
||||
var timestamp = qDetailsCol.Children("font").Text().Trim() + " ";
|
||||
var timeParts = new List<string>(timestamp.Replace(" at", "").Replace(",", "").Split(' '));
|
||||
timeParts[2] = Regex.Replace(timeParts[2], "[^0-9.]", "");
|
||||
var formattedTimeString = string.Join(" ", timeParts.ToArray()).Trim();
|
||||
release.PublishDate = DateTime.ParseExact(formattedTimeString, "dddd MMMM d yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
|
||||
|
||||
release.Link = new Uri (BaseUrl + "/" + row.ChildElements.ElementAt (2).Cq ().Children ("a.index").Attr ("href"));
|
||||
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
|
||||
|
||||
var sizeCol = row.ChildElements.ElementAt (6);
|
||||
var sizeVal = float.Parse (sizeCol.ChildNodes [0].NodeValue);
|
||||
var sizeUnit = sizeCol.ChildNodes [2].NodeValue;
|
||||
release.Size = ReleaseInfo.GetBytes (sizeUnit, sizeVal);
|
||||
var sizeCol = row.ChildElements.ElementAt(6);
|
||||
var sizeVal = float.Parse(sizeCol.ChildNodes[0].NodeValue);
|
||||
var sizeUnit = sizeCol.ChildNodes[2].NodeValue;
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, sizeVal);
|
||||
|
||||
release.Seeders = int.Parse (row.ChildElements.ElementAt (8).Cq ().Text ());
|
||||
release.Peers = int.Parse (row.ChildElements.ElementAt (9).Cq ().Text ()) + release.Seeders;
|
||||
releases.Add (release);
|
||||
}
|
||||
}
|
||||
release.Seeders = int.Parse(row.ChildElements.ElementAt(8).Cq().Text(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(row.ChildElements.ElementAt(9).Cq().Text(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
return releases.ToArray ();
|
||||
if (!release.Title.ToLower().Contains(title.ToLower()))
|
||||
continue;
|
||||
|
||||
}
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<byte[]> Download (Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync (link);
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -14,168 +14,183 @@ using System.Web.UI.WebControls;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public class Freshon : IndexerInterface
|
||||
{
|
||||
public class Freshon : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
static string BaseUrl = "https://freshon.tv";
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
static string LoginPostUrl = BaseUrl + "/login.php?action=makelogin";
|
||||
static string SearchUrl = BaseUrl + "/browse.php";
|
||||
static string BaseUrl = "https://freshon.tv";
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
static string LoginPostUrl = BaseUrl + "/login.php?action=makelogin";
|
||||
static string SearchUrl = BaseUrl + "/browse.php";
|
||||
|
||||
static string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
static string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
public string DisplayName { get { return "FreshOnTV"; } }
|
||||
public string DisplayName { get { return "FreshOnTV"; } }
|
||||
|
||||
public string DisplayDescription { get { return "Our goal is to provide the latest stuff in the TV show domain"; } }
|
||||
public string DisplayDescription { get { return "Our goal is to provide the latest stuff in the TV show domain"; } }
|
||||
|
||||
public Uri SiteLink { get { return new Uri (BaseUrl); } }
|
||||
public Uri SiteLink { get { return new Uri(BaseUrl); } }
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public Freshon ()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer ();
|
||||
handler = new HttpClientHandler {
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient (handler);
|
||||
}
|
||||
public Freshon()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup ()
|
||||
{
|
||||
var request = CreateHttpRequest (new Uri (LoginUrl));
|
||||
var response = await client.SendAsync (request);
|
||||
await response.Content.ReadAsStreamAsync ();
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
return config;
|
||||
}
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var request = CreateHttpRequest(new Uri(LoginUrl));
|
||||
var response = await client.SendAsync(request);
|
||||
await response.Content.ReadAsStreamAsync();
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return config;
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration (JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
config.LoadValuesFromJson (configJson);
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent (pairs);
|
||||
var message = CreateHttpRequest (new Uri (LoginPostUrl));
|
||||
message.Method = HttpMethod.Post;
|
||||
message.Content = content;
|
||||
message.Headers.Referrer = new Uri (LoginUrl);
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
var message = CreateHttpRequest(new Uri(LoginPostUrl));
|
||||
message.Method = HttpMethod.Post;
|
||||
message.Content = content;
|
||||
message.Headers.Referrer = new Uri(LoginUrl);
|
||||
|
||||
var response = await client.SendAsync (message);
|
||||
var responseContent = await response.Content.ReadAsStringAsync ();
|
||||
var response = await client.SendAsync(message);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains ("/logout.php")) {
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom [".error_text"];
|
||||
var errorMessage = messageEl.Text ().Trim ();
|
||||
throw new ExceptionWithConfigData (errorMessage, (ConfigurationData)config);
|
||||
} else {
|
||||
var configSaveData = new JObject ();
|
||||
configSaveData ["cookies"] = cookies.ToJson (SiteLink);
|
||||
if (!responseContent.Contains("/logout.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom[".error_text"];
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested (this, configSaveData);
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration (JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson (new Uri (BaseUrl), (JArray)jsonConfig ["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
HttpRequestMessage CreateHttpRequest (Uri uri)
|
||||
{
|
||||
var message = new HttpRequestMessage ();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = uri;
|
||||
message.Headers.UserAgent.ParseAdd (chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
HttpRequestMessage CreateHttpRequest(Uri uri)
|
||||
{
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = uri;
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery (TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo> ();
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty }) {
|
||||
string episodeSearchUrl;
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
string episodeSearchUrl;
|
||||
|
||||
if (string.IsNullOrEmpty (title))
|
||||
episodeSearchUrl = SearchUrl;
|
||||
else {
|
||||
var searchString = title + " " + query.GetEpisodeSearchString ();
|
||||
episodeSearchUrl = string.Format ("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode (searchString));
|
||||
}
|
||||
if (string.IsNullOrEmpty(title))
|
||||
episodeSearchUrl = SearchUrl;
|
||||
else
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
episodeSearchUrl = string.Format("{0}?search={1}&cat=0", SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
}
|
||||
|
||||
var request = CreateHttpRequest (new Uri (episodeSearchUrl));
|
||||
var response = await client.SendAsync (request);
|
||||
var results = await response.Content.ReadAsStringAsync ();
|
||||
var request = CreateHttpRequest(new Uri(episodeSearchUrl));
|
||||
var response = await client.SendAsync(request);
|
||||
var results = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
CQ dom = results;
|
||||
var rows = dom["#highlight > tbody > tr"];
|
||||
|
||||
var rows = dom ["#highlight > tbody > tr"];
|
||||
foreach (var row in rows.Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
foreach (var row in rows.Skip(1)) {
|
||||
var release = new ReleaseInfo ();
|
||||
var qRow = row.Cq();
|
||||
var qLink = qRow.Find("a.torrent_name_link").First();
|
||||
|
||||
var qRow = row.Cq ();
|
||||
var qLink = qRow.Find ("a.torrent_name_link").First ();
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Attr("title");
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(BaseUrl + qRow.Find("td.table_links > a").First().Attr("href"));
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Attr ("title");
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri (BaseUrl + qLink.Attr ("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri (BaseUrl + qRow.Find ("td.table_links > a").First ().Attr ("href"));
|
||||
DateTime pubDate;
|
||||
var dateString = qRow.Find("td.table_added").Text().Trim();
|
||||
if (dateString.StartsWith("Today "))
|
||||
pubDate = (DateTime.UtcNow + TimeSpan.Parse(dateString.Split(' ')[1])).ToLocalTime();
|
||||
else if (dateString.StartsWith("Yesterday "))
|
||||
pubDate = (DateTime.UtcNow + TimeSpan.Parse(dateString.Split(' ')[1]) - TimeSpan.FromDays(1)).ToLocalTime();
|
||||
else
|
||||
pubDate = DateTime.ParseExact(dateString, "d-MMM-yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime();
|
||||
release.PublishDate = pubDate;
|
||||
|
||||
DateTime pubDate;
|
||||
var dateString = qRow.Find ("td.table_added").Text ().Trim ();
|
||||
if (dateString.StartsWith ("Today "))
|
||||
pubDate = (DateTime.UtcNow + TimeSpan.Parse (dateString.Split (' ') [1])).ToLocalTime ();
|
||||
else if (dateString.StartsWith ("Yesterday "))
|
||||
pubDate = (DateTime.UtcNow + TimeSpan.Parse (dateString.Split (' ') [1]) - TimeSpan.FromDays (1)).ToLocalTime ();
|
||||
else
|
||||
pubDate = DateTime.ParseExact (dateString, "d-MMM-yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime ();
|
||||
release.PublishDate = pubDate;
|
||||
release.Seeders = int.Parse(qRow.Find("td.table_seeders").Text().Trim(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(qRow.Find("td.table_leechers").Text().Trim(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
release.Seeders = int.Parse (qRow.Find ("td.table_seeders").Text ().Trim ());
|
||||
release.Peers = int.Parse (qRow.Find ("td.table_leechers").Text ().Trim ()) + release.Seeders;
|
||||
var sizeCol = qRow.Find("td.table_size")[0];
|
||||
var sizeVal = float.Parse(sizeCol.ChildNodes[0].NodeValue.Trim());
|
||||
var sizeUnit = sizeCol.ChildNodes[2].NodeValue.Trim();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, sizeVal);
|
||||
|
||||
var sizeCol = qRow.Find ("td.table_size") [0];
|
||||
var sizeVal = float.Parse (sizeCol.ChildNodes [0].NodeValue.Trim ());
|
||||
var sizeUnit = sizeCol.ChildNodes [2].NodeValue.Trim ();
|
||||
release.Size = ReleaseInfo.GetBytes (sizeUnit, sizeVal);
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
releases.Add (release);
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
return releases.ToArray ();
|
||||
}
|
||||
|
||||
public async Task<byte[]> Download (Uri link)
|
||||
{
|
||||
var request = CreateHttpRequest (link);
|
||||
var response = await client.SendAsync (request);
|
||||
var bytes = await response.Content.ReadAsByteArrayAsync ();
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
public async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var request = CreateHttpRequest(link);
|
||||
var response = await client.SendAsync(request);
|
||||
var bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -11,181 +12,198 @@ using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class IPTorrents : IndexerInterface
|
||||
{
|
||||
public class IPTorrents : IndexerInterface
|
||||
{
|
||||
|
||||
public event Action<IndexerInterface, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName { get { return "IPTorrents"; } }
|
||||
public string DisplayName { get { return "IPTorrents"; } }
|
||||
|
||||
public string DisplayDescription { get { return "Always a step ahead"; } }
|
||||
public string DisplayDescription { get { return "Always a step ahead"; } }
|
||||
|
||||
public Uri SiteLink { get { return new Uri (BaseUrl); } }
|
||||
public Uri SiteLink { get { return new Uri(BaseUrl); } }
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
static string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
static string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
|
||||
static string BaseUrl = "https://iptorrents.com";
|
||||
|
||||
string SearchUrl = BaseUrl + "/t?q=";
|
||||
|
||||
|
||||
static string BaseUrl = "https://iptorrents.com";
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
string SearchUrl = BaseUrl + "/t?q=";
|
||||
public IPTorrents()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
await client.GetAsync(new Uri(BaseUrl));
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return (ConfigurationData)config;
|
||||
}
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
|
||||
public IPTorrents ()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer ();
|
||||
handler = new HttpClientHandler {
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient (handler);
|
||||
}
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
public async Task<ConfigurationData> GetConfigurationForSetup ()
|
||||
{
|
||||
await client.GetAsync (new Uri (BaseUrl));
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
return (ConfigurationData)config;
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration (JToken configJson)
|
||||
{
|
||||
|
||||
var config = new ConfigurationDataBasicLogin ();
|
||||
config.LoadValuesFromJson (configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent (pairs);
|
||||
var message = new HttpRequestMessage ();
|
||||
message.Method = HttpMethod.Post;
|
||||
message.Content = content;
|
||||
message.RequestUri = new Uri (BaseUrl);
|
||||
message.Headers.Referrer = new Uri (BaseUrl);
|
||||
message.Headers.UserAgent.ParseAdd (chromeUserAgent);
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Post;
|
||||
message.Content = content;
|
||||
message.RequestUri = new Uri(BaseUrl);
|
||||
message.Headers.Referrer = new Uri(BaseUrl);
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
|
||||
var response = await client.SendAsync (message);
|
||||
var responseContent = await response.Content.ReadAsStringAsync ();
|
||||
var response = await client.SendAsync(message);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains ("/my.php")) {
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom ["body > div"].First ();
|
||||
var errorMessage = messageEl.Text ().Trim ();
|
||||
throw new ExceptionWithConfigData (errorMessage, (ConfigurationData)config);
|
||||
} else {
|
||||
var configSaveData = new JObject ();
|
||||
configSaveData ["cookies"] = cookies.ToJson (SiteLink);
|
||||
if (!responseContent.Contains("/my.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom["body > div"].First();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested (this, configSaveData);
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
HttpRequestMessage CreateHttpRequest (Uri uri)
|
||||
{
|
||||
var message = new HttpRequestMessage ();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = uri;
|
||||
message.Headers.UserAgent.ParseAdd (chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
HttpRequestMessage CreateHttpRequest(Uri uri)
|
||||
{
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = uri;
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration (Newtonsoft.Json.Linq.JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson (new Uri (BaseUrl), (JArray)jsonConfig ["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
public void LoadFromSavedConfiguration(Newtonsoft.Json.Linq.JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery (TorznabQuery query)
|
||||
{
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
|
||||
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 episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode (searchString);
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
||||
|
||||
var request = CreateHttpRequest (new Uri (episodeSearchUrl));
|
||||
var response = await client.SendAsync (request);
|
||||
var results = await response.Content.ReadAsStringAsync ();
|
||||
var request = CreateHttpRequest(new Uri(episodeSearchUrl));
|
||||
var response = await client.SendAsync(request);
|
||||
var results = await response.Content.ReadAsStringAsync();
|
||||
|
||||
CQ dom = results;
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
var rows = dom ["table.torrents > tbody > tr"];
|
||||
foreach (var row in rows.Skip(1)) {
|
||||
var release = new ReleaseInfo ();
|
||||
var rows = dom["table.torrents > tbody > tr"];
|
||||
foreach (var row in rows.Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
var qRow = row.Cq ();
|
||||
var qRow = row.Cq();
|
||||
|
||||
var qTitleLink = qRow.Find ("a.t_title").First ();
|
||||
release.Title = qTitleLink.Text ().Trim ();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri (BaseUrl + qTitleLink.Attr ("href"));
|
||||
release.Comments = release.Guid;
|
||||
var qTitleLink = qRow.Find("a.t_title").First();
|
||||
release.Title = qTitleLink.Text().Trim();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(BaseUrl + qTitleLink.Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
|
||||
DateTime pubDate;
|
||||
var descString = qRow.Find (".t_ctime").Text ();
|
||||
var dateString = descString.Split ('|').Last ().Trim ();
|
||||
dateString = dateString.Split (new string[] { " by " }, StringSplitOptions.None) [0];
|
||||
var dateValue = float.Parse (dateString.Split (' ') [0]);
|
||||
var dateUnit = dateString.Split (' ') [1];
|
||||
if (dateUnit.Contains ("minute"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromMinutes (dateValue);
|
||||
else if (dateUnit.Contains ("hour"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromHours (dateValue);
|
||||
else if (dateUnit.Contains ("day"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays (dateValue);
|
||||
else if (dateUnit.Contains ("week"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays (7 * dateValue);
|
||||
else if (dateUnit.Contains ("month"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays (30 * dateValue);
|
||||
else if (dateUnit.Contains ("year"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays (365 * dateValue);
|
||||
else
|
||||
pubDate = DateTime.MinValue;
|
||||
release.PublishDate = pubDate;
|
||||
DateTime pubDate;
|
||||
var descString = qRow.Find(".t_ctime").Text();
|
||||
var dateString = descString.Split('|').Last().Trim();
|
||||
dateString = dateString.Split(new string[] { " by " }, StringSplitOptions.None)[0];
|
||||
var dateValue = float.Parse(dateString.Split(' ')[0]);
|
||||
var dateUnit = dateString.Split(' ')[1];
|
||||
if (dateUnit.Contains("minute"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromMinutes(dateValue);
|
||||
else if (dateUnit.Contains("hour"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromHours(dateValue);
|
||||
else if (dateUnit.Contains("day"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays(dateValue);
|
||||
else if (dateUnit.Contains("week"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays(7 * dateValue);
|
||||
else if (dateUnit.Contains("month"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays(30 * dateValue);
|
||||
else if (dateUnit.Contains("year"))
|
||||
pubDate = DateTime.Now - TimeSpan.FromDays(365 * dateValue);
|
||||
else
|
||||
pubDate = DateTime.MinValue;
|
||||
release.PublishDate = pubDate;
|
||||
|
||||
var qLink = row.ChildElements.ElementAt (3).Cq ().Children ("a");
|
||||
release.Link = new Uri (BaseUrl + qLink.Attr ("href"));
|
||||
var qLink = row.ChildElements.ElementAt(3).Cq().Children("a");
|
||||
release.Link = new Uri(BaseUrl + qLink.Attr("href"));
|
||||
|
||||
var sizeStr = row.ChildElements.ElementAt (5).Cq ().Text ().Trim ();
|
||||
var sizeVal = float.Parse (sizeStr.Split (' ') [0]);
|
||||
var sizeUnit = sizeStr.Split (' ') [1];
|
||||
release.Size = ReleaseInfo.GetBytes (sizeUnit, sizeVal);
|
||||
var sizeStr = row.ChildElements.ElementAt(5).Cq().Text().Trim();
|
||||
var sizeVal = float.Parse(sizeStr.Split(' ')[0]);
|
||||
var sizeUnit = sizeStr.Split(' ')[1];
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, sizeVal);
|
||||
|
||||
release.Seeders = int.Parse (qRow.Find (".t_seeders").Text ().Trim ());
|
||||
release.Peers = int.Parse (qRow.Find (".t_leechers").Text ().Trim ()) + release.Seeders;
|
||||
release.Seeders = int.Parse(qRow.Find(".t_seeders").Text().Trim(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(qRow.Find(".t_leechers").Text().Trim(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
releases.Add (release);
|
||||
}
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return releases.ToArray ();
|
||||
return releases.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<byte[]> Download (Uri link)
|
||||
{
|
||||
var request = CreateHttpRequest (link);
|
||||
var response = await client.SendAsync (request);
|
||||
var bytes = await response.Content.ReadAsByteArrayAsync ();
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
public async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var request = CreateHttpRequest(link);
|
||||
var response = await client.SendAsync(request);
|
||||
var bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ namespace Jackett.Indexers
|
||||
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace Jackett.Indexers
|
||||
string responseContent;
|
||||
JArray cookieJArray;
|
||||
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
// If Windows use .net http
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
@@ -95,7 +96,7 @@ namespace Jackett.Indexers
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
cookieHeader = response.CookieHeader;
|
||||
cookieJArray = new JArray(response.CookiesFlat);
|
||||
@@ -150,45 +151,53 @@ namespace Jackett.Indexers
|
||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
||||
|
||||
string results;
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
results = await client.GetStringAsync(episodeSearchUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await CurlHelper.Shared.GetAsync(episodeSearchUrl, cookieHeader);
|
||||
var response = await CurlHelper.GetAsync(episodeSearchUrl, cookieHeader);
|
||||
results = Encoding.UTF8.GetString(response.Content);
|
||||
}
|
||||
|
||||
var json = JObject.Parse(results);
|
||||
foreach (JObject r in json["response"]["results"])
|
||||
try
|
||||
{
|
||||
|
||||
var pubDate = UnixTimestampToDateTime(double.Parse((string)r["groupTime"]));
|
||||
var groupName = (string)r["groupName"];
|
||||
|
||||
if (r["torrents"] is JArray)
|
||||
var json = JObject.Parse(results);
|
||||
foreach (JObject r in json["response"]["results"])
|
||||
{
|
||||
foreach (JObject t in r["torrents"])
|
||||
|
||||
var pubDate = UnixTimestampToDateTime(double.Parse((string)r["groupTime"]));
|
||||
var groupName = (string)r["groupName"];
|
||||
|
||||
if (r["torrents"] is JArray)
|
||||
{
|
||||
foreach (JObject t in r["torrents"])
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
release.PublishDate = pubDate;
|
||||
release.Title = groupName;
|
||||
release.Description = groupName;
|
||||
FillReleaseInfoFromJson(release, t);
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
release.PublishDate = pubDate;
|
||||
release.Title = groupName;
|
||||
release.Description = groupName;
|
||||
FillReleaseInfoFromJson(release, t);
|
||||
FillReleaseInfoFromJson(release, r);
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
release.PublishDate = pubDate;
|
||||
release.Title = groupName;
|
||||
release.Description = groupName;
|
||||
FillReleaseInfoFromJson(release, r);
|
||||
releases.Add(release);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,16 +213,17 @@ namespace Jackett.Indexers
|
||||
|
||||
public async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
return await client.GetByteArrayAsync(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await CurlHelper.Shared.GetAsync(link.ToString(), cookieHeader);
|
||||
var response = await CurlHelper.GetAsync(link.ToString(), cookieHeader);
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
160
src/Jackett/Indexers/Rarbg.cs
Normal file
160
src/Jackett/Indexers/Rarbg.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using CsQuery;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class Rarbg : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "RARBG"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return DisplayName; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri("https://rarbg.com"); }
|
||||
}
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
const string DefaultUrl = "http://torrentapi.org";
|
||||
|
||||
const string TokenUrl = "/pubapi.php?get_token=get_token&format=json";
|
||||
const string SearchTVRageUrl = "/pubapi.php?mode=search&search_tvrage={0}&token={1}&format=json&min_seeders=1";
|
||||
const string SearchQueryUrl = "/pubapi.php?mode=search&search_string={0}&token={1}&format=json&min_seeders=1";
|
||||
|
||||
static string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
|
||||
string BaseUrl;
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public Rarbg()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var formattedUrl = config.GetFormattedHostUrl();
|
||||
var token = await GetToken(formattedUrl);
|
||||
/*var releases = await PerformQuery(new TorznabQuery(), formattedUrl);
|
||||
if (releases.Length == 0)
|
||||
throw new Exception("Could not find releases from this URL");*/
|
||||
|
||||
BaseUrl = formattedUrl;
|
||||
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["base_url"] = BaseUrl;
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
BaseUrl = (string)jsonConfig["base_url"];
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
HttpRequestMessage CreateHttpRequest(string uri)
|
||||
{
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = new Uri(uri);
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
|
||||
async Task<string> GetToken(string url)
|
||||
{
|
||||
var request = CreateHttpRequest(url + TokenUrl);
|
||||
var response = await client.SendAsync(request);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
JObject obj = JObject.Parse(result);
|
||||
return (string)obj["token"];
|
||||
}
|
||||
|
||||
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>();
|
||||
|
||||
string token = await GetToken(baseUrl);
|
||||
string searchUrl;
|
||||
if (query.RageID != 0)
|
||||
searchUrl = string.Format(baseUrl + SearchTVRageUrl, query.RageID, token);
|
||||
else
|
||||
searchUrl = string.Format(baseUrl + SearchQueryUrl, query.SearchTerm, token);
|
||||
|
||||
var request = CreateHttpRequest(searchUrl);
|
||||
var response = await client.SendAsync(request);
|
||||
var results = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var jItems = JArray.Parse(results);
|
||||
foreach (JObject item in jItems)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
release.Title = (string)item["f"];
|
||||
release.MagnetUri = new Uri((string)item["d"]);
|
||||
release.Guid = release.MagnetUri;
|
||||
release.PublishDate = new DateTime(1970, 1, 1);
|
||||
release.Size = 0;
|
||||
release.Seeders = 1;
|
||||
release.Peers = 1;
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
releases.Add(release);
|
||||
}
|
||||
|
||||
return releases.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
155
src/Jackett/Indexers/Strike.cs
Normal file
155
src/Jackett/Indexers/Strike.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class Strike : IndexerInterface
|
||||
{
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "Strike"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return "Torrent search engine"; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(DefaultUrl); }
|
||||
}
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
const string DefaultUrl = "https://getstrike.net";
|
||||
|
||||
const string DownloadUrl = "/api/v2/torrents/download/?hash={0}";
|
||||
const string SearchUrl = "/api/v2/torrents/search/?category=TV&phrase={0}";
|
||||
string BaseUrl;
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public Strike()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var formattedUrl = config.GetFormattedHostUrl();
|
||||
var releases = await PerformQuery(new TorznabQuery(), formattedUrl);
|
||||
if (releases.Length == 0)
|
||||
throw new Exception("Could not find releases from this URL");
|
||||
|
||||
BaseUrl = formattedUrl;
|
||||
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["base_url"] = BaseUrl;
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
BaseUrl = (string)jsonConfig["base_url"];
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query, string baseUrl)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { "2015" })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = baseUrl + string.Format(SearchUrl, HttpUtility.UrlEncode(searchString.Trim()));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
var jResults = JObject.Parse(results);
|
||||
foreach (JObject result in (JArray)jResults["torrents"])
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
|
||||
release.Title = (string)result["torrent_title"];
|
||||
release.Description = release.Title;
|
||||
release.Seeders = (int)result["seeds"];
|
||||
release.Peers = (int)result["leeches"] + release.Seeders;
|
||||
release.Size = (long)result["size"];
|
||||
|
||||
// "Apr 2, 2015", "Apr 12, 2015" (note the spacing)
|
||||
var dateString = string.Join(" ", ((string)result["upload_date"]).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
|
||||
release.PublishDate = DateTime.ParseExact(dateString, "MMM d, yyyy", CultureInfo.InvariantCulture);
|
||||
|
||||
release.Guid = new Uri((string)result["page"]);
|
||||
release.Comments = release.Guid;
|
||||
|
||||
release.InfoHash = (string)result["torrent_hash"];
|
||||
release.MagnetUri = new Uri((string)result["magnet_uri"]);
|
||||
release.Link = new Uri(string.Format("{0}{1}{2}", baseUrl, DownloadUrl, release.InfoHash));
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
return await PerformQuery(query, BaseUrl);
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -16,34 +16,22 @@ namespace Jackett.Indexers
|
||||
public class ThePirateBay : IndexerInterface
|
||||
{
|
||||
|
||||
class ThePirateBayConfig : ConfigurationData
|
||||
{
|
||||
public StringItem Url { get; private set; }
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public ThePirateBayConfig()
|
||||
{
|
||||
Url = new StringItem { Name = "Url", Value = "https://thepiratebay.se/" };
|
||||
}
|
||||
|
||||
public override Item[] GetItems()
|
||||
{
|
||||
return new Item[] { Url };
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<IndexerInterface, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName { get { return "The Pirate Bay"; } }
|
||||
|
||||
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(DefaultUrl); } }
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
static string SearchUrl = "s/?q=\"{0}\"&category=205&page=0&orderby=99";
|
||||
static string BrowserUrl = "browse/200";
|
||||
static string SwitchSingleViewUrl = "switchview.php?view=s";
|
||||
const string DefaultUrl = "https://thepiratebay.se";
|
||||
const string SearchUrl = "/s/?q=\"{0}\"&category=205&page=0&orderby=99";
|
||||
const string SearchUrl2 = "/s/?q=\"{0}\"&category=208&page=0&orderby=99";
|
||||
const string SwitchSingleViewUrl = "/switchview.php?view=s";
|
||||
|
||||
string BaseUrl;
|
||||
|
||||
@@ -51,7 +39,6 @@ namespace Jackett.Indexers
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
|
||||
public ThePirateBay()
|
||||
{
|
||||
IsConfigured = false;
|
||||
@@ -67,24 +54,21 @@ namespace Jackett.Indexers
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ThePirateBayConfig();
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ThePirateBayConfig();
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
config.LoadValuesFromJson(configJson);
|
||||
await TestBrowse(config.Url.Value);
|
||||
BaseUrl = new Uri(config.Url.Value).ToString();
|
||||
|
||||
var message = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(BaseUrl + SwitchSingleViewUrl)
|
||||
};
|
||||
message.Headers.Referrer = new Uri(BaseUrl + BrowserUrl);
|
||||
var response = await client.SendAsync(message);
|
||||
var formattedUrl = config.GetFormattedHostUrl();
|
||||
var releases = await PerformQuery(new TorznabQuery(), formattedUrl);
|
||||
if (releases.Length == 0)
|
||||
throw new Exception("Could not find releases from this URL");
|
||||
|
||||
BaseUrl = formattedUrl;
|
||||
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["base_url"] = BaseUrl;
|
||||
@@ -95,15 +79,6 @@ namespace Jackett.Indexers
|
||||
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)
|
||||
{
|
||||
BaseUrl = (string)jsonConfig["base_url"];
|
||||
@@ -111,71 +86,102 @@ namespace Jackett.Indexers
|
||||
}
|
||||
|
||||
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<string> searchUrls = new List<string>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = BaseUrl + string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var queryStr = HttpUtility.UrlEncode(searchString);
|
||||
var episodeSearchUrl = baseUrl + string.Format(SearchUrl, queryStr);
|
||||
var episodeSearchUrl2 = baseUrl + string.Format(SearchUrl2, queryStr);
|
||||
searchUrls.Add(episodeSearchUrl);
|
||||
searchUrls.Add(episodeSearchUrl2);
|
||||
}
|
||||
|
||||
foreach (var episodeSearchUrl in searchUrls)
|
||||
{
|
||||
var message = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(BaseUrl + SwitchSingleViewUrl)
|
||||
RequestUri = new Uri(baseUrl + SwitchSingleViewUrl)
|
||||
};
|
||||
message.Headers.Referrer = new Uri(episodeSearchUrl);
|
||||
|
||||
var response = await client.SendAsync(message);
|
||||
var results = await response.Content.ReadAsStringAsync();
|
||||
string results;
|
||||
|
||||
CQ dom = results;
|
||||
|
||||
var rows = dom["#searchResult > tbody > tr"];
|
||||
foreach (var row in rows)
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
CQ qRow = row.Cq();
|
||||
CQ qLink = row.ChildElements.ElementAt(1).Cq().Children("a").First();
|
||||
var response = await client.SendAsync(message);
|
||||
results = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await CurlHelper.GetAsync(baseUrl + SwitchSingleViewUrl, null, episodeSearchUrl);
|
||||
results = Encoding.UTF8.GetString(response.Content);
|
||||
}
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Text().Trim();
|
||||
release.Description = release.Title;
|
||||
release.Comments = new Uri(BaseUrl + qLink.Attr("href").TrimStart('/'));
|
||||
release.Guid = release.Comments;
|
||||
|
||||
var timeString = row.ChildElements.ElementAt(2).Cq().Text();
|
||||
if (timeString.Contains("mins ago"))
|
||||
release.PublishDate = (DateTime.Now - TimeSpan.FromMinutes(int.Parse(timeString.Split(' ')[0])));
|
||||
else if (timeString.Contains("Today"))
|
||||
release.PublishDate = (DateTime.UtcNow - TimeSpan.FromHours(2) - TimeSpan.Parse(timeString.Split(' ')[1])).ToLocalTime();
|
||||
else if (timeString.Contains("Y-day"))
|
||||
release.PublishDate = (DateTime.UtcNow - TimeSpan.FromHours(26) - TimeSpan.Parse(timeString.Split(' ')[1])).ToLocalTime();
|
||||
else if (timeString.Contains(':'))
|
||||
var rows = dom["#searchResult > tbody > tr"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var utc = DateTime.ParseExact(timeString, "MM-dd HH:mm", CultureInfo.InvariantCulture) - TimeSpan.FromHours(2);
|
||||
release.PublishDate = DateTime.SpecifyKind(utc, DateTimeKind.Utc).ToLocalTime();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
CQ qLink = row.ChildElements.ElementAt(1).Cq().Children("a").First();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Text().Trim();
|
||||
release.Description = release.Title;
|
||||
release.Comments = new Uri(baseUrl + qLink.Attr("href").TrimStart('/'));
|
||||
release.Guid = release.Comments;
|
||||
|
||||
var timeString = row.ChildElements.ElementAt(2).Cq().Text();
|
||||
if (timeString.Contains("mins ago"))
|
||||
release.PublishDate = (DateTime.Now - TimeSpan.FromMinutes(int.Parse(timeString.Split(' ')[0])));
|
||||
else if (timeString.Contains("Today"))
|
||||
release.PublishDate = (DateTime.UtcNow - TimeSpan.FromHours(2) - TimeSpan.Parse(timeString.Split(' ')[1])).ToLocalTime();
|
||||
else if (timeString.Contains("Y-day"))
|
||||
release.PublishDate = (DateTime.UtcNow - TimeSpan.FromHours(26) - TimeSpan.Parse(timeString.Split(' ')[1])).ToLocalTime();
|
||||
else if (timeString.Contains(':'))
|
||||
{
|
||||
var utc = DateTime.ParseExact(timeString, "MM-dd HH:mm", CultureInfo.InvariantCulture) - TimeSpan.FromHours(2);
|
||||
release.PublishDate = DateTime.SpecifyKind(utc, DateTimeKind.Utc).ToLocalTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
var utc = DateTime.ParseExact(timeString, "MM-dd yyyy", CultureInfo.InvariantCulture) - TimeSpan.FromHours(2);
|
||||
release.PublishDate = DateTime.SpecifyKind(utc, DateTimeKind.Utc).ToLocalTime();
|
||||
}
|
||||
|
||||
var downloadCol = row.ChildElements.ElementAt(3).Cq().Find("a");
|
||||
release.MagnetUri = new Uri(downloadCol.Attr("href"));
|
||||
release.InfoHash = release.MagnetUri.ToString().Split(':')[3].Split('&')[0];
|
||||
|
||||
var sizeString = row.ChildElements.ElementAt(4).Cq().Text().Split(' ');
|
||||
var sizeVal = float.Parse(sizeString[0]);
|
||||
var sizeUnit = sizeString[1];
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, sizeVal);
|
||||
|
||||
release.Seeders = int.Parse(row.ChildElements.ElementAt(5).Cq().Text());
|
||||
release.Peers = int.Parse(row.ChildElements.ElementAt(6).Cq().Text()) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
else
|
||||
{
|
||||
var utc = DateTime.ParseExact(timeString, "MM-dd yyyy", CultureInfo.InvariantCulture) - TimeSpan.FromHours(2);
|
||||
release.PublishDate = DateTime.SpecifyKind(utc, DateTimeKind.Utc).ToLocalTime();
|
||||
}
|
||||
|
||||
var downloadCol = row.ChildElements.ElementAt(3).Cq().Find("a");
|
||||
release.MagnetUrl = new Uri(downloadCol.Attr("href"));
|
||||
release.InfoHash = release.MagnetUrl.ToString().Split(':')[3].Split('&')[0];
|
||||
|
||||
var sizeString = row.ChildElements.ElementAt(4).Cq().Text().Split(' ');
|
||||
var sizeVal = float.Parse(sizeString[0]);
|
||||
var sizeUnit = sizeString[1];
|
||||
release.Size = ReleaseInfo.GetBytes(sizeUnit, sizeVal);
|
||||
|
||||
release.Seeders = int.Parse(row.ChildElements.ElementAt(5).Cq().Text());
|
||||
release.Peers = int.Parse(row.ChildElements.ElementAt(6).Cq().Text()) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
@@ -187,5 +193,7 @@ namespace Jackett.Indexers
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
178
src/Jackett/Indexers/TorrentDay.cs
Normal file
178
src/Jackett/Indexers/TorrentDay.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using CsQuery;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentDay : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "TorrentDay"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return DisplayName; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(BaseUrl); }
|
||||
}
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
const string BaseUrl = "https://torrentday.eu";
|
||||
const string LoginUrl = BaseUrl + "/takelogin.php";
|
||||
const string SearchUrl = BaseUrl + "/browse.php?search={0}&cata=yes&c2=1&c7=1&c14=1&c24=1&c26=1&c31=1&c32=1&c33=1";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public TorrentDay()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "keeplogged", "1" },
|
||||
{ "login", "Login" }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains("logout.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom["#login"];
|
||||
messageEl.Children("form").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
var rows = dom["#torrentTable > tbody > tr.browse"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ qRow = row.Cq();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qRow.Find(".torrentName").Text();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(BaseUrl + "/" + qRow.Find(".torrentName").Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(BaseUrl + "/" + qRow.Find(".dlLinksInfo > a").Attr("href"));
|
||||
|
||||
var sizeStr = qRow.Find(".sizeInfo").Text().Trim();
|
||||
var sizeParts = sizeStr.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeParts[1], float.Parse(sizeParts[0]));
|
||||
|
||||
var dateStr = qRow.Find(".ulInfo").Text().Trim();
|
||||
var dateParts = dateStr.Split(' ');
|
||||
var dateValue = int.Parse(dateParts[1]);
|
||||
TimeSpan ts = TimeSpan.Zero;
|
||||
if (dateStr.Contains("sec"))
|
||||
ts = TimeSpan.FromSeconds(dateValue);
|
||||
else if (dateStr.Contains("min"))
|
||||
ts = TimeSpan.FromMinutes(dateValue);
|
||||
else if (dateStr.Contains("hour"))
|
||||
ts = TimeSpan.FromHours(dateValue);
|
||||
else if (dateStr.Contains("day"))
|
||||
ts = TimeSpan.FromDays(dateValue);
|
||||
else if (dateStr.Contains("week"))
|
||||
ts = TimeSpan.FromDays(dateValue * 7);
|
||||
else if (dateStr.Contains("month"))
|
||||
ts = TimeSpan.FromDays(dateValue * 30);
|
||||
else if (dateStr.Contains("year"))
|
||||
ts = TimeSpan.FromDays(dateValue * 365);
|
||||
release.PublishDate = DateTime.Now - ts;
|
||||
|
||||
release.Seeders = int.Parse(qRow.Find(".seedersInfo").Text(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(qRow.Find(".leechersInfo").Text(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
}
|
||||
}
|
178
src/Jackett/Indexers/TorrentLeech.cs
Normal file
178
src/Jackett/Indexers/TorrentLeech.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using CsQuery;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentLeech : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "TorrentLeech"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return "This is what happens when you seed"; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(BaseUrl); }
|
||||
}
|
||||
|
||||
const string BaseUrl = "http://www.torrentleech.org";
|
||||
const string LoginUrl = BaseUrl + "/user/account/login/";
|
||||
const string SearchUrl = BaseUrl + "/torrents/browse/index/query/{0}/categories/2%2C26%2C27%2C32/orderby/added?";
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public TorrentLeech()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "remember_me", "on" },
|
||||
{ "login", "submit" }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains("/user/account/logout"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom[".ui-state-error"].Last();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
CQ qRows = dom["#torrenttable > tbody > tr"];
|
||||
|
||||
foreach (var row in qRows)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
var qRow = row.Cq();
|
||||
|
||||
var debug = qRow.Html();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
|
||||
CQ qLink = qRow.Find(".title > a").First();
|
||||
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Title = qLink.Text();
|
||||
release.Description = release.Title;
|
||||
|
||||
release.Link = new Uri(BaseUrl + qRow.Find(".quickdownload > a").Attr("href"));
|
||||
|
||||
var dateString = qRow.Find(".name").First()[0].ChildNodes[4].NodeValue.Replace(" on", "").Trim();
|
||||
//"2015-04-25 23:38:12"
|
||||
//"yyyy-MMM-dd hh:mm:ss"
|
||||
release.PublishDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
|
||||
var sizeStringParts = qRow.Children().ElementAt(4).InnerText.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStringParts[1], float.Parse(sizeStringParts[0]));
|
||||
|
||||
release.Seeders = int.Parse(qRow.Find(".seeders").Text());
|
||||
release.Peers = int.Parse(qRow.Find(".leechers").Text());
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
179
src/Jackett/Indexers/TorrentShack.cs
Normal file
179
src/Jackett/Indexers/TorrentShack.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using CsQuery;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentShack : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "TorrentShack"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return DisplayName; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(BaseUrl); }
|
||||
}
|
||||
|
||||
const string BaseUrl = "http://torrentshack.me";
|
||||
const string LoginUrl = BaseUrl + "/login.php";
|
||||
const string SearchUrl = BaseUrl + "/torrents.php?searchstr={0}&release_type=both&searchtags=&tags_type=0&order_by=s3&order_way=desc&torrent_preset=all&filter_cat%5B600%5D=1&filter_cat%5B620%5D=1&filter_cat%5B700%5D=1&filter_cat%5B981%5D=1&filter_cat%5B980%5D=1";
|
||||
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
public TorrentShack()
|
||||
{
|
||||
IsConfigured = false;
|
||||
cookies = new CookieContainer();
|
||||
handler = new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = true,
|
||||
UseCookies = true,
|
||||
};
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "keeplogged", "1" },
|
||||
{ "login", "Login" }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains("logout.php"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
var messageEl = dom["#loginform"];
|
||||
messageEl.Children("table").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
}
|
||||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookies.ToJson(SiteLink);
|
||||
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
|
||||
{
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
var rows = dom["#torrent_table > tbody > tr.torrent"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ qRow = row.Cq();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qRow.Find(".torrent_name_link").Text();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(BaseUrl + "/" + qRow.Find(".torrent_name_link").Parent().Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(BaseUrl + "/" + qRow.Find(".torrent_handle_links > a").First().Attr("href"));
|
||||
|
||||
var dateStr = qRow.Find(".time").Text().Trim();
|
||||
var dateParts = dateStr.Split(' ');
|
||||
var dateValue = int.Parse(dateParts[0]);
|
||||
TimeSpan ts = TimeSpan.Zero;
|
||||
if (dateStr.Contains("sec"))
|
||||
ts = TimeSpan.FromSeconds(dateValue);
|
||||
else if (dateStr.Contains("min"))
|
||||
ts = TimeSpan.FromMinutes(dateValue);
|
||||
else if (dateStr.Contains("hour"))
|
||||
ts = TimeSpan.FromHours(dateValue);
|
||||
else if (dateStr.Contains("day"))
|
||||
ts = TimeSpan.FromDays(dateValue);
|
||||
else if (dateStr.Contains("week"))
|
||||
ts = TimeSpan.FromDays(dateValue * 7);
|
||||
else if (dateStr.Contains("month"))
|
||||
ts = TimeSpan.FromDays(dateValue * 30);
|
||||
else if (dateStr.Contains("year"))
|
||||
ts = TimeSpan.FromDays(dateValue * 365);
|
||||
release.PublishDate = DateTime.Now - ts;
|
||||
|
||||
var sizeStr = qRow.Find(".size")[0].ChildNodes[0].NodeValue.Trim();
|
||||
var sizeParts = sizeStr.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeParts[1], float.Parse(sizeParts[0]));
|
||||
release.Seeders = int.Parse(qRow.Children().ElementAt(6).InnerText.Trim(), NumberStyles.AllowThousands);
|
||||
release.Peers = int.Parse(qRow.Children().ElementAt(7).InnerText.Trim(), NumberStyles.AllowThousands) + release.Seeders;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
}
|
||||
}
|
@@ -84,6 +84,7 @@
|
||||
<Compile Include="ChannelInfo.cs" />
|
||||
<Compile Include="ConfigurationData.cs" />
|
||||
<Compile Include="ConfigurationDataBasicLogin.cs" />
|
||||
<Compile Include="ConfigurationDataUrl.cs" />
|
||||
<Compile Include="CookieContainerExtensions.cs" />
|
||||
<Compile Include="DataUrl.cs" />
|
||||
<Compile Include="ExceptionWithConfigData.cs" />
|
||||
@@ -94,7 +95,12 @@
|
||||
<Compile Include="Indexers\Freshon.cs" />
|
||||
<Compile Include="Indexers\IPTorrents.cs" />
|
||||
<Compile Include="Indexers\MoreThanTV.cs" />
|
||||
<Compile Include="Indexers\Rarbg.cs" />
|
||||
<Compile Include="Indexers\Strike.cs" />
|
||||
<Compile Include="Indexers\ThePirateBay.cs" />
|
||||
<Compile Include="Indexers\TorrentDay.cs" />
|
||||
<Compile Include="Indexers\TorrentLeech.cs" />
|
||||
<Compile Include="Indexers\TorrentShack.cs" />
|
||||
<Compile Include="Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -137,6 +143,12 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="WebContent\logos\torrentday.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\logos\torrentshack.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="jacket_large.ico" />
|
||||
<Content Include="WebContent\animate.css">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -195,9 +207,15 @@
|
||||
<Content Include="WebContent\logos\rarbg.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\logos\strike.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\logos\thepiratebay.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\logos\torrentleech.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\setup_indexer.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@@ -37,7 +37,7 @@ namespace Jackett
|
||||
|
||||
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
void toolStripMenuItemAutoStart_CheckedChanged(object sender, EventArgs e)
|
||||
|
@@ -14,84 +14,100 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static string AppConfigDirectory = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData), "Jackett");
|
||||
class Program
|
||||
{
|
||||
public static string AppConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett");
|
||||
|
||||
public static Server ServerInstance { get; private set; }
|
||||
public static Server ServerInstance { get; private set; }
|
||||
|
||||
public static bool IsFirstRun { get; private set; }
|
||||
public static bool IsFirstRun { get; private set; }
|
||||
|
||||
public static Logger LoggerInstance { get; private set; }
|
||||
public static Logger LoggerInstance { get; private set; }
|
||||
|
||||
public static ManualResetEvent ExitEvent { get; private set; }
|
||||
public static ManualResetEvent ExitEvent { get; private set; }
|
||||
|
||||
static void Main (string[] args)
|
||||
{
|
||||
ExitEvent = new ManualResetEvent (false);
|
||||
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
||||
|
||||
try {
|
||||
if (!Directory.Exists (AppConfigDirectory)) {
|
||||
IsFirstRun = true;
|
||||
Directory.CreateDirectory (AppConfigDirectory);
|
||||
}
|
||||
Console.WriteLine ("App config/log directory: " + AppConfigDirectory);
|
||||
} catch (Exception ex) {
|
||||
MessageBox.Show ("Could not create settings directory.");
|
||||
Application.Exit ();
|
||||
return;
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
ExitEvent = new ManualResetEvent(false);
|
||||
|
||||
var logConfig = new LoggingConfiguration ();
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(AppConfigDirectory))
|
||||
{
|
||||
IsFirstRun = true;
|
||||
Directory.CreateDirectory(AppConfigDirectory);
|
||||
}
|
||||
Console.WriteLine("App config/log directory: " + AppConfigDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Could not create settings directory. " + ex.Message);
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
var logFile = new FileTarget ();
|
||||
logConfig.AddTarget ("file", logFile);
|
||||
logFile.FileName = Path.Combine (AppConfigDirectory, "log.txt");
|
||||
logFile.Layout = "${longdate} ${level} ${message} \n ${exception:format=ToString}\n";
|
||||
var logFileRule = new LoggingRule ("*", LogLevel.Debug, logFile);
|
||||
logConfig.LoggingRules.Add (logFileRule);
|
||||
var logConfig = new LoggingConfiguration();
|
||||
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||
var logAlert = new MessageBoxTarget ();
|
||||
logConfig.AddTarget ("alert", logAlert);
|
||||
logAlert.Layout = "${message}";
|
||||
logAlert.Caption = "Alert";
|
||||
var logAlertRule = new LoggingRule ("*", LogLevel.Fatal, logAlert);
|
||||
logConfig.LoggingRules.Add (logAlertRule);
|
||||
}
|
||||
var logFile = new FileTarget();
|
||||
logConfig.AddTarget("file", logFile);
|
||||
logFile.Layout = "${longdate} ${level} ${message} \n ${exception:format=ToString}\n";
|
||||
logFile.FileName = Path.Combine(AppConfigDirectory, "log.txt");
|
||||
logFile.ArchiveFileName = "log.{#####}.txt";
|
||||
logFile.ArchiveAboveSize = 500000;
|
||||
logFile.MaxArchiveFiles = 1;
|
||||
logFile.KeepFileOpen = false;
|
||||
logFile.ArchiveNumbering = ArchiveNumberingMode.DateAndSequence;
|
||||
var logFileRule = new LoggingRule("*", LogLevel.Debug, logFile);
|
||||
logConfig.LoggingRules.Add(logFileRule);
|
||||
|
||||
var logConsole = new ConsoleTarget ();
|
||||
logConfig.AddTarget ("console", logConsole);
|
||||
logConsole.Layout = "${longdate} ${level} ${message} ${exception:format=ToString}";
|
||||
var logConsoleRule = new LoggingRule ("*", LogLevel.Debug, logConsole);
|
||||
logConfig.LoggingRules.Add (logConsoleRule);
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
var logAlert = new MessageBoxTarget();
|
||||
logConfig.AddTarget("alert", logAlert);
|
||||
logAlert.Layout = "${message}";
|
||||
logAlert.Caption = "Alert";
|
||||
var logAlertRule = new LoggingRule("*", LogLevel.Fatal, logAlert);
|
||||
logConfig.LoggingRules.Add(logAlertRule);
|
||||
}
|
||||
|
||||
LogManager.Configuration = logConfig;
|
||||
LoggerInstance = LogManager.GetCurrentClassLogger ();
|
||||
var logConsole = new ConsoleTarget();
|
||||
logConfig.AddTarget("console", logConsole);
|
||||
logConsole.Layout = "${longdate} ${level} ${message} ${exception:format=ToString}";
|
||||
var logConsoleRule = new LoggingRule("*", LogLevel.Debug, logConsole);
|
||||
logConfig.LoggingRules.Add(logConsoleRule);
|
||||
|
||||
var serverTask = Task.Run (async () => {
|
||||
ServerInstance = new Server ();
|
||||
await ServerInstance.Start ();
|
||||
});
|
||||
LogManager.Configuration = logConfig;
|
||||
LoggerInstance = LogManager.GetCurrentClassLogger();
|
||||
|
||||
try {
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
Application.Run (new Main ());
|
||||
} catch (Exception ex) {
|
||||
var serverTask = Task.Run(async () =>
|
||||
{
|
||||
ServerInstance = new Server();
|
||||
await ServerInstance.Start();
|
||||
});
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
if (Program.IsWindows)
|
||||
Application.Run(new Main());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
Console.WriteLine ("Running in headless mode.");
|
||||
}
|
||||
|
||||
Task.WaitAll (serverTask);
|
||||
Console.WriteLine ("Server thread exit");
|
||||
}
|
||||
Console.WriteLine("Running in headless mode.");
|
||||
|
||||
static public void RestartAsAdmin ()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo (Application.ExecutablePath.ToString ()) { Verb = "runas" };
|
||||
Process.Start (startInfo);
|
||||
Environment.Exit (0);
|
||||
}
|
||||
}
|
||||
Task.WaitAll(serverTask);
|
||||
Console.WriteLine("Server thread exit");
|
||||
}
|
||||
|
||||
static public void RestartAsAdmin()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
|
||||
Process.Start(startInfo);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ namespace Jackett
|
||||
public Uri ConverUrl { get; set; }
|
||||
public Uri BannerUrl { get; set; }
|
||||
public string InfoHash { get; set; }
|
||||
public Uri MagnetUrl { get; set; }
|
||||
public Uri MagnetUri { get; set; }
|
||||
public double? MinimumRatio { get; set; }
|
||||
public long? MinimumSeedTime { get; set; }
|
||||
|
||||
|
@@ -69,19 +69,19 @@ namespace Jackett
|
||||
select new XElement("item",
|
||||
new XElement("title", r.Title),
|
||||
new XElement("guid", r.Guid),
|
||||
new XElement("comments", r.Comments.ToString()),
|
||||
new XElement("pubDate", xmlDateFormat(r.PublishDate)),
|
||||
new XElement("size", r.Size),
|
||||
r.Comments == null ? null : new XElement("comments", r.Comments.ToString()),
|
||||
r.PublishDate == DateTime.MinValue ? null : new XElement("pubDate", xmlDateFormat(r.PublishDate)),
|
||||
r.Size == null ? null : new XElement("size", r.Size),
|
||||
new XElement("description", r.Description),
|
||||
new XElement("link", r.Link ?? r.MagnetUrl),
|
||||
new XElement("link", r.Link ?? r.MagnetUri),
|
||||
r.Category == null ? null : new XElement("category", r.Category),
|
||||
new XElement(
|
||||
"enclosure",
|
||||
new XAttribute("url", r.Link ?? r.MagnetUrl),
|
||||
new XAttribute("length", r.Size),
|
||||
new XAttribute("url", r.Link ?? r.MagnetUri),
|
||||
r.Size == null ? null : new XAttribute("length", r.Size),
|
||||
new XAttribute("type", "application/x-bittorrent")
|
||||
),
|
||||
getTorznabElement("magneturl", r.MagnetUrl),
|
||||
getTorznabElement("magneturl", r.MagnetUri),
|
||||
getTorznabElement("rageid", r.RageID),
|
||||
getTorznabElement("seeders", r.Seeders),
|
||||
getTorznabElement("peers", r.Peers),
|
||||
|
@@ -34,8 +34,6 @@ namespace Jackett
|
||||
sonarrApi = new SonarrApi();
|
||||
webApi = new WebApi(indexerManager, sonarrApi);
|
||||
|
||||
listener = new HttpListener();
|
||||
listener.Prefixes.Add("http://*:9117/");
|
||||
}
|
||||
|
||||
void LoadApiKey()
|
||||
@@ -56,6 +54,8 @@ namespace Jackett
|
||||
|
||||
try
|
||||
{
|
||||
listener = new HttpListener();
|
||||
listener.Prefixes.Add("http://*:9117/");
|
||||
listener.Start();
|
||||
}
|
||||
catch (HttpListenerException ex)
|
||||
@@ -63,8 +63,8 @@ namespace Jackett
|
||||
if (ex.ErrorCode == 5)
|
||||
{
|
||||
var errorStr = "App must be ran as admin for permission to use port "
|
||||
+ Port + Environment.NewLine + "Restart app with admin privileges?";
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
+ Port + Environment.NewLine + "Restart app with admin privileges?";
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
var dialogResult = MessageBox.Show(errorStr, "Error", MessageBoxButtons.YesNo);
|
||||
if (dialogResult == DialogResult.No)
|
||||
@@ -89,30 +89,29 @@ namespace Jackett
|
||||
|
||||
Program.LoggerInstance.Info("Server started on port " + Port);
|
||||
|
||||
try
|
||||
{
|
||||
#if !DEBUG
|
||||
Process.Start("http://127.0.0.1:" + Port);
|
||||
#endif
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Exception error = null;
|
||||
try
|
||||
{
|
||||
error = null;
|
||||
var context = await listener.GetContextAsync();
|
||||
ProcessHttpRequest(context);
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
Program.LoggerInstance.ErrorException("Critical error, HTTP listener was destroyed", ex);
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex;
|
||||
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
|
||||
}
|
||||
}
|
||||
|
||||
Program.LoggerInstance.Debug("HTTP request servicer thread died");
|
||||
if (error != null)
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
@@ -174,8 +173,6 @@ namespace Jackett
|
||||
|
||||
var query = HttpUtility.ParseQueryString(context.Request.Url.Query);
|
||||
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 indexer = indexerManager.GetIndexer(indexerId);
|
||||
@@ -191,7 +188,10 @@ namespace Jackett
|
||||
|
||||
var torznabQuery = TorznabQuery.FromHttpQuery(query);
|
||||
|
||||
torznabQuery.ShowTitles = await sonarrApi.GetShowTitle(torznabQuery.RageID);
|
||||
if (torznabQuery.RageID != 0)
|
||||
torznabQuery.ShowTitles = await sonarrApi.GetShowTitle(torznabQuery.RageID);
|
||||
else if (!string.IsNullOrEmpty(torznabQuery.SearchTerm))
|
||||
torznabQuery.ShowTitles = new string[] { torznabQuery.SearchTerm };
|
||||
|
||||
var releases = await indexer.PerformQuery(torznabQuery);
|
||||
|
||||
|
@@ -20,6 +20,7 @@ namespace Jackett
|
||||
public int Season { get; private set; }
|
||||
public string Episode { get; private set; }
|
||||
public string[] ShowTitles { get; set; }
|
||||
public string SearchTerm { get; set; }
|
||||
|
||||
public string GetEpisodeSearchString()
|
||||
{
|
||||
@@ -44,6 +45,7 @@ namespace Jackett
|
||||
//{t=tvsearch&cat=5030%2c5040&extended=1&apikey=test&offset=0&limit=100&rid=24493&season=5&ep=1}
|
||||
var q = new TorznabQuery();
|
||||
q.QueryType = query["t"];
|
||||
q.SearchTerm = query["q"];
|
||||
q.Categories = query["cat"].Split(',');
|
||||
q.Extended = int.Parse(query["extended"]);
|
||||
q.ApiKey = query["apikey"];
|
||||
|
@@ -27,17 +27,17 @@ namespace Jackett
|
||||
ApplySonarrConfig,
|
||||
TestSonarr
|
||||
}
|
||||
static Dictionary<string, WebApiMethod> WebApiMethods = new Dictionary<string, WebApiMethod>
|
||||
{
|
||||
{ "get_config_form", WebApiMethod.GetConfigForm },
|
||||
{ "configure_indexer", WebApiMethod.ConfigureIndexer },
|
||||
{ "get_indexers", WebApiMethod.GetIndexers },
|
||||
{ "test_indexer", WebApiMethod.TestIndexer },
|
||||
{ "delete_indexer", WebApiMethod.DeleteIndexer },
|
||||
{ "get_sonarr_config", WebApiMethod.GetSonarrConfig },
|
||||
{ "apply_sonarr_config", WebApiMethod.ApplySonarrConfig },
|
||||
{ "test_sonarr", WebApiMethod.TestSonarr }
|
||||
};
|
||||
|
||||
static Dictionary<string, WebApiMethod> WebApiMethods = new Dictionary<string, WebApiMethod> {
|
||||
{ "get_config_form", WebApiMethod.GetConfigForm },
|
||||
{ "configure_indexer", WebApiMethod.ConfigureIndexer },
|
||||
{ "get_indexers", WebApiMethod.GetIndexers },
|
||||
{ "test_indexer", WebApiMethod.TestIndexer },
|
||||
{ "delete_indexer", WebApiMethod.DeleteIndexer },
|
||||
{ "get_sonarr_config", WebApiMethod.GetSonarrConfig },
|
||||
{ "apply_sonarr_config", WebApiMethod.ApplySonarrConfig },
|
||||
{ "test_sonarr", WebApiMethod.TestSonarr }
|
||||
};
|
||||
|
||||
IndexerManager indexerManager;
|
||||
SonarrApi sonarrApi;
|
||||
@@ -80,7 +80,9 @@ namespace Jackett
|
||||
{
|
||||
await context.Response.OutputStream.WriteAsync(contentFile, 0, contentFile.Length);
|
||||
}
|
||||
catch (HttpListenerException) { }
|
||||
catch (HttpListenerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
async Task<JToken> ReadPostDataJson(Stream stream)
|
||||
@@ -93,8 +95,6 @@ namespace Jackett
|
||||
|
||||
async Task ProcessWebApiRequest(HttpListenerContext context, WebApiMethod method)
|
||||
{
|
||||
var query = HttpUtility.ParseQueryString(context.Request.Url.Query);
|
||||
|
||||
context.Response.ContentType = "text/json";
|
||||
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
margin: 0 auto;
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
margin-bottom: 100px;
|
||||
}
|
||||
|
||||
.container-fluid {
|
||||
|
BIN
src/Jackett/WebContent/logos/strike.png
Normal file
BIN
src/Jackett/WebContent/logos/strike.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
src/Jackett/WebContent/logos/torrentday.png
Normal file
BIN
src/Jackett/WebContent/logos/torrentday.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
src/Jackett/WebContent/logos/torrentleech.png
Normal file
BIN
src/Jackett/WebContent/logos/torrentleech.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
src/Jackett/WebContent/logos/torrentshack.png
Normal file
BIN
src/Jackett/WebContent/logos/torrentshack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Reference in New Issue
Block a user