Change indexers to use new api

This commit is contained in:
Kayomani
2015-07-19 18:18:54 +01:00
parent 43f5f5eda2
commit 0dcebe9ced
37 changed files with 532 additions and 957 deletions

View File

@@ -115,6 +115,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CurlSharp\CurlSharp.csproj">
<Project>{74420a79-cc16-442c-8b1e-7c1b913844f0}</Project>
<Name>CurlSharp</Name>
</ProjectReference>
<ProjectReference Include="..\Jackett\Jackett.csproj">
<Project>{e636d5f8-68b4-4903-b4ed-ccfd9c9e899f}</Project>
<Name>Jackett</Name>

View File

@@ -121,6 +121,10 @@
<Content Include="jackett.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CurlSharp\CurlSharp.csproj">
<Project>{74420a79-cc16-442c-8b1e-7c1b913844f0}</Project>
<Name>CurlSharp</Name>
</ProjectReference>
<ProjectReference Include="..\Jackett\Jackett.csproj">
<Project>{e636d5f8-68b4-4903-b4ed-ccfd9c9e899f}</Project>
<Name>Jackett</Name>

View File

@@ -1,5 +1,4 @@
#if !__MonoCS__
using Microsoft.Win32;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -92,5 +91,4 @@ namespace JackettTray
shortcut.Save();*/
}
}
}
#endif
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -57,7 +57,7 @@ namespace Jackett.Controllers
continue;
var originalLink = release.Link;
var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(originalLink.ToString())) + "/download.torrent";
var proxyLink = string.Format("{0}api/{1}/download/{2}", severUrl, indexer.DisplayName.ToLowerInvariant(), encodedLink);
var proxyLink = string.Format("{0}api/{1}/download/{2}", severUrl, indexer.DisplayName, encodedLink);
release.Link = new Uri(proxyLink);
}

View File

@@ -34,7 +34,7 @@ namespace Jackett.Controllers
}
[Route("get_config_form")]
[HttpGet]
[HttpPost]
public async Task<IHttpActionResult> GetConfigForm()
{
var jsonReply = new JObject();
@@ -99,7 +99,7 @@ namespace Jackett.Controllers
foreach (var indexer in indexerService.GetAllIndexers())
{
var item = new JObject();
item["id"] = indexer.GetType().Name.ToLowerInvariant();
item["id"] = indexer.GetType().Name;
item["name"] = indexer.DisplayName;
item["description"] = indexer.DisplayDescription;
item["configured"] = indexer.IsConfigured;
@@ -126,6 +126,7 @@ namespace Jackett.Controllers
var postData = await ReadPostDataJson();
string indexerString = (string)postData["indexer"];
indexerService.TestIndexer(indexerString);
jsonReply["name"] = indexerService.GetIndexer(indexerString).DisplayName;
jsonReply["result"] = "success";
}
catch (Exception ex)

View File

@@ -12,57 +12,36 @@ using System.Net.Http.Headers;
using Jackett.Models;
using Jackett.Utils;
using NLog;
using Jackett.Services;
namespace Jackett.Indexers
{
public class AlphaRatio : IIndexer
public class AlphaRatio : BaseIndexer,IIndexer
{
public string DisplayName
{
get { return "AlphaRatio"; }
}
public string DisplayDescription
{
get { return "Legendary"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, 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=";
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
private readonly string GuidUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
string cookieHeader;
private Logger logger;
public AlphaRatio(Logger l)
public AlphaRatio(IIndexerManagerService i, Logger l):
base(name: "AlphaRatio",
description: "Legendary",
link: new Uri("https://alpharatio.cc"),
rageid: true,
manager:i,
logger:l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login.php";
SearchUrl = SiteLink + "/ajax.php?action=browse&searchstr=";
DownloadUrl = SiteLink + "/torrents.php?action=download&id=";
GuidUrl = SiteLink + "/torrents.php?torrentid=";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -83,8 +62,7 @@ namespace Jackett.Indexers
public async Task ApplyConfiguration(JToken configJson)
{
var configSaveData = new JObject();
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
var config = new ConfigurationDataBasicLogin();
config.LoadValuesFromJson(configJson);
@@ -131,9 +109,7 @@ namespace Jackett.Indexers
}
else
{
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
@@ -143,7 +119,7 @@ namespace Jackett.Indexers
var message = new HttpRequestMessage();
message.Method = HttpMethod.Post;
message.RequestUri = uri;
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
@@ -223,8 +199,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -18,7 +19,7 @@ using System.Web;
namespace Jackett.Indexers
{
public class AnimeBytes : IIndexer
public class AnimeBytes : BaseIndexer, IIndexer
{
class ConfigurationDataBasicLoginAnimeBytes : ConfigurationDataBasicLogin
{
@@ -38,48 +39,27 @@ namespace Jackett.Indexers
}
}
private static List<CachedResult> cache = new List<CachedResult>();
private static readonly TimeSpan cacheTime = new TimeSpan(0, 9, 0);
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
public event Action<IIndexer, string, Exception> OnResultParsingError;
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
public string DisplayName
{
get { return "AnimeBytes"; }
}
public string DisplayDescription
{
get { return "The web's best Chinese cartoons"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string BaseUrl = "https://animebytes.tv";
const string LoginUrl = BaseUrl + "/user/login";
const string SearchUrl = BaseUrl + "/torrents.php?filter_cat[1]=1";
public bool IsConfigured { get; private set; }
public bool AllowRaws { get; private set; }
CookieContainer cookieContainer;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public AnimeBytes(Logger l)
public AnimeBytes(IIndexerManagerService i, Logger l) :
base(name: "AnimeBytes",
description: "The web's best Chinese cartoons",
link: new Uri("https://animebytes.tv"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/user/login";
SearchUrl = SiteLink + "/torrents.php?filter_cat[1]=1";
cookieContainer = new CookieContainer();
handler = new HttpClientHandler
{
@@ -88,7 +68,7 @@ namespace Jackett.Indexers
UseCookies = true,
};
client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("User-Agent", chromeUserAgent);
client.DefaultRequestHeaders.Add("User-Agent", BrowserUtil.ChromeUserAgent);
}
public Task<ConfigurationData> GetConfigurationForSetup()
@@ -132,11 +112,11 @@ namespace Jackett.Indexers
{
foreach (var c in cookies)
{
cookieContainer.SetCookies(new Uri(BaseUrl), c.Substring(0, c.LastIndexOf(';')));
cookieContainer.SetCookies(SiteLink, c.Substring(0, c.LastIndexOf(';')));
}
}
foreach (Cookie cookie in cookieContainer.GetCookies(new Uri(BaseUrl)))
foreach (Cookie cookie in cookieContainer.GetCookies(SiteLink))
{
if (cookie.Name == "session")
{
@@ -146,7 +126,7 @@ namespace Jackett.Indexers
}
// Get the home page now we are logged in as AllowAutoRedirect is false as we needed to get the cookie manually.
response = await client.GetAsync(BaseUrl);
response = await client.GetAsync(SiteLink);
responseContent = await response.Content.ReadAsStringAsync();
if (!responseContent.Contains("/user/logout"))
@@ -160,16 +140,14 @@ namespace Jackett.Indexers
cookieContainer.DumpToJson(SiteLink, configSaveData);
configSaveData["raws"] = AllowRaws;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookieContainer.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookieContainer.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
AllowRaws = jsonConfig["raws"].Value<bool>();
}
@@ -191,13 +169,7 @@ namespace Jackett.Indexers
return sb.ToString();
}
private void CleanCache()
{
foreach (var expired in cache.Where(i => i.Created - DateTime.Now > cacheTime).ToList())
{
cache.Remove(expired);
}
}
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
@@ -344,9 +316,9 @@ namespace Jackett.Indexers
release.PublishDate = release.PublishDate.AddDays(Math.Min(DateTime.Now.DayOfYear, 365) - 1);
var infoLink = links.Get(1);
release.Comments = new Uri(BaseUrl + "/" + infoLink.Attributes.GetAttribute("href"));
release.Guid = new Uri(BaseUrl + "/" + infoLink.Attributes.GetAttribute("href") + "&nh=" + Hash(title)); // Sonarr should dedupe on this url - allow a url per name.
release.Link = new Uri(BaseUrl + "/" + downloadLink.Attributes.GetAttribute("href"));
release.Comments = new Uri(SiteLink + "/" + infoLink.Attributes.GetAttribute("href"));
release.Guid = new Uri(SiteLink + "/" + infoLink.Attributes.GetAttribute("href") + "&nh=" + Hash(title)); // Sonarr should dedupe on this url - allow a url per name.
release.Link = new Uri(SiteLink + "/" + downloadLink.Attributes.GetAttribute("href"));
// We dont actually have a release name >.> so try to create one
var releaseTags = infoLink.InnerText.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
@@ -406,8 +378,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, responseContent, ex);
throw ex;
OnParseError(responseContent, ex);
}
// Add to the cache

View File

@@ -6,10 +6,11 @@ using System.Threading.Tasks;
using Jackett.Models;
using Newtonsoft.Json.Linq;
using NLog;
using Jackett.Services;
namespace Jackett.Indexers
{
public abstract class BaseIndexer: IIndexer
public abstract class BaseIndexer
{
public string DisplayDescription { get; private set; }
public string DisplayName { get; private set; }
@@ -17,28 +18,43 @@ namespace Jackett.Indexers
public Uri SiteLink { get; private set; }
public bool RequiresRageIDLookupDisabled { get; private set; }
public abstract Task ApplyConfiguration(JToken configJson);
public abstract Task<byte[]> Download(Uri link);
public abstract Task<ConfigurationData> GetConfigurationForSetup();
public abstract void LoadFromSavedConfiguration(JToken jsonConfig);
public abstract Task<ReleaseInfo[]> PerformQuery(TorznabQuery query);
protected Logger logger;
protected IIndexerManagerService indexerService;
private Logger logger;
protected static List<CachedResult> cache = new List<CachedResult>();
protected static readonly TimeSpan cacheTime = new TimeSpan(0, 9, 0);
public BaseIndexer(string name, string description, Uri link, Logger logger)
public BaseIndexer(string name, string description, bool rageid, Uri link, IIndexerManagerService manager, Logger logger)
{
DisplayName = name;
DisplayDescription = description;
SiteLink = link;
this.logger = logger;
indexerService = manager;
RequiresRageIDLookupDisabled = rageid;
}
protected void LogParseError(string results, Exception ex)
protected void SaveConfig(JToken config)
{
indexerService.SaveConfig(this as IIndexer, config);
}
protected void OnParseError(string results, Exception ex)
{
var fileName = string.Format("Error on {0} for {1}.txt", DateTime.Now.ToString("yyyyMMddHHmmss"), DisplayName);
var spacing = string.Join("", Enumerable.Repeat(Environment.NewLine, 5));
var fileContents = string.Format("{0}{1}{2}", ex, spacing, results);
logger.Error(fileName + fileContents);
throw ex;
}
protected void CleanCache()
{
foreach (var expired in cache.Where(i => i.Created - DateTime.Now > cacheTime).ToList())
{
cache.Remove(expired);
}
}
}
}

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -14,44 +15,26 @@ using System.Web;
namespace Jackett.Indexers
{
public class BeyondHD : IIndexer
public class BeyondHD : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "BeyondHD"; }
}
public string DisplayDescription
{
get { return "Without BeyondHD, your HDTV is just a TV"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string BaseUrl = "https://beyondhd.me";
const string SearchUrl = BaseUrl + "/browse.php?c40=1&c44=1&c48=1&c89=1&c46=1&c45=1&searchin=title&incldead=0&search={0}";
const string DownloadUrl = BaseUrl + "/download.php?torrent={0}";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public BeyondHD(Logger l)
public BeyondHD(IIndexerManagerService i, Logger l) :
base(name: "BeyondHD",
description: "Without BeyondHD, your HDTV is just a TV",
link: new Uri("https://beyondhd.me"),
rageid: true,
manager:i,
logger:l)
{
logger = l;
IsConfigured = false;
SearchUrl = SiteLink + "/browse.php?c40=1&c44=1&c48=1&c89=1&c46=1&c45=1&searchin=title&incldead=0&search={0}";
DownloadUrl = SiteLink + "/download.php?torrent={0}";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -75,9 +58,9 @@ namespace Jackett.Indexers
var jsonCookie = new JObject();
jsonCookie["cookie_header"] = config.CookieHeader;
cookies.FillFromJson(new Uri(BaseUrl), jsonCookie, logger);
cookies.FillFromJson(SiteLink, jsonCookie, logger);
var responseContent = await client.GetStringAsync(BaseUrl);
var responseContent = await client.GetStringAsync(SiteLink);
if (!responseContent.Contains("logout.php"))
{
@@ -88,18 +71,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -124,14 +103,14 @@ namespace Jackett.Indexers
var qRow = row.Cq();
var qLink = row.ChildElements.ElementAt(2).FirstChild.Cq();
release.Link = new Uri(BaseUrl + "/" + qLink.Attr("href"));
release.Link = new Uri(SiteLink + "/" + qLink.Attr("href"));
var torrentID = qLink.Attr("href").Split('=').Last();
var descCol = row.ChildElements.ElementAt(3);
var qCommentLink = descCol.FirstChild.Cq();
release.Title = qCommentLink.Text();
release.Description = release.Title;
release.Comments = new Uri(BaseUrl + "/" + qCommentLink.Attr("href"));
release.Comments = new Uri(SiteLink + "/" + qCommentLink.Attr("href"));
release.Guid = release.Comments;
var dateStr = descCol.ChildElements.Last().Cq().Text().Split('|').Last().ToLowerInvariant().Replace("ago.", "").Trim();
@@ -167,11 +146,9 @@ namespace Jackett.Indexers
}
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,41 +16,28 @@ using System.Web;
namespace Jackett.Indexers
{
public class BitHdtv : IIndexer
public class BitHdtv : BaseIndexer, IIndexer
{
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "BIT-HDTV"; }
}
public string DisplayDescription
{
get { return "Home of high definition invites"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
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";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger loggger;
public BitHdtv(Logger l)
public BitHdtv(IIndexerManagerService i, Logger l) :
base(name: "BIT-HDTV",
description: "Home of high definition invites",
link: new Uri("https://www.bit-hdtv.com"),
rageid: true,
manager: i,
logger: l)
{
loggger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/takelogin.php";
SearchUrl = SiteLink + "/torrents.php?cat=0&search=";
DownloadUrl = SiteLink + "/download.php?/{0}/dl.torrent";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -94,21 +82,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public bool IsConfigured { get; private set; }
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, loggger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -136,7 +117,7 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 172800;
release.Title = qLink.Attr("title");
release.Description = release.Title;
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
release.Guid = new Uri(SiteLink + qLink.Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(string.Format(DownloadUrl, qLink.Attr("href").Split('=')[1]));
@@ -157,8 +138,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
@@ -168,7 +148,5 @@ namespace Jackett.Indexers
{
return client.GetByteArrayAsync(link);
}
}
}

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -16,7 +17,7 @@ using System.Web;
namespace Jackett.Indexers
{
public class BitMeTV : IIndexer
public class BitMeTV : BaseIndexer, IIndexer
{
class BmtvConfig : ConfigurationData
{
@@ -42,24 +43,28 @@ namespace Jackett.Indexers
}
}
static string BaseUrl = "http://www.bitmetv.org";
static string LoginUrl = BaseUrl + "/login.php";
static string LoginPost = BaseUrl + "/takelogin.php";
static string CaptchaUrl = BaseUrl + "/visual.php";
static string SearchUrl = BaseUrl + "/browse.php";
private readonly string LoginUrl = "";
private readonly string LoginPost = "";
private readonly string CaptchaUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public BitMeTV(Logger l)
public BitMeTV(IIndexerManagerService i, Logger l) :
base(name: "BitMeTV",
description: "TV Episode specialty tracker",
link: new Uri("http://www.bitmetv.org"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login.php";
LoginPost = SiteLink + "/takelogin.php";
CaptchaUrl = SiteLink + "/visual.php";
SearchUrl = SiteLink + "/browse.php";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -70,16 +75,6 @@ namespace Jackett.Indexers
client = new HttpClient(handler);
}
public string DisplayName { get { return "BitMeTV"; } }
public string DisplayDescription { get { return "TV Episode specialty tracker"; } }
public Uri SiteLink { get { return new Uri(BaseUrl); } }
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
public async Task<ConfigurationData> GetConfigurationForSetup()
{
await client.GetAsync(LoginUrl);
@@ -119,17 +114,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -155,7 +147,7 @@ namespace Jackett.Indexers
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.Comments = new Uri(BaseUrl + "/" + qLink.Attr("href"));
release.Comments = new Uri(SiteLink + "/" + qLink.Attr("href"));
release.Guid = release.Comments;
release.Title = qLink.Attr("title");
release.Description = release.Title;
@@ -169,7 +161,7 @@ namespace Jackett.Indexers
var date = DateTime.ParseExact(formattedTimeString, "dddd MMMM d yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
release.PublishDate = DateTime.SpecifyKind(date, DateTimeKind.Utc).ToLocalTime();
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
release.Link = new Uri(SiteLink + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));
var sizeCol = row.ChildElements.ElementAt(6);
var sizeVal = ParseUtil.CoerceFloat(sizeCol.ChildNodes[0].NodeValue);
@@ -187,8 +179,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,7 +1,9 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -12,7 +14,7 @@ using System.Web;
namespace Jackett.Indexers
{
class FrenchTorrentDb : IIndexer
class FrenchTorrentDb : BaseIndexer, IIndexer
{
public event Action<IIndexer, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
@@ -33,28 +35,9 @@ namespace Jackett.Indexers
}
}
public string DisplayName
{
get { return "FrenchTorrentDb"; }
}
public string DisplayDescription
{
get { return "One the biggest French Torrent Tracker"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string BaseUrl = "http://www.frenchtorrentdb.com/";
const string MainUrl = BaseUrl + "?section=INDEX";
const string SearchUrl = BaseUrl + "?section=TORRENTS&exact=1&name={0}&submit=GO";
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private readonly string MainUrl = "";
private readonly string SearchUrl = "";
string cookie = string.Empty;
@@ -62,9 +45,17 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public FrenchTorrentDb()
public FrenchTorrentDb(IIndexerManagerService i, Logger l) :
base(name: "FrenchTorrentDb",
description: "One the biggest French Torrent Tracker",
link: new Uri("http://www.frenchtorrentdb.com/"),
rageid: true,
manager: i,
logger: l)
{
IsConfigured = false;
MainUrl = SiteLink + "?section=INDEX";
SearchUrl = SiteLink + "?section=TORRENTS&exact=1&name={0}&submit=GO";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -73,12 +64,12 @@ namespace Jackett.Indexers
UseCookies = true,
};
client = new HttpClient(handler);
client.DefaultRequestHeaders.UserAgent.ParseAdd(chromeUserAgent);
client.DefaultRequestHeaders.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataUrl(BaseUrl);
var config = new ConfigurationDataUrl(SiteLink);
return Task.FromResult<ConfigurationData>(config);
}
@@ -86,7 +77,7 @@ namespace Jackett.Indexers
{
var config = new ConfigurationDataBasicLoginFrenchTorrentDb();
config.LoadValuesFromJson(configJson);
cookies.SetCookies(new Uri(BaseUrl), "WebsiteID=" + config.Cookie.Value);
cookies.SetCookies(SiteLink, "WebsiteID=" + config.Cookie.Value);
var mainPage = await client.GetAsync(MainUrl);
string responseContent = await mainPage.Content.ReadAsStringAsync();
@@ -109,7 +100,7 @@ namespace Jackett.Indexers
public void LoadFromSavedConfiguration(Newtonsoft.Json.Linq.JToken jsonConfig)
{
cookie = (string)jsonConfig["cookie"];
cookies.SetCookies(new Uri(BaseUrl), "WebsiteID=" + cookie);
cookies.SetCookies(SiteLink, "WebsiteID=" + cookie);
IsConfigured = true;
}
@@ -142,9 +133,9 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 172800;
release.Title = qLink.Text().Trim();
release.Description = release.Title;
release.Comments = new Uri(BaseUrl + "/" + qLink.Attr("href").TrimStart('/'));
release.Comments = new Uri(SiteLink + "/" + qLink.Attr("href").TrimStart('/'));
release.Guid = release.Comments;
release.Link = new Uri(BaseUrl + "/" + qDlLink.Attr("href").TrimStart('/'));
release.Link = new Uri(SiteLink + "/" + qDlLink.Attr("href").TrimStart('/'));
release.PublishDate = DateTime.Now;
release.Seeders = ParseUtil.CoerceInt(qRow.Find("li.torrents_seeders").Text());
release.Peers = ParseUtil.CoerceInt(qRow.Find("li.torrents_leechers").Text()) + release.Seeders;

View File

@@ -1,6 +1,7 @@
using CsQuery;
using Jackett.Indexers;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -18,38 +19,29 @@ using System.Web.UI.WebControls;
namespace Jackett
{
public class Freshon : IIndexer
public class Freshon : BaseIndexer, IIndexer
{
public event Action<IIndexer, 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 chromeUserAgent = BrowserUtil.ChromeUserAgent;
private readonly string LoginUrl = "";
private readonly string LoginPostUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public bool IsConfigured { get; private set; }
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 Uri SiteLink { get { return new Uri(BaseUrl); } }
public bool RequiresRageIDLookupDisabled { get { return true; } }
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
private Logger logger;
public Freshon(Logger l)
public Freshon(IIndexerManagerService i, Logger l) :
base(name: "FreshOnTV",
description: "Our goal is to provide the latest stuff in the TV show domain",
link: new Uri("https://www.bit-hdtv.com"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login.php";
LoginPostUrl = SiteLink + "/login.php?action=makelogin";
SearchUrl = SiteLink + "/browse.php";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -99,17 +91,14 @@ namespace Jackett
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
// if (OnSaveConfigurationRequested != null)
// OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -118,7 +107,7 @@ namespace Jackett
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = uri;
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
@@ -156,9 +145,9 @@ namespace Jackett
release.MinimumSeedTime = 172800;
release.Title = qLink.Attr("title");
release.Description = release.Title;
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
release.Guid = new Uri(SiteLink + qLink.Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(BaseUrl + qRow.Find("td.table_links > a").First().Attr("href"));
release.Link = new Uri(SiteLink + qRow.Find("td.table_links > a").First().Attr("href"));
DateTime pubDate;
var dateString = qRow.Find("td.table_added").Text().Trim();
@@ -183,8 +172,7 @@ namespace Jackett
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,28 +16,27 @@ using System.Web;
namespace Jackett.Indexers
{
public class HDTorrents : IIndexer
public class HDTorrents : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
const string DefaultUrl = "http://hdts.ru"; // Of the accessible domains the .ru seems the most reliable. https://hdts.ru | https://hd-torrents.org | https://hd-torrents.net | https://hd-torrents.me
string BaseUrl = DefaultUrl;
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private string SearchUrl = DefaultUrl + "/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={1}";
private static string LoginUrl = DefaultUrl + "/login.php";
private readonly string SearchUrl = "";
private static string LoginUrl = "";
private const int MAXPAGES = 3;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public HDTorrents(Logger l)
public HDTorrents(IIndexerManagerService i, Logger l) :
base(name: "HD-Torrents",
description: "HD-Torrents is a private torrent website with HD torrents and strict rules on their content.",
link: new Uri("http://hdts.ru"),// Of the accessible domains the .ru seems the most reliable. https://hdts.ru | https://hd-torrents.org | https://hd-torrents.net | https://hd-torrents.me
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
SearchUrl = SiteLink + "/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={1}";
LoginUrl = SiteLink + "/login.php";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -47,29 +47,6 @@ namespace Jackett.Indexers
client = new HttpClient(handler);
}
public string DisplayName
{
get { return "HD-Torrents"; }
}
public string DisplayDescription
{
get { return "HD-Torrents is a private torrent website with HD torrents and strict rules on their content."; }
}
public Uri SiteLink
{
get { return new Uri(DefaultUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured
{
get;
private set;
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataBasicLogin();
@@ -81,7 +58,7 @@ namespace Jackett.Indexers
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = new Uri(url);
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
@@ -118,10 +95,7 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
@@ -132,7 +106,7 @@ namespace Jackett.Indexers
IsConfigured = true;
}
async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query, string baseUrl)
async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query, Uri baseUrl)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
List<string> searchurls = new List<string>();
@@ -212,9 +186,9 @@ namespace Jackett.Indexers
}
release.Size = size;
release.Guid = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent b a").Attr("href"));
release.Link = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent").Get(3).FirstChild.GetAttribute("href"));
release.Comments = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent b a").Attr("href") + "#comments");
release.Guid = new Uri(SiteLink + "/" + qRow.Find("td.mainblockcontent b a").Attr("href"));
release.Link = new Uri(SiteLink + "/" + qRow.Find("td.mainblockcontent").Get(3).FirstChild.GetAttribute("href"));
release.Comments = new Uri(SiteLink + "/" + qRow.Find("td.mainblockcontent b a").Attr("href") + "#comments");
string[] dateSplit = qRow.Find("td.mainblockcontent").Get(5).InnerHTML.Split(',');
string dateString = dateSplit[1].Substring(0, dateSplit[1].IndexOf('>'));
@@ -225,8 +199,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError( results, ex);
}
}
@@ -236,7 +209,7 @@ namespace Jackett.Indexers
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
{
return await PerformQuery(query, BaseUrl);
return await PerformQuery(query, SiteLink);
}
public Task<byte[]> Download(Uri link)

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,38 +16,22 @@ using System.Web;
namespace Jackett.Indexers
{
public class IPTorrents : IIndexer
public class IPTorrents : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName { get { return "IPTorrents"; } }
public string DisplayDescription { get { return "Always a step ahead"; } }
public Uri SiteLink { get { return new Uri(BaseUrl); } }
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
static string BaseUrl = "https://iptorrents.com";
string SearchUrl = BaseUrl + "/t?q=";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public IPTorrents(Logger l)
public IPTorrents(IIndexerManagerService i, Logger l) :
base(name: "IPTorrents",
description: "Always a step ahead.",
link: new Uri("https://iptorrents.com"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
SearchUrl = SiteLink + "t?q=";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -59,7 +44,7 @@ namespace Jackett.Indexers
public async Task<ConfigurationData> GetConfigurationForSetup()
{
await client.GetAsync(new Uri(BaseUrl));
await client.GetAsync(SiteLink);
var config = new ConfigurationDataBasicLogin();
return (ConfigurationData)config;
}
@@ -79,9 +64,9 @@ namespace Jackett.Indexers
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);
message.RequestUri = SiteLink;
message.Headers.Referrer = SiteLink;
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
var response = await client.SendAsync(message);
var responseContent = await response.Content.ReadAsStringAsync();
@@ -97,13 +82,9 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
HttpRequestMessage CreateHttpRequest(Uri uri)
@@ -111,22 +92,19 @@ namespace Jackett.Indexers
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = uri;
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
public void LoadFromSavedConfiguration(Newtonsoft.Json.Linq.JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
var releases = new List<ReleaseInfo>();
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
@@ -148,7 +126,7 @@ namespace Jackett.Indexers
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.Guid = new Uri(SiteLink + qTitleLink.Attr("href"));
release.Comments = release.Guid;
DateTime pubDate;
@@ -174,7 +152,7 @@ namespace Jackett.Indexers
release.PublishDate = pubDate;
var qLink = row.ChildElements.ElementAt(3).Cq().Children("a");
release.Link = new Uri(BaseUrl + qLink.Attr("href"));
release.Link = new Uri(SiteLink + qLink.Attr("href"));
var sizeStr = row.ChildElements.ElementAt(5).Cq().Text().Trim();
var sizeVal = ParseUtil.CoerceFloat(sizeStr.Split(' ')[0]);
@@ -189,12 +167,10 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}
public async Task<byte[]> Download(Uri link)
@@ -204,8 +180,5 @@ namespace Jackett.Indexers
var bytes = await response.Content.ReadAsByteArrayAsync();
return bytes;
}
}
}

View File

@@ -1,16 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Indexers
{
class Master
{
}
}

View File

@@ -1,5 +1,7 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
@@ -14,52 +16,33 @@ using System.Web;
namespace Jackett.Indexers
{
public class MoreThanTV : IIndexer
public class MoreThanTV : BaseIndexer, IIndexer
{
public string DisplayName
{
get { return "MoreThanTV"; }
}
public string DisplayDescription
{
get { return "ROMANIAN Private Torrent Tracker for TV / MOVIES, and the internal tracker for the release group DRACULA"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public bool IsConfigured { get; private set; }
static string BaseUrl = "https://www.morethan.tv";
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=";
private readonly string LoginUrl ="";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
private readonly string GuidUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
private Logger logger;
string cookieHeader;
int retries = 3;
public MoreThanTV(Logger l)
public MoreThanTV(IIndexerManagerService i, Logger l) :
base(name: "MoreThanTV",
description: "ROMANIAN Private Torrent Tracker for TV / MOVIES, and the internal tracker for the release group DRACULA.",
link: new Uri("https://www.morethan.tv"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login.php";
SearchUrl = SiteLink + "/ajax.php?action=browse&searchstr=";
DownloadUrl = SiteLink + "/torrents.php?action=download&id=";
GuidUrl = SiteLink + "/torrents.php?torrentid=";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -121,9 +104,7 @@ namespace Jackett.Indexers
}
else
{
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
@@ -135,7 +116,7 @@ namespace Jackett.Indexers
IsConfigured = true;
}
static void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
private void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
{
var id = r["torrentId"];
release.Size = (long)r["size"];
@@ -173,7 +154,7 @@ namespace Jackett.Indexers
double dateNum;
if (double.TryParse((string)r["groupTime"], out dateNum))
{
pubDate = UnixTimestampToDateTime(dateNum);
pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum);
pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime();
}
@@ -205,20 +186,12 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, 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 (Engine.IsWindows)
@@ -230,7 +203,6 @@ namespace Jackett.Indexers
var response = await CurlHelper.GetAsync(link.ToString(), cookieHeader);
return response.Content;
}
}
}
}

View File

@@ -1,7 +1,9 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,48 +14,27 @@ using System.Threading.Tasks;
namespace Jackett.Indexers
{
public class Rarbg : IIndexer
public class Rarbg : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, 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 RequiresRageIDLookupDisabled { get { return false; } }
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 = BrowserUtil.ChromeUserAgent;
string BaseUrl;
private string BaseUrl;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public Rarbg()
public Rarbg(IIndexerManagerService i, Logger l) :
base(name: "RARBG",
description: "RARBG",
link: new Uri("https://rarbg.com"),
rageid: true,
manager: i,
logger: l)
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -85,10 +66,7 @@ namespace Jackett.Indexers
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
@@ -103,7 +81,7 @@ namespace Jackett.Indexers
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = new Uri(uri);
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
@@ -156,10 +134,9 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
OnParseError(results, ex);
}
return releases.ToArray();
}
public Task<byte[]> Download(Uri link)

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -13,50 +14,27 @@ using System.Threading.Tasks;
namespace Jackett.Indexers
{
class SceneAccess : IIndexer
class SceneAccess : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "SceneAccess"; }
}
public string DisplayDescription
{
get { return "Your gateway to the scene"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string BaseUrl = "https://sceneaccess.eu";
const string LoginUrl = BaseUrl + "/login";
const string SearchUrl = BaseUrl + "/{0}?method=1&c{1}=1&search={2}";
public bool IsConfigured
{
get;
private set;
}
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
string cookieHeader;
private Logger logger;
public SceneAccess(Logger l)
public SceneAccess(IIndexerManagerService i, Logger l) :
base(name: "SceneAccess",
description: "Your gateway to the scene",
link: new Uri("https://sceneaccess.eu"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login";
SearchUrl = SiteLink + "/{0}?method=1&c{1}=1&search={2}";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -114,16 +92,14 @@ namespace Jackett.Indexers
}
else
{
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
cookieHeader = cookies.GetCookieHeader(SiteLink);
IsConfigured = true;
}
@@ -162,9 +138,9 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 129600;
release.Title = qRow.Find(".ttr_name > a").Text();
release.Description = release.Title;
release.Guid = new Uri(BaseUrl + "/" + qRow.Find(".ttr_name > a").Attr("href"));
release.Guid = new Uri(SiteLink + "/" + qRow.Find(".ttr_name > a").Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(BaseUrl + "/" + qRow.Find(".td_dl > a").Attr("href"));
release.Link = new Uri(SiteLink + "/" + qRow.Find(".td_dl > a").Attr("href"));
var sizeStr = qRow.Find(".ttr_size").Contents()[0].NodeValue;
var sizeParts = sizeStr.Split(' ');
@@ -185,8 +161,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,46 +16,28 @@ using System.Web;
namespace Jackett.Indexers
{
public class SceneTime : IIndexer
public class SceneTime : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "SceneTime"; }
}
public string DisplayDescription
{
get { return "Always on time"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string BaseUrl = "https://www.scenetime.com";
const string LoginUrl = BaseUrl + "/takelogin.php";
const string SearchUrl = BaseUrl + "/browse_API.php";
const string DownloadUrl = BaseUrl + "/download.php/{0}/download.torrent";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public SceneTime(Logger l)
public SceneTime(IIndexerManagerService i, Logger l) :
base(name: "SceneTime",
description: "Always on time",
link: new Uri("https://www.scenetime.com"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/takelogin.php";
SearchUrl = SiteLink + "/browse_API.php";
DownloadUrl = SiteLink + "/download.php/{0}/download.torrent";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -96,17 +79,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -146,7 +126,7 @@ namespace Jackett.Indexers
var qLink = qDescCol.Find("a");
release.Title = qLink.Text();
release.Description = release.Title;
release.Comments = new Uri(BaseUrl + "/" + qLink.Attr("href"));
release.Comments = new Uri(SiteLink + "/" + qLink.Attr("href"));
release.Guid = release.Comments;
var torrentId = qLink.Attr("href").Split('=')[1];
release.Link = new Uri(string.Format(DownloadUrl, torrentId));
@@ -169,8 +149,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}

View File

@@ -1,6 +1,8 @@
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -14,47 +16,25 @@ using System.Xml;
namespace Jackett.Indexers
{
public class ShowRSS : IIndexer
public class ShowRSS : BaseIndexer, IIndexer
{
public event Action<IIndexer, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "ShowRSS"; }
}
public string DisplayDescription
{
get { return "showRSS is a service that allows you to keep track of your favorite TV shows"; }
}
public Uri SiteLink
{
get { return new Uri(DefaultUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string DefaultUrl = "http://showrss.info";
const string searchAllUrl = DefaultUrl + "/feeds/all.rss";
private readonly string searchAllUrl = "";
string BaseUrl;
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public bool IsConfigured
public ShowRSS(IIndexerManagerService i, Logger l) :
base(name: "ShowRSS",
description: "showRSS is a service that allows you to keep track of your favorite TV shows",
link: new Uri("http://showrss.info"),
rageid: true,
manager: i,
logger: l)
{
get;
private set;
}
searchAllUrl = SiteLink + "/feeds/all.rss";
public ShowRSS()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -67,13 +47,13 @@ namespace Jackett.Indexers
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
config.LoadValuesFromJson(configJson);
var formattedUrl = config.GetFormattedHostUrl();
@@ -85,10 +65,7 @@ namespace Jackett.Indexers
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
@@ -112,7 +89,7 @@ namespace Jackett.Indexers
{
WebClient wc = new WebClient();
WebHeaderCollection headers = new WebHeaderCollection();
headers.Add("User-Agent", chromeUserAgent);
headers.Add("User-Agent", BrowserUtil.ChromeUserAgent);
wc.Headers = headers;
return wc;
}
@@ -166,8 +143,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, xml, ex);
throw ex;
OnParseError(xml, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,9 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -13,36 +17,31 @@ using System.Web;
namespace Jackett.Indexers
{
public class SpeedCD : IndexerInterface
public class SpeedCD : BaseIndexer, IIndexer
{
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
public string DisplayName { get { return "Speed.cd"; } }
public string DisplayDescription { get { return "Your home now!"; } }
public Uri SiteLink { get { return new Uri(BaseUrl); } }
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string BaseUrl = "http://speed.cd";
const string LoginUrl = BaseUrl + "/take_login.php";
const string SearchUrl = BaseUrl + "/V3/API/API.php";
const string SearchFormData = "c53=1&c49=1&c2=1&c52=1&c41=1&c50=1&c30=1&jxt=4&jxw=b";
const string CommentsUrl = BaseUrl + "/t/{0}";
const string DownloadUrl = BaseUrl + "/download.php?torrent={0}";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
private readonly string SearchFormData = "c53=1&c49=1&c2=1&c52=1&c41=1&c50=1&c30=1&jxt=4&jxw=b";
private readonly string CommentsUrl ="";
private readonly string DownloadUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public bool IsConfigured { get; private set; }
public SpeedCD()
public SpeedCD(IIndexerManagerService i, Logger l) :
base(name: "Speed.cd",
description: "Your home now!",
link: new Uri("http://speed.cd"),
rageid: true,
manager: i,
logger: l)
{
IsConfigured = false;
LoginUrl = SiteLink + "/take_login.php";
SearchUrl = SiteLink + "/V3/API/API.php";
CommentsUrl = SiteLink + "/t/{0}";
DownloadUrl = SiteLink + "/download.php?torrent={0}";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -84,17 +83,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -142,7 +138,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
// OnResultParsingError(this, results, ex);
throw ex;
}
return releases.ToArray();

View File

@@ -1,5 +1,7 @@
using Jackett.Models;
using Jackett.Services;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -12,47 +14,24 @@ using System.Web;
namespace Jackett.Indexers
{
public class Strike : IIndexer
public class Strike : BaseIndexer, IIndexer
{
private readonly string DownloadUrl = "/torrents/api/download/{0}.torrent";
private readonly string SearchUrl = "/api/v2/torrents/search/?category=TV&phrase={0}";
private string BaseUrl;
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
private CookieContainer cookies;
private HttpClientHandler handler;
private HttpClient client;
public string DisplayName
public Strike(IIndexerManagerService i, Logger l) :
base(name: "Strike",
description: "Torrent search engine",
link: new Uri("https://getstrike.net"),
rageid: true,
manager: i,
logger: l)
{
get { return "Strike"; }
}
public string DisplayDescription
{
get { return "Torrent search engine"; }
}
public Uri SiteLink
{
get { return new Uri(DefaultUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string DefaultUrl = "https://getstrike.net";
//const string DownloadUrl = "/api/v2/torrents/download/?hash={0}";
const string DownloadUrl = "/torrents/api/download/{0}.torrent";
const string SearchUrl = "/api/v2/torrents/search/?category=TV&phrase={0}";
string BaseUrl;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public Strike()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -65,13 +44,13 @@ namespace Jackett.Indexers
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(JToken configJson)
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
config.LoadValuesFromJson(configJson);
var formattedUrl = config.GetFormattedHostUrl();
@@ -83,12 +62,8 @@ namespace Jackett.Indexers
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
@@ -138,11 +113,9 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}

View File

@@ -1,6 +1,8 @@
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -14,35 +16,9 @@ using System.Web;
namespace Jackett.Indexers
{
public class T411 : IIndexer
public class T411 : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "T411"; }
}
public string DisplayDescription
{
get { return "French Torrent Tracker"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string BaseUrl = "http://www.t411.io";
const string CommentsUrl = BaseUrl + "/torrents/{0}";
private readonly string CommentsUrl = "";
const string ApiUrl = "http://api.t411.io";
const string AuthUrl = ApiUrl + "/auth";
const string SearchUrl = ApiUrl + "/torrents/search/{0}";
@@ -56,8 +32,15 @@ namespace Jackett.Indexers
string token = string.Empty;
DateTime lastTokenFetch = DateTime.MinValue;
public T411()
public T411(IIndexerManagerService i, Logger l) :
base(name: "T411",
description: "French Torrent Tracker",
link: new Uri("http://www.t411.io"),
rageid: true,
manager: i,
logger: l)
{
CommentsUrl = SiteLink + "/torrents/{0}";
IsConfigured = false;
handler = new HttpClientHandler
{
@@ -120,10 +103,7 @@ namespace Jackett.Indexers
configSaveData["password"] = password;
configSaveData["token"] = token;
configSaveData["last_token_fetch"] = lastTokenFetch;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
@@ -182,8 +162,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}

View File

@@ -1,7 +1,9 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -15,35 +17,24 @@ using System.Web;
namespace Jackett.Indexers
{
public class ThePirateBay : IIndexer
public class ThePirateBay : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName { get { return "The Pirate Bay"; } }
public string DisplayDescription { get { return "The worlds largest bittorrent indexer"; } }
public Uri SiteLink { get { return new Uri(DefaultUrl); } }
public bool RequiresRageIDLookupDisabled { get { return true; } }
public bool IsConfigured { get; private set; }
const string DefaultUrl = "https://thepiratebay.mn";
const string SearchUrl = "/search/{0}/0/99/208,205";
string BaseUrl;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public ThePirateBay()
public ThePirateBay(IIndexerManagerService i, Logger l) :
base(name: "The Pirate Bay",
description: "The worlds largest bittorrent indexer",
link: new Uri("https://thepiratebay.mn"),
rageid: true,
manager: i,
logger: l)
{
BaseUrl = DefaultUrl;
BaseUrl = SiteLink.ToString();
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
@@ -63,7 +54,7 @@ namespace Jackett.Indexers
public async Task ApplyConfiguration(JToken configJson)
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
config.LoadValuesFromJson(configJson);
var formattedUrl = config.GetFormattedHostUrl();
@@ -75,10 +66,7 @@ namespace Jackett.Indexers
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,47 +16,28 @@ using System.Web;
namespace Jackett.Indexers
{
public class TorrentDay : IIndexer
public class TorrentDay: BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, 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 RequiresRageIDLookupDisabled { get { return true; } }
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";
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private readonly string StartPageUrl = "";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public TorrentDay(Logger l)
public TorrentDay(IIndexerManagerService i, Logger l) :
base(name: "TorrentDay",
description: "TorrentDay",
link: new Uri("https://torrentday.eu"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
StartPageUrl = SiteLink + "/login.php";
LoginUrl = SiteLink + "/tak3login.php";
SearchUrl = SiteLink + "/browse.php?search={0}&cata=yes&c2=1&c7=1&c14=1&c24=1&c26=1&c31=1&c32=1&c33=1";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -77,7 +59,7 @@ namespace Jackett.Indexers
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = new Uri(uri);
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
message.Headers.UserAgent.ParseAdd(BrowserUtil.ChromeUserAgent);
return message;
}
@@ -115,17 +97,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -149,9 +128,9 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 172800;
release.Title = qRow.Find(".torrentName").Text();
release.Description = release.Title;
release.Guid = new Uri(BaseUrl + "/" + qRow.Find(".torrentName").Attr("href"));
release.Guid = new Uri(SiteLink + "/" + qRow.Find(".torrentName").Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(BaseUrl + "/" + qRow.Find(".dlLinksInfo > a").Attr("href"));
release.Link = new Uri(SiteLink + "/" + qRow.Find(".dlLinksInfo > a").Attr("href"));
var sizeStr = qRow.Find(".sizeInfo").Text().Trim();
var sizeParts = sizeStr.Split(' ');
@@ -185,8 +164,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,45 +16,26 @@ using System.Web;
namespace Jackett.Indexers
{
public class TorrentLeech : IIndexer
public class TorrentLeech : BaseIndexer, IIndexer
{
public event Action<IIndexer, string, Exception> OnResultParsingError;
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public string DisplayName
{
get { return "TorrentLeech"; }
}
public string DisplayDescription
{
get { return "This is what happens when you seed"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string BaseUrl = "http://www.torrentleech.org";
const string LoginUrl = BaseUrl + "/user/account/login/";
const string SearchUrl = BaseUrl + "/torrents/browse/index/query/{0}/categories/2%2C26%2C27%2C32/orderby/added?";
public bool IsConfigured { get; private set; }
private readonly string LoginUrl ="";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public TorrentLeech(Logger l)
public TorrentLeech(IIndexerManagerService i, Logger l) :
base(name: "TorrentLeech",
description: "This is what happens when you seed",
link: new Uri("http://www.torrentleech.org"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/user/account/login/";
SearchUrl = SiteLink + "/torrents/browse/index/query/{0}/categories/2%2C26%2C27%2C32/orderby/added?";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -98,17 +80,14 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -137,12 +116,12 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 172800;
CQ qLink = qRow.Find(".title > a").First();
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
release.Guid = new Uri(SiteLink + qLink.Attr("href"));
release.Comments = release.Guid;
release.Title = qLink.Text();
release.Description = release.Title;
release.Link = new Uri(BaseUrl + qRow.Find(".quickdownload > a").Attr("href"));
release.Link = new Uri(SiteLink + qRow.Find(".quickdownload > a").Attr("href"));
var dateString = qRow.Find(".name").First()[0].ChildNodes[4].NodeValue.Replace(" on", "").Trim();
//"2015-04-25 23:38:12"
@@ -161,8 +140,7 @@ namespace Jackett.Indexers
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();

View File

@@ -1,5 +1,6 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
@@ -15,45 +16,25 @@ using System.Web;
namespace Jackett.Indexers
{
public class TorrentShack : IIndexer
public class TorrentShack : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "TorrentShack"; }
}
public string DisplayDescription
{
get { return DisplayName; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
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";
private readonly string LoginUrl ="";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
Logger logger;
public bool IsConfigured { get; private set; }
public TorrentShack(Logger l)
public TorrentShack(IIndexerManagerService i, Logger l) :
base(name: "TorrentShack",
description: "TorrentShack",
link: new Uri("http://torrentshack.me"),
rageid: true,
manager: i,
logger: l)
{
logger = l;
IsConfigured = false;
LoginUrl = SiteLink + "/login.php";
SearchUrl = SiteLink + "/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";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -99,10 +80,7 @@ namespace Jackett.Indexers
{
var configSaveData = new JObject();
cookies.DumpToJson(SiteLink, configSaveData);
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
@@ -110,7 +88,7 @@ namespace Jackett.Indexers
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), jsonConfig, logger);
cookies.FillFromJson(SiteLink, jsonConfig, logger);
IsConfigured = true;
}
@@ -135,9 +113,9 @@ namespace Jackett.Indexers
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.Guid = new Uri(SiteLink + "/" + 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"));
release.Link = new Uri(SiteLink + "/" + qRow.Find(".torrent_handle_links > a").First().Attr("href"));
var dateStr = qRow.Find(".time").Text().Trim();
if (dateStr.ToLower().Contains("just now"))
@@ -177,8 +155,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, results, ex);
throw ex;
OnParseError(results, ex);
}
return releases.ToArray();
}

View File

@@ -1,6 +1,8 @@
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -13,47 +15,25 @@ using System.Xml;
namespace Jackett.Indexers
{
public class Torrentz : IIndexer
public class Torrentz : BaseIndexer, IIndexer
{
public event Action<IIndexer, JToken> OnSaveConfigurationRequested;
public event Action<IIndexer, string, Exception> OnResultParsingError;
public string DisplayName
{
get { return "Torrentz"; }
}
public string DisplayDescription
{
get { return "Torrentz is a meta-search engine and a Multisearch. This means we just search other search engines."; }
}
public Uri SiteLink
{
get { return new Uri(DefaultUrl); }
}
public bool RequiresRageIDLookupDisabled { get { return true; } }
const string DefaultUrl = "https://torrentz.eu";
const string SearchUrl = DefaultUrl + "/feed_verifiedP?f={0}";
private readonly string SearchUrl = "";
string BaseUrl;
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public bool IsConfigured
public Torrentz(IIndexerManagerService i, Logger l) :
base(name: "Torrentz",
description: "Torrentz is a meta-search engine and a Multisearch. This means we just search other search engines.",
link: new Uri("https://torrentz.eu"),
rageid: true,
manager: i,
logger: l)
{
get;
private set;
}
public Torrentz()
{
IsConfigured = false;
SearchUrl = SiteLink + "/feed_verifiedP?f={0}";
cookies = new CookieContainer();
handler = new HttpClientHandler
{
@@ -64,18 +44,16 @@ namespace Jackett.Indexers
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(JToken configJson)
{
var config = new ConfigurationDataUrl(DefaultUrl);
var config = new ConfigurationDataUrl(SiteLink);
config.LoadValuesFromJson(configJson);
var formattedUrl = config.GetFormattedHostUrl();
@@ -87,10 +65,7 @@ namespace Jackett.Indexers
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
SaveConfig(configSaveData);
IsConfigured = true;
}
@@ -99,7 +74,7 @@ namespace Jackett.Indexers
{
WebClient wc = new WebClient();
WebHeaderCollection headers = new WebHeaderCollection();
headers.Add("User-Agent", chromeUserAgent);
headers.Add("User-Agent", BrowserUtil.ChromeUserAgent);
wc.Headers = headers;
return wc;
}
@@ -119,7 +94,7 @@ namespace Jackett.Indexers
{
using (wc)
{
xml = wc.DownloadString(episodeSearchUrl);
xml = await wc.DownloadStringTaskAsync(new Uri(episodeSearchUrl));
xmlDoc.LoadXml(xml);
}
@@ -153,8 +128,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnResultParsingError(this, xml, ex);
throw ex;
OnParseError(xml, ex);
}
return releases.ToArray();
@@ -176,7 +150,6 @@ namespace Jackett.Indexers
{
throw new NotImplementedException();
}
}
public class TorrentzHelper

View File

@@ -139,6 +139,7 @@
<Compile Include="Controllers\DownloadController.cs" />
<Compile Include="Engine.cs" />
<Compile Include="Indexers\BaseIndexer.cs" />
<Compile Include="Indexers\SpeedCD.cs" />
<Compile Include="Models\Config\ServerConfig.cs" />
<Compile Include="Services\ProcessService.cs" />
<Compile Include="Services\SerializeService.cs" />
@@ -153,7 +154,7 @@
<Compile Include="Models\ConfigurationDataUrl.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="CookieContainerExtensions.cs" />
<Compile Include="DataUrl.cs" />
<Compile Include="Utils\DataUrl.cs" />
<Compile Include="ExceptionWithConfigData.cs" />
<Compile Include="HttpClientExtensions.cs" />
<Compile Include="Indexers\IIndexer.cs" />
@@ -164,7 +165,6 @@
<Compile Include="Indexers\Freshon.cs" />
<Compile Include="Indexers\HDTorrents.cs" />
<Compile Include="Indexers\IPTorrents.cs" />
<Compile Include="Indexers\Master.cs" />
<Compile Include="Indexers\MoreThanTV.cs" />
<Compile Include="Indexers\Rarbg.cs" />
<Compile Include="Indexers\SceneAccess.cs" />
@@ -179,6 +179,7 @@
<Compile Include="Indexers\TorrentShack.cs" />
<Compile Include="Indexers\Torrentz.cs" />
<Compile Include="JackettModule.cs" />
<Compile Include="Utils\DateTimeUtil.cs" />
<Compile Include="Utils\ParseUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@@ -241,6 +242,9 @@
<Content Include="Content\logos\showrss.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\logos\speedcd.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\logos\t411.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@@ -23,7 +23,7 @@ namespace Jackett
.Where(p => typeof(IIndexer).IsAssignableFrom(p) && !p.IsInterface)
.ToArray())
{
builder.RegisterType(indexer).Named<IIndexer>(indexer.Name.ToLowerInvariant()).SingleInstance();
builder.RegisterType(indexer).Named<IIndexer>(indexer.Name);
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -57,7 +58,7 @@ namespace Jackett.Models
jObject["value"] = ((BoolItem)item).Value;
break;
case ItemType.DisplayImage:
string dataUri = DataUrl.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg");
string dataUri = DataUrlUtils.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg");
jObject["value"] = dataUri;
break;
}

View File

@@ -10,6 +10,11 @@ namespace Jackett.Models
{
public StringItem Url { get; private set; }
public ConfigurationDataUrl(Uri defaultUrl)
{
Url = new StringItem { Name = "Url", Value = defaultUrl.ToString() };
}
public ConfigurationDataUrl(string defaultUrl)
{
Url = new StringItem { Name = "Url", Value = defaultUrl };

View File

@@ -27,6 +27,7 @@ namespace Jackett.Services
private IContainer container;
private IConfigurationService configService;
private Logger logger;
private Dictionary<string, IIndexer> indexers = new Dictionary<string, IIndexer>();
public IndexerManagerService(IContainer c, IConfigurationService config, Logger l)
{
@@ -37,33 +38,35 @@ namespace Jackett.Services
public void InitIndexers()
{
// Load the existing config for each indexer
foreach (var indexer in GetAllIndexers())
foreach (var idx in container.Resolve<IEnumerable<IIndexer>>().OrderBy(_ => _.DisplayName))
{
var configFilePath = GetIndexerConfigFilePath(indexer);
indexers.Add(idx.DisplayName, idx);
var configFilePath = GetIndexerConfigFilePath(idx);
if (File.Exists(configFilePath))
{
var jsonString = JObject.Parse(File.ReadAllText(configFilePath));
indexer.LoadFromSavedConfiguration(jsonString);
idx.LoadFromSavedConfiguration(jsonString);
}
}
}
public IIndexer GetIndexer(string name)
{
var indexer = GetAllIndexers().Where(i => string.Equals(i.DisplayName, name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (indexer == null)
var indexer = indexers.Values.Where(i => string.Equals(i.DisplayName, name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (indexer != null)
{
return indexer;
}
else
{
logger.Error("Request for unknown indexer: " + name);
throw new Exception("Unknown indexer: " + name);
}
return indexer;
}
public IEnumerable<IIndexer> GetAllIndexers()
{
return container.Resolve<IEnumerable<IIndexer>>().OrderBy(_ => _.DisplayName);
return indexers.Values;
}
public async void TestIndexer(string name)
@@ -79,10 +82,9 @@ namespace Jackett.Services
public void DeleteIndexer(string name)
{
var indexer = GetIndexer(name);
var configPath = configService.GetIndexerConfigDir();
var configPath = GetIndexerConfigFilePath(indexer);
File.Delete(configPath);
//Indexers.Remove(name);
//LoadMissingIndexers();
indexers[name] = container.ResolveNamed<IIndexer>(name);
}
private string GetIndexerConfigFilePath(IIndexer indexer)

View File

@@ -6,9 +6,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Jackett
namespace Jackett.Utils
{
public class DataUrl
public class DataUrlUtils
{
public static string ReadFileToDataUrl(string file)
{

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Utils
{
public static class DateTimeUtil
{
public 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);
}
}
}