mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-15 16:34:11 +02:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
976f42b48c | ||
![]() |
0311c3f9a9 | ||
![]() |
e2daa21914 | ||
![]() |
68c3f6ed4e | ||
![]() |
c9df7bc47a | ||
![]() |
f2749ed311 | ||
![]() |
6a3cface7a | ||
![]() |
9f54f87c62 | ||
![]() |
857a123162 | ||
![]() |
27f7ec61f0 | ||
![]() |
adc06388e2 | ||
![]() |
d898725704 | ||
![]() |
e93e95a940 | ||
![]() |
ba419a1b8e | ||
![]() |
eb4b068d54 | ||
![]() |
489c900e00 | ||
![]() |
7753ffdad4 | ||
![]() |
4aca537a92 | ||
![]() |
c0a7d00ffc | ||
![]() |
68dd53b962 | ||
![]() |
9ba12621a5 | ||
![]() |
1faf5099f5 | ||
![]() |
bc8b1d14d5 | ||
![]() |
f781deb4a9 | ||
![]() |
8d39a4b1a7 |
@@ -28,6 +28,9 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
|
||||
* [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
|
||||
|
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);
|
||||
}
|
||||
}
|
||||
}
|
28
src/Jackett/HttpClientExtensions.cs
Normal file
28
src/Jackett/HttpClientExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public static class HttpClientExtensions
|
||||
{
|
||||
public static async Task<string> GetStringAsync(this HttpClient client, string uri, int retries)
|
||||
{
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
return await client.GetStringAsync(uri);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
}
|
||||
if (retries > 0)
|
||||
return await client.GetStringAsync(uri, --retries);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,6 +14,8 @@ namespace Jackett
|
||||
// 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; }
|
||||
|
@@ -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");
|
||||
|
232
src/Jackett/Indexers/AlphaRatio.cs
Normal file
232
src/Jackett/Indexers/AlphaRatio.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
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;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class AlphaRatio : IndexerInterface
|
||||
{
|
||||
public string DisplayName
|
||||
{
|
||||
get { return "AlphaRatio"; }
|
||||
}
|
||||
|
||||
public string DisplayDescription
|
||||
{
|
||||
get { return "Legendary"; }
|
||||
}
|
||||
|
||||
public Uri SiteLink
|
||||
{
|
||||
get { return new Uri(BaseUrl); }
|
||||
}
|
||||
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
static string BaseUrl = "https://alpharatio.cc";
|
||||
|
||||
static string LoginUrl = BaseUrl + "/login.php";
|
||||
|
||||
static string SearchUrl = BaseUrl + "/ajax.php?action=browse&searchstr=";
|
||||
|
||||
static string DownloadUrl = BaseUrl + "/torrents.php?action=download&id=";
|
||||
|
||||
static string GuidUrl = BaseUrl + "/torrents.php?torrentid=";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
||||
string cookieHeader;
|
||||
|
||||
public AlphaRatio()
|
||||
{
|
||||
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 },
|
||||
{ "login", "Log in" },
|
||||
{ "keeplogged", "1" }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
|
||||
string responseContent;
|
||||
JArray cookieJArray;
|
||||
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
// If Windows use .net http
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
responseContent = await response.Content.ReadAsStringAsync();
|
||||
cookieJArray = cookies.ToJson(SiteLink);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If UNIX system use curl
|
||||
var response = await CurlHelper.PostAsync(LoginUrl, pairs);
|
||||
responseContent = Encoding.UTF8.GetString(response.Content);
|
||||
cookieHeader = response.CookieHeader;
|
||||
cookieJArray = new JArray(response.CookiesFlat);
|
||||
}
|
||||
|
||||
if (!responseContent.Contains("logout.php?"))
|
||||
{
|
||||
CQ dom = responseContent;
|
||||
dom["#loginform > table"].Remove();
|
||||
var errorMessage = dom["#loginform"].Text().Trim().Replace("\n\t", " ");
|
||||
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookieJArray;
|
||||
if (OnSaveConfigurationRequested != null)
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookies.FillFromJson(SiteLink, (JArray)jsonConfig["cookies"]);
|
||||
cookieHeader = cookies.GetCookieHeader(SiteLink);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
|
||||
{
|
||||
var id = r["torrentId"];
|
||||
release.Size = (long)r["size"];
|
||||
release.Seeders = (int)r["seeders"];
|
||||
release.Peers = (int)r["leechers"] + release.Seeders;
|
||||
release.Guid = new Uri(GuidUrl + id);
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(DownloadUrl + id);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
string results;
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
results = await client.GetStringAsync(episodeSearchUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await CurlHelper.GetAsync(episodeSearchUrl, cookieHeader);
|
||||
results = Encoding.UTF8.GetString(response.Content);
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
var json = JObject.Parse(results);
|
||||
foreach (JObject r in json["response"]["results"])
|
||||
{
|
||||
DateTime pubDate = DateTime.MinValue;
|
||||
double dateNum;
|
||||
if (double.TryParse((string)r["groupTime"], out dateNum))
|
||||
pubDate = UnixTimestampToDateTime(dateNum);
|
||||
|
||||
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, r);
|
||||
releases.Add(release);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
return releases.ToArray();
|
||||
}
|
||||
|
||||
static DateTime UnixTimestampToDateTime(double unixTime)
|
||||
{
|
||||
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
|
||||
long unixTimeStampInTicks = (long)(unixTime * TimeSpan.TicksPerSecond);
|
||||
return new DateTime(unixStart.Ticks + unixTimeStampInTicks);
|
||||
}
|
||||
|
||||
public async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
return await client.GetByteArrayAsync(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await CurlHelper.GetAsync(link.ToString(), cookieHeader);
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ namespace Jackett
|
||||
HttpClient client;
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public BitMeTV()
|
||||
{
|
||||
@@ -136,46 +137,54 @@ namespace Jackett
|
||||
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 table = dom["tbody > tr > .latest"].Parent().Parent();
|
||||
|
||||
foreach (var row in table.Children().Skip(1))
|
||||
try
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
CQ dom = results;
|
||||
|
||||
CQ qDetailsCol = row.ChildElements.ElementAt(1).Cq();
|
||||
CQ qLink = qDetailsCol.Children("a").First();
|
||||
var table = dom["tbody > tr > .latest"].Parent().Parent();
|
||||
|
||||
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;
|
||||
foreach (var row in table.Children().Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
//"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);
|
||||
CQ qDetailsCol = row.ChildElements.ElementAt(1).Cq();
|
||||
CQ qLink = qDetailsCol.Children("a").First();
|
||||
|
||||
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
|
||||
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;
|
||||
|
||||
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);
|
||||
//"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.Seeders = int.Parse(row.ChildElements.ElementAt(8).Cq().Text());
|
||||
release.Peers = int.Parse(row.ChildElements.ElementAt(9).Cq().Text()) + release.Seeders;
|
||||
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
|
||||
|
||||
if (!release.Title.ToLower().Contains(title.ToLower()))
|
||||
continue;
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
//if (!release.Title.ToLower().Contains(title.ToLower()))
|
||||
// continue;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,5 +196,6 @@ namespace Jackett
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -30,6 +31,7 @@ namespace Jackett.Indexers
|
||||
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
@@ -48,6 +50,7 @@ namespace Jackett.Indexers
|
||||
HttpClient client;
|
||||
|
||||
string cookieHeader;
|
||||
int retries = 3;
|
||||
|
||||
public MoreThanTV()
|
||||
{
|
||||
@@ -128,7 +131,7 @@ namespace Jackett.Indexers
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
|
||||
static void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
|
||||
{
|
||||
var id = r["torrentId"];
|
||||
release.Size = (long)r["size"];
|
||||
@@ -152,43 +155,54 @@ namespace Jackett.Indexers
|
||||
string results;
|
||||
if (Program.IsWindows)
|
||||
{
|
||||
results = await client.GetStringAsync(episodeSearchUrl);
|
||||
results = await client.GetStringAsync(episodeSearchUrl, retries);
|
||||
}
|
||||
else
|
||||
{
|
||||
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"])
|
||||
DateTime pubDate = DateTime.MinValue;
|
||||
double dateNum;
|
||||
if (double.TryParse((string)r["groupTime"], out dateNum))
|
||||
pubDate = UnixTimestampToDateTime(dateNum);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
166
src/Jackett/Indexers/Rarbg.cs
Normal file
166
src/Jackett/Indexers/Rarbg.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
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();
|
||||
try
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
}
|
||||
return releases.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,23 +14,8 @@ namespace Jackett.Indexers
|
||||
public class Strike : IndexerInterface
|
||||
{
|
||||
|
||||
class StrikeConfig : ConfigurationData
|
||||
{
|
||||
public StringItem Url { get; private set; }
|
||||
|
||||
public StrikeConfig()
|
||||
{
|
||||
Url = new StringItem { Name = "Url", Value = DefaultUrl };
|
||||
}
|
||||
|
||||
public override Item[] GetItems()
|
||||
{
|
||||
return new Item[] { Url };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
@@ -74,17 +59,16 @@ namespace Jackett.Indexers
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var config = new StrikeConfig();
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new StrikeConfig();
|
||||
var config = new ConfigurationDataUrl(DefaultUrl);
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var uri = new Uri(config.Url.Value);
|
||||
var formattedUrl = string.Format("{0}://{1}", uri.Scheme, uri.Host);
|
||||
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");
|
||||
@@ -116,32 +100,40 @@ namespace Jackett.Indexers
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = baseUrl + string.Format(SearchUrl, HttpUtility.UrlEncode(searchString.Trim()));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
var jResults = JObject.Parse(results);
|
||||
foreach (JObject result in (JArray)jResults["torrents"])
|
||||
try
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
var jResults = JObject.Parse(results);
|
||||
foreach (JObject result in (JArray)jResults["torrents"])
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
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"];
|
||||
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);
|
||||
// "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.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));
|
||||
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);
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,5 +149,7 @@ namespace Jackett.Indexers
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -16,22 +16,9 @@ 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 = DefaultUrl };
|
||||
}
|
||||
|
||||
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"; } }
|
||||
|
||||
@@ -41,8 +28,9 @@ namespace Jackett.Indexers
|
||||
|
||||
public bool IsConfigured { get; private set; }
|
||||
|
||||
const string DefaultUrl = "https://thepiratebay.se";
|
||||
const string DefaultUrl = "https://thepiratebay.gd";
|
||||
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,17 +54,16 @@ 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);
|
||||
|
||||
var uri = new Uri(config.Url.Value);
|
||||
var formattedUrl = string.Format("{0}://{1}", uri.Scheme, uri.Host);
|
||||
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");
|
||||
@@ -91,7 +77,6 @@ namespace Jackett.Indexers
|
||||
OnSaveConfigurationRequested(this, configSaveData);
|
||||
|
||||
IsConfigured = true;
|
||||
|
||||
}
|
||||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
@@ -109,11 +94,20 @@ namespace Jackett.Indexers
|
||||
{
|
||||
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,
|
||||
@@ -133,54 +127,61 @@ namespace Jackett.Indexers
|
||||
var response = await CurlHelper.GetAsync(baseUrl + SwitchSingleViewUrl, null, episodeSearchUrl);
|
||||
results = Encoding.UTF8.GetString(response.Content);
|
||||
}
|
||||
|
||||
CQ dom = results;
|
||||
|
||||
var rows = dom["#searchResult > tbody > tr"];
|
||||
foreach (var row in rows)
|
||||
try
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
CQ dom = results;
|
||||
|
||||
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 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.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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnResultParsingError(this, results, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return releases.ToArray();
|
||||
@@ -192,5 +193,7 @@ namespace Jackett.Indexers
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
195
src/Jackett/Indexers/TorrentDay.cs
Normal file
195
src/Jackett/Indexers/TorrentDay.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
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 StartPageUrl = BaseUrl + "/login.php";
|
||||
const string LoginUrl = BaseUrl + "/tak3login.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";
|
||||
|
||||
const 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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
HttpRequestMessage CreateHttpRequest(string uri)
|
||||
{
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = new Uri(uri);
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var startMessage = CreateHttpRequest(StartPageUrl);
|
||||
var results = await (await client.SendAsync(startMessage)).Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value }
|
||||
};
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
var loginRequest = CreateHttpRequest(LoginUrl);
|
||||
loginRequest.Method = HttpMethod.Post;
|
||||
loginRequest.Content = content;
|
||||
loginRequest.Headers.Referrer = new Uri(StartPageUrl);
|
||||
|
||||
var response = await client.SendAsync(loginRequest);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@ namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentLeech : IndexerInterface
|
||||
{
|
||||
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
|
||||
|
||||
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
|
||||
|
||||
@@ -114,51 +115,64 @@ namespace Jackett.Indexers
|
||||
var searchString = title + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
||||
var results = await client.GetStringAsync(episodeSearchUrl);
|
||||
CQ dom = results;
|
||||
|
||||
CQ qRows = dom["#torrenttable > tbody > tr"];
|
||||
|
||||
foreach (var row in qRows)
|
||||
try
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
CQ dom = results;
|
||||
|
||||
var qRow = row.Cq();
|
||||
CQ qRows = dom["#torrenttable > tbody > tr"];
|
||||
|
||||
var debug = qRow.Html();
|
||||
foreach (var row in qRows)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
var qRow = row.Cq();
|
||||
|
||||
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;
|
||||
var debug = qRow.Html();
|
||||
|
||||
release.Link = new Uri(BaseUrl + qRow.Find(".quickdownload > a").Attr("href"));
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
var sizeStringParts = qRow.Children().ElementAt(4).InnerText.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStringParts[1], float.Parse(sizeStringParts[0]));
|
||||
release.Link = new Uri(BaseUrl + qRow.Find(".quickdownload > a").Attr("href"));
|
||||
|
||||
release.Seeders = int.Parse(qRow.Find(".seeders").Text());
|
||||
release.Peers = int.Parse(qRow.Find(".leechers").Text());
|
||||
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);
|
||||
|
||||
releases.Add(release);
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return client.GetByteArrayAsync(link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
184
src/Jackett/Indexers/TorrentShack.cs
Normal file
184
src/Jackett/Indexers/TorrentShack.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
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();
|
||||
if (dateStr.ToLower().Contains("just now"))
|
||||
release.PublishDate = DateTime.Now;
|
||||
else
|
||||
{
|
||||
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], NumberStyles.AllowThousands));
|
||||
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,9 +84,11 @@
|
||||
<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" />
|
||||
<Compile Include="HttpClientExtensions.cs" />
|
||||
<Compile Include="IndexerInterface.cs" />
|
||||
<Compile Include="IndexerManager.cs" />
|
||||
<Compile Include="Indexers\BitHdtv.cs" />
|
||||
@@ -94,9 +96,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>
|
||||
@@ -118,6 +123,7 @@
|
||||
<Compile Include="TVRage.cs" />
|
||||
<Compile Include="WebApi.cs" />
|
||||
<Compile Include="CurlHelper.cs" />
|
||||
<Compile Include="Indexers\AlphaRatio.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
@@ -139,6 +145,9 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="WebContent\logos\torrentday.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="WebContent\logos\torrentshack.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -213,6 +222,9 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\validator_reply.xml" />
|
||||
<Content Include="WebContent\logos\alpharatio.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CurlSharp\CurlSharp.csproj">
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using NLog;
|
||||
using Jackett.Indexers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using System;
|
||||
@@ -28,6 +30,8 @@ namespace Jackett
|
||||
|
||||
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
||||
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
ExitEvent = new ManualResetEvent(false);
|
||||
@@ -81,6 +85,8 @@ namespace Jackett
|
||||
LogManager.Configuration = logConfig;
|
||||
LoggerInstance = LogManager.GetCurrentClassLogger();
|
||||
|
||||
ReadSettingsFile();
|
||||
|
||||
var serverTask = Task.Run(async () =>
|
||||
{
|
||||
ServerInstance = new Server();
|
||||
@@ -99,10 +105,32 @@ namespace Jackett
|
||||
|
||||
Console.WriteLine("Running in headless mode.");
|
||||
|
||||
|
||||
|
||||
Task.WaitAll(serverTask);
|
||||
Console.WriteLine("Server thread exit");
|
||||
}
|
||||
|
||||
static void ReadSettingsFile()
|
||||
{
|
||||
var path = Path.Combine(AppConfigDirectory, "config.json");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
JObject f = new JObject();
|
||||
f.Add("port", Server.DefaultPort);
|
||||
f.Add("public", true);
|
||||
File.WriteAllText(path, f.ToString());
|
||||
}
|
||||
|
||||
var configJson = JObject.Parse(File.ReadAllText(path));
|
||||
int port = (int)configJson.GetValue("port");
|
||||
Server.Port = port;
|
||||
|
||||
Server.ListenPublic = (bool)configJson.GetValue("public");
|
||||
|
||||
Console.WriteLine("Config file path: " + path);
|
||||
}
|
||||
|
||||
static public void RestartAsAdmin()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
|
||||
|
@@ -69,16 +69,16 @@ 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.MagnetUri),
|
||||
r.Category == null ? null : new XElement("category", r.Category),
|
||||
new XElement(
|
||||
"enclosure",
|
||||
new XAttribute("url", r.Link ?? r.MagnetUri),
|
||||
new XAttribute("length", r.Size),
|
||||
r.Size == null ? null : new XAttribute("length", r.Size),
|
||||
new XAttribute("type", "application/x-bittorrent")
|
||||
),
|
||||
getTorznabElement("magneturl", r.MagnetUri),
|
||||
|
@@ -15,7 +15,9 @@ namespace Jackett
|
||||
{
|
||||
public class Server
|
||||
{
|
||||
public const int Port = 9117;
|
||||
public const int DefaultPort = 9117;
|
||||
public static int Port = DefaultPort;
|
||||
public static bool ListenPublic = true;
|
||||
|
||||
HttpListener listener;
|
||||
IndexerManager indexerManager;
|
||||
@@ -55,7 +57,13 @@ namespace Jackett
|
||||
try
|
||||
{
|
||||
listener = new HttpListener();
|
||||
listener.Prefixes.Add("http://*:9117/");
|
||||
listener.Prefixes.Add(string.Format("http://127.0.0.1:{0}/", Port));
|
||||
listener.Prefixes.Add(string.Format("http://localhost:{0}/", Port));
|
||||
if (ListenPublic)
|
||||
{
|
||||
listener.Prefixes.Add(string.Format("http://*:{0}/", Port));
|
||||
}
|
||||
|
||||
listener.Start();
|
||||
}
|
||||
catch (HttpListenerException ex)
|
||||
@@ -88,6 +96,7 @@ namespace Jackett
|
||||
}
|
||||
|
||||
Program.LoggerInstance.Info("Server started on port " + Port);
|
||||
Program.LoggerInstance.Info("Accepting only requests from local system: " + (!ListenPublic));
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -190,7 +199,7 @@ namespace Jackett
|
||||
|
||||
if (torznabQuery.RageID != 0)
|
||||
torznabQuery.ShowTitles = await sonarrApi.GetShowTitle(torznabQuery.RageID);
|
||||
else
|
||||
else if (!string.IsNullOrEmpty(torznabQuery.SearchTerm))
|
||||
torznabQuery.ShowTitles = new string[] { torznabQuery.SearchTerm };
|
||||
|
||||
var releases = await indexer.PerformQuery(torznabQuery);
|
||||
|
BIN
src/Jackett/WebContent/logos/alpharatio.png
Normal file
BIN
src/Jackett/WebContent/logos/alpharatio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 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/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