Implemented torznab capabilities feature

This commit is contained in:
unknown
2015-07-19 17:05:30 -06:00
parent f6ed903ef5
commit a9f1daac73
32 changed files with 402 additions and 272 deletions

View File

@@ -29,9 +29,12 @@ namespace Jackett.Controllers
var indexer = indexerService.GetIndexer(indexerName);
var torznabQuery = TorznabQuery.FromHttpQuery(HttpUtility.ParseQueryString(Request.RequestUri.Query));
if (torznabQuery.RageIDLookupEnabled && indexer.RequiresRageIDLookupDisabled)
if (torznabQuery.QueryType == "caps")
{
throw new ArgumentException("This indexer requires RageID lookup disabled");
return new HttpResponseMessage()
{
Content = new StringContent(indexer.TorznabCaps.ToXml(), Encoding.UTF8, "application/rss+xml")
};
}
var releases = await indexer.PerformQuery(torznabQuery);

View File

@@ -18,6 +18,11 @@ namespace Jackett
static Engine()
{
#if DEBUG
TracingEnabled = true;
#endif
var builder = new ContainerBuilder();
builder.RegisterModule<JackettModule>();
container = builder.Build();
@@ -48,8 +53,10 @@ namespace Jackett
return container;
}
public static bool IsWindows {
get {
public static bool IsWindows
{
get
{
return Environment.OSVersion.Platform == PlatformID.Win32NT;
}
}

View File

@@ -16,7 +16,7 @@ using Jackett.Services;
namespace Jackett.Indexers
{
public class AlphaRatio : BaseIndexer,IIndexer
public class AlphaRatio : BaseIndexer, IIndexer
{
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
@@ -29,13 +29,13 @@ namespace Jackett.Indexers
string cookieHeader;
public AlphaRatio(IIndexerManagerService i, Logger l):
base(name: "AlphaRatio",
public AlphaRatio(IIndexerManagerService i, Logger l)
: base(name: "AlphaRatio",
description: "Legendary",
link: new Uri("https://alpharatio.cc"),
rageid: true,
manager:i,
logger:l)
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{
LoginUrl = SiteLink + "/login.php";
SearchUrl = SiteLink + "/ajax.php?action=browse&searchstr=";

View File

@@ -48,11 +48,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public AnimeBytes(IIndexerManagerService i, Logger l) :
base(name: "AnimeBytes",
public AnimeBytes(IIndexerManagerService i, Logger l)
: base(name: "AnimeBytes",
description: "The web's best Chinese cartoons",
link: new Uri("https://animebytes.tv"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -27,11 +27,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public BB(IIndexerManagerService i, Logger l) :
base(name: "bB",
public BB(IIndexerManagerService i, Logger l)
: base(name: "bB",
description: "bB",
link: new Uri("http://www.reddit.com/r/baconbits"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -16,9 +16,11 @@ namespace Jackett.Indexers
public string DisplayDescription { get; private set; }
public string DisplayName { get; private set; }
public string ID { get { return GetIndexerID(GetType()); } }
public bool IsConfigured { get; protected set; }
public Uri SiteLink { get; private set; }
public bool RequiresRageIDLookupDisabled { get; private set; }
public TorznabCapabilities TorznabCaps { get; private set; }
protected Logger logger;
protected IIndexerManagerService indexerService;
@@ -31,14 +33,14 @@ namespace Jackett.Indexers
return StringUtil.StripNonAlphaNumeric(type.Name.ToLowerInvariant());
}
public BaseIndexer(string name, string description, bool rageid, Uri link, IIndexerManagerService manager, Logger logger)
public BaseIndexer(string name, string description, Uri link, TorznabCapabilities caps, IIndexerManagerService manager, Logger logger)
{
DisplayName = name;
DisplayDescription = description;
SiteLink = link;
TorznabCaps = caps;
this.logger = logger;
indexerService = manager;
RequiresRageIDLookupDisabled = rageid;
}
protected void SaveConfig(JToken config)

View File

@@ -24,13 +24,13 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public BeyondHD(IIndexerManagerService i, Logger l) :
base(name: "BeyondHD",
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)
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{
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}";

View File

@@ -26,11 +26,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public BitHdtv(IIndexerManagerService i, Logger l) :
base(name: "BIT-HDTV",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -52,11 +52,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public BitMeTV(IIndexerManagerService i, Logger l) :
base(name: "BitMeTV",
public BitMeTV(IIndexerManagerService i, Logger l)
: base(name: "BitMeTV",
description: "TV Episode specialty tracker",
link: new Uri("http://www.bitmetv.org"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -45,11 +45,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public FrenchTorrentDb(IIndexerManagerService i, Logger l) :
base(name: "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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -29,11 +29,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public Freshon(IIndexerManagerService i, Logger l) :
base(name: "FreshOnTV",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -26,11 +26,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public HDTorrents(IIndexerManagerService i, Logger l) :
base(name: "HD-Torrents",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{
@@ -199,7 +199,7 @@ namespace Jackett.Indexers
}
catch (Exception ex)
{
OnParseError( results, ex);
OnParseError(results, ex);
}
}

View File

@@ -17,7 +17,7 @@ namespace Jackett.Indexers
Uri SiteLink { get; }
bool RequiresRageIDLookupDisabled { get; }
TorznabCapabilities TorznabCaps { get; }
// Whether this indexer has been configured, verified and saved in the past and has the settings required for functioning
bool IsConfigured { get; }

View File

@@ -23,11 +23,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public IPTorrents(IIndexerManagerService i, Logger l) :
base(name: "IPTorrents",
public IPTorrents(IIndexerManagerService i, Logger l)
: base(name: "IPTorrents",
description: "Always a step ahead.",
link: new Uri("https://iptorrents.com"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -18,7 +18,7 @@ namespace Jackett.Indexers
{
public class MoreThanTV : BaseIndexer, IIndexer
{
private readonly string LoginUrl ="";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
private readonly string DownloadUrl = "";
private readonly string GuidUrl = "";
@@ -30,11 +30,11 @@ namespace Jackett.Indexers
string cookieHeader;
int retries = 3;
public MoreThanTV(IIndexerManagerService i, Logger l) :
base(name: "MoreThanTV",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -27,11 +27,11 @@ namespace Jackett.Indexers
HttpClient client;
public Rarbg(IIndexerManagerService i, Logger l) :
base(name: "RARBG",
public Rarbg(IIndexerManagerService i, Logger l)
: base(name: "RARBG",
description: "RARBG",
link: new Uri("https://rarbg.com"),
rageid: false,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -24,11 +24,11 @@ namespace Jackett.Indexers
HttpClient client;
string cookieHeader;
public SceneAccess(IIndexerManagerService i, Logger l) :
base(name: "SceneAccess",
public SceneAccess(IIndexerManagerService i, Logger l)
: base(name: "SceneAccess",
description: "Your gateway to the scene",
link: new Uri("https://sceneaccess.eu"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -26,11 +26,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public SceneTime(IIndexerManagerService i, Logger l) :
base(name: "SceneTime",
public SceneTime(IIndexerManagerService i, Logger l)
: base(name: "SceneTime",
description: "Always on time",
link: new Uri("https://www.scenetime.com"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -25,11 +25,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public ShowRSS(IIndexerManagerService i, Logger l) :
base(name: "ShowRSS",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -22,18 +22,18 @@ namespace Jackett.Indexers
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 CommentsUrl = "";
private readonly string DownloadUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public SpeedCD(IIndexerManagerService i, Logger l) :
base(name: "Speed.cd",
public SpeedCD(IIndexerManagerService i, Logger l)
: base(name: "Speed.cd",
description: "Your home now!",
link: new Uri("http://speed.cd"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -25,11 +25,11 @@ namespace Jackett.Indexers
private HttpClientHandler handler;
private HttpClient client;
public Strike(IIndexerManagerService i, Logger l) :
base(name: "Strike",
public Strike(IIndexerManagerService i, Logger l)
: base(name: "Strike",
description: "Torrent search engine",
link: new Uri("https://getstrike.net"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -32,11 +32,11 @@ namespace Jackett.Indexers
string token = string.Empty;
DateTime lastTokenFetch = DateTime.MinValue;
public T411(IIndexerManagerService i, Logger l) :
base(name: "T411",
public T411(IIndexerManagerService i, Logger l)
: base(name: "T411",
description: "French Torrent Tracker",
link: new Uri("http://www.t411.io"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -26,11 +26,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public ThePirateBay(IIndexerManagerService i, Logger l) :
base(name: "The Pirate Bay",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -16,7 +16,7 @@ using System.Web;
namespace Jackett.Indexers
{
public class TorrentDay: BaseIndexer, IIndexer
public class TorrentDay : BaseIndexer, IIndexer
{
private readonly string StartPageUrl = "";
private readonly string LoginUrl = "";
@@ -26,11 +26,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public TorrentDay(IIndexerManagerService i, Logger l) :
base(name: "TorrentDay",
public TorrentDay(IIndexerManagerService i, Logger l)
: base(name: "TorrentDay",
description: "TorrentDay",
link: new Uri("https://torrentday.eu"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -18,18 +18,18 @@ namespace Jackett.Indexers
{
public class TorrentLeech : BaseIndexer, IIndexer
{
private readonly string LoginUrl ="";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public TorrentLeech(IIndexerManagerService i, Logger l) :
base(name: "TorrentLeech",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -18,18 +18,18 @@ namespace Jackett.Indexers
{
public class TorrentShack : BaseIndexer, IIndexer
{
private readonly string LoginUrl ="";
private readonly string LoginUrl = "";
private readonly string SearchUrl = "";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public TorrentShack(IIndexerManagerService i, Logger l) :
base(name: "TorrentShack",
public TorrentShack(IIndexerManagerService i, Logger l)
: base(name: "TorrentShack",
description: "TorrentShack",
link: new Uri("http://torrentshack.me"),
rageid: true,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -24,11 +24,11 @@ namespace Jackett.Indexers
HttpClientHandler handler;
HttpClient client;
public Torrentz(IIndexerManagerService i, Logger l) :
base(name: "Torrentz",
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,
caps: TorznabCapsUtil.CreateDefaultTorznabTVCaps(),
manager: i,
logger: l)
{

View File

@@ -144,7 +144,9 @@
<Compile Include="Indexers\BaseIndexer.cs" />
<Compile Include="Indexers\BB.cs" />
<Compile Include="Indexers\SpeedCD.cs" />
<Compile Include="Models\TorznabCapabilities.cs" />
<Compile Include="Models\Config\ServerConfig.cs" />
<Compile Include="Models\TorznabCategory.cs" />
<Compile Include="Services\ProcessService.cs" />
<Compile Include="Services\SerializeService.cs" />
<Compile Include="Services\ServiceConfigService.cs" />
@@ -202,6 +204,7 @@
<Compile Include="CurlHelper.cs" />
<Compile Include="Indexers\AlphaRatio.cs" />
<Compile Include="Utils\StringUtil.cs" />
<Compile Include="Utils\TorznabCapsUtil.cs" />
<Compile Include="Utils\WebAPIRequestLogger.cs" />
<Compile Include="Utils\WebAPIToNLogTracer.cs" />
</ItemGroup>

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Jackett.Models
{
public class TorznabCapabilities
{
public bool SearchAvailable { get; set; }
public bool TVSearchAvailable { get; set; }
public bool SupportsTVRageSearch { get; set; }
public List<TorznabCategory> Categories { get; private set; }
public TorznabCapabilities()
{
Categories = new List<TorznabCategory>();
}
string SupportedTVSearchParams
{
get
{
var parameters = new List<string>() { "q", "season", "ep" };
if (SupportsTVRageSearch)
parameters.Add("rid");
return string.Join(",", parameters);
}
}
public string ToXml()
{
var xdoc = new XDocument(
new XDeclaration("1.0", "UTF-8", null),
new XElement("caps",
new XElement("searching",
new XElement("search",
new XAttribute("available", SearchAvailable ? "yes" : "no"),
new XAttribute("supportedParams", "q")
),
new XElement("tv-search",
new XAttribute("available", TVSearchAvailable ? "yes" : "no"),
new XAttribute("supportedParams", SupportedTVSearchParams)
)
),
new XElement("categories",
from c in Categories
select new XElement("category",
new XAttribute("id", c.ID),
new XAttribute("name", c.Name),
from sc in c.SubCategories
select new XElement("subcat",
new XAttribute("id", sc.ID),
new XAttribute("name", sc.Name)
)
)
)
)
);
return xdoc.Declaration.ToString() + Environment.NewLine + xdoc.ToString();
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Models
{
public class TorznabCategory
{
public string ID { get; set; }
public string Name { get; set; }
public List<TorznabCategory> SubCategories { get; private set; }
public TorznabCategory()
{
SubCategories = new List<TorznabCategory>();
}
}
}

View File

@@ -18,7 +18,6 @@ namespace Jackett.Models
public int Limit { get; private set; }
public int Offset { get; private set; }
public int RageID { get; private set; }
public bool RageIDLookupEnabled { get; private set; }
public int Season { get; private set; }
public string Episode { get; private set; }
@@ -73,8 +72,6 @@ namespace Jackett.Models
q.SanitizedSearchTerm = SanitizeSearchTerm(q.SearchTerm);
}
q.RageIDLookupEnabled = query["rid_enabled"] != "0";
if (query["cat"] != null)
{
q.Categories = query["cat"].Split(',');

View File

@@ -0,0 +1,27 @@
using Jackett.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Utils
{
public static class TorznabCapsUtil
{
public static TorznabCapabilities CreateDefaultTorznabTVCaps()
{
var caps = new TorznabCapabilities();
caps.SearchAvailable = true;
caps.TVSearchAvailable = true;
caps.SupportsTVRageSearch = false;
caps.Categories.AddRange(new[] {
new TorznabCategory { ID = "5000", Name = "TV" },
new TorznabCategory { ID = "5030", Name = "TV/SD" },
new TorznabCategory { ID = "5040", Name = "TV/HD" }
});
return caps;
}
}
}