mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Merge v0.6.4
This commit is contained in:
@@ -20,6 +20,7 @@ We were previously focused on TV but are working on extending searches to allow
|
||||
#### Supported Trackers
|
||||
* [AlphaRatio](https://alpharatio.cc/)
|
||||
* [AnimeBytes](https://animebytes.tv/)
|
||||
* [AnimeTorrents](http://animetorrents.me/)
|
||||
* [Avistaz](https://avistaz.to/)
|
||||
* [BakaBT](http://bakabt.me/)
|
||||
* [bB](http://reddit.com/r/baconbits)
|
||||
@@ -59,7 +60,7 @@ We were previously focused on TV but are working on extending searches to allow
|
||||
* Debian/Ubunutu: apt-get install libcurl-dev
|
||||
* Redhat/Fedora: yum install libcurl-devel
|
||||
* For other distros see the [Curl docs](http://curl.haxx.se/dlwiz/?type=devel).
|
||||
3. Download and extract the latest ```.tar.bz2``` release from the [website](http://jackett.net/Download) and run Jackett using mono with the command "mono JackettConsole.exe".
|
||||
3. Download and extract the latest ```.tar.bz2``` release from the [website](http://jackett.net/Download) and run Jackett using mono with the command "mono JackettConsole.exe".
|
||||
|
||||
|
||||
#### Installation on Windows
|
||||
|
BIN
src/Jackett/Content/logos/animetorrents.png
Normal file
BIN
src/Jackett/Content/logos/animetorrents.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
src/Jackett/Content/logos/nxtgn.png
Normal file
BIN
src/Jackett/Content/logos/nxtgn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@@ -1,162 +1,167 @@
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Jackett.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[JackettAPINoCache]
|
||||
public class PotatoController : ApiController
|
||||
{
|
||||
private IIndexerManagerService indexerService;
|
||||
private Logger logger;
|
||||
private IServerService serverService;
|
||||
private ICacheService cacheService;
|
||||
private IWebClient webClient;
|
||||
|
||||
public static int[] MOVIE_CATS
|
||||
{
|
||||
get
|
||||
{
|
||||
var torznabQuery = new TorznabQuery()
|
||||
{
|
||||
Categories = new int[1] { TorznabCatType.Movies.ID },
|
||||
};
|
||||
|
||||
torznabQuery.ExpandCatsToSubCats();
|
||||
return torznabQuery.Categories;
|
||||
}
|
||||
}
|
||||
|
||||
public PotatoController(IIndexerManagerService i, Logger l, IServerService s, ICacheService c, IWebClient w)
|
||||
{
|
||||
indexerService = i;
|
||||
logger = l;
|
||||
serverService = s;
|
||||
cacheService = c;
|
||||
webClient = w;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<HttpResponseMessage> Call(string indexerID, [FromUri]TorrentPotatoRequest request)
|
||||
{
|
||||
var indexer = indexerService.GetIndexer(indexerID);
|
||||
|
||||
var allowBadApiDueToDebug = false;
|
||||
#if DEBUG
|
||||
allowBadApiDueToDebug = Debugger.IsAttached;
|
||||
#endif
|
||||
|
||||
if (!allowBadApiDueToDebug && !string.Equals(request.passkey, serverService.Config.APIKey, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
logger.Warn(string.Format("A request from {0} was made with an incorrect API key.", Request.GetOwinContext().Request.RemoteIpAddress));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "Incorrect API key");
|
||||
}
|
||||
|
||||
if (!indexer.IsConfigured)
|
||||
{
|
||||
logger.Warn(string.Format("Rejected a request to {0} which is unconfigured.", indexer.DisplayName));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "This indexer is not configured.");
|
||||
}
|
||||
|
||||
if (!indexer.TorznabCaps.Categories.Select(c => c.ID).Any(i => MOVIE_CATS.Contains(i))){
|
||||
logger.Warn(string.Format("Rejected a request to {0} which does not support searching for movies.", indexer.DisplayName));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "This indexer does not support movies.");
|
||||
}
|
||||
|
||||
var year = 0;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.search))
|
||||
{
|
||||
// We are searching by IMDB id so look up the name
|
||||
var response = await webClient.GetString(new Utils.Clients.WebRequest("http://www.omdbapi.com/?type=movie&i=" + request.imdbid));
|
||||
if (response.Status == HttpStatusCode.OK)
|
||||
{
|
||||
JObject result = JObject.Parse(response.Content);
|
||||
if (result["Title"] != null)
|
||||
{
|
||||
request.search = result["Title"].ToString();
|
||||
year = ParseUtil.CoerceInt(result["Year"].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var torznabQuery = new TorznabQuery()
|
||||
{
|
||||
ApiKey = request.passkey,
|
||||
Categories = MOVIE_CATS,
|
||||
SearchTerm = request.search
|
||||
};
|
||||
|
||||
IEnumerable<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
releases = await indexer.PerformQuery(torznabQuery);
|
||||
releases = indexer.CleanLinks(releases);
|
||||
}
|
||||
|
||||
// Cache non query results
|
||||
if (string.IsNullOrEmpty(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
cacheService.CacheRssResults(indexer, releases);
|
||||
}
|
||||
|
||||
releases = indexer.FilterResults(torznabQuery, releases);
|
||||
var serverUrl = string.Format("{0}://{1}:{2}/", Request.RequestUri.Scheme, Request.RequestUri.Host, Request.RequestUri.Port);
|
||||
var potatoResponse = new TorrentPotatoResponse();
|
||||
|
||||
releases = TorznabUtil.FilterResultsToTitle(releases, torznabQuery.SanitizedSearchTerm, year);
|
||||
|
||||
foreach (var r in releases)
|
||||
{
|
||||
var release = Mapper.Map<ReleaseInfo>(r);
|
||||
release.Link = serverService.ConvertToProxyLink(release.Link, serverUrl, indexerID);
|
||||
|
||||
potatoResponse.results.Add(new TorrentPotatoResponseItem()
|
||||
{
|
||||
release_name = release.Title + "[" + indexer.DisplayName + "]", // Suffix the indexer so we can see which tracker we are using in CPS as it just says torrentpotato >.>
|
||||
torrent_id = release.Guid.ToString(),
|
||||
details_url = release.Comments.ToString(),
|
||||
download_url = release.Link.ToString(),
|
||||
// imdb_id = request.imdbid,
|
||||
freeleech = false,
|
||||
type = "movie",
|
||||
size = (long)release.Size/ (1024 * 1024), // This is in MB
|
||||
leechers = (int)release.Peers - (int)release.Seeders,
|
||||
seeders = (int)release.Seeders
|
||||
});
|
||||
}
|
||||
|
||||
// Log info
|
||||
if (string.IsNullOrWhiteSpace(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
logger.Info(string.Format("Found {0} torrentpotato releases from {1}", releases.Count(), indexer.DisplayName));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info(string.Format("Found {0} torrentpotato releases from {1} for: {2}", releases.Count(), indexer.DisplayName, torznabQuery.GetQueryString()));
|
||||
}
|
||||
|
||||
// Force the return as Json
|
||||
return new HttpResponseMessage()
|
||||
{
|
||||
Content = new JsonContent(potatoResponse)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Jackett.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[JackettAPINoCache]
|
||||
public class PotatoController : ApiController
|
||||
{
|
||||
private IIndexerManagerService indexerService;
|
||||
private Logger logger;
|
||||
private IServerService serverService;
|
||||
private ICacheService cacheService;
|
||||
private IWebClient webClient;
|
||||
|
||||
public static int[] MOVIE_CATS
|
||||
{
|
||||
get
|
||||
{
|
||||
var torznabQuery = new TorznabQuery()
|
||||
{
|
||||
Categories = new int[1] { TorznabCatType.Movies.ID },
|
||||
};
|
||||
|
||||
torznabQuery.ExpandCatsToSubCats();
|
||||
return torznabQuery.Categories;
|
||||
}
|
||||
}
|
||||
|
||||
public PotatoController(IIndexerManagerService i, Logger l, IServerService s, ICacheService c, IWebClient w)
|
||||
{
|
||||
indexerService = i;
|
||||
logger = l;
|
||||
serverService = s;
|
||||
cacheService = c;
|
||||
webClient = w;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<HttpResponseMessage> Call(string indexerID, [FromUri]TorrentPotatoRequest request)
|
||||
{
|
||||
var indexer = indexerService.GetIndexer(indexerID);
|
||||
|
||||
var allowBadApiDueToDebug = false;
|
||||
#if DEBUG
|
||||
allowBadApiDueToDebug = Debugger.IsAttached;
|
||||
#endif
|
||||
|
||||
if (!allowBadApiDueToDebug && !string.Equals(request.passkey, serverService.Config.APIKey, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
logger.Warn(string.Format("A request from {0} was made with an incorrect API key.", Request.GetOwinContext().Request.RemoteIpAddress));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "Incorrect API key");
|
||||
}
|
||||
|
||||
if (!indexer.IsConfigured)
|
||||
{
|
||||
logger.Warn(string.Format("Rejected a request to {0} which is unconfigured.", indexer.DisplayName));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "This indexer is not configured.");
|
||||
}
|
||||
|
||||
if (!indexer.TorznabCaps.Categories.Select(c => c.ID).Any(i => MOVIE_CATS.Contains(i))){
|
||||
logger.Warn(string.Format("Rejected a request to {0} which does not support searching for movies.", indexer.DisplayName));
|
||||
return Request.CreateResponse(HttpStatusCode.Forbidden, "This indexer does not support movies.");
|
||||
}
|
||||
|
||||
var year = 0;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.search))
|
||||
{
|
||||
// We are searching by IMDB id so look up the name
|
||||
var response = await webClient.GetString(new Utils.Clients.WebRequest("http://www.omdbapi.com/?type=movie&i=" + request.imdbid));
|
||||
if (response.Status == HttpStatusCode.OK)
|
||||
{
|
||||
JObject result = JObject.Parse(response.Content);
|
||||
if (result["Title"] != null)
|
||||
{
|
||||
request.search = result["Title"].ToString();
|
||||
year = ParseUtil.CoerceInt(result["Year"].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var torznabQuery = new TorznabQuery()
|
||||
{
|
||||
ApiKey = request.passkey,
|
||||
Categories = MOVIE_CATS,
|
||||
SearchTerm = request.search
|
||||
};
|
||||
|
||||
IEnumerable<ReleaseInfo> releases = new List<ReleaseInfo>();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
releases = await indexer.PerformQuery(torznabQuery);
|
||||
releases = indexer.CleanLinks(releases);
|
||||
}
|
||||
|
||||
// Cache non query results
|
||||
if (string.IsNullOrEmpty(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
cacheService.CacheRssResults(indexer, releases);
|
||||
}
|
||||
|
||||
releases = indexer.FilterResults(torznabQuery, releases);
|
||||
var serverUrl = string.Format("{0}://{1}:{2}/", Request.RequestUri.Scheme, Request.RequestUri.Host, Request.RequestUri.Port);
|
||||
var potatoResponse = new TorrentPotatoResponse();
|
||||
|
||||
releases = TorznabUtil.FilterResultsToTitle(releases, torznabQuery.SanitizedSearchTerm, year);
|
||||
releases = TorznabUtil.FilterResultsToImdb(releases, request.imdbid);
|
||||
|
||||
foreach (var r in releases)
|
||||
{
|
||||
var release = Mapper.Map<ReleaseInfo>(r);
|
||||
release.Link = serverService.ConvertToProxyLink(release.Link, serverUrl, indexerID);
|
||||
|
||||
// Only accept torrent links, magnet is not supported
|
||||
if (release.Link != null)
|
||||
{
|
||||
potatoResponse.results.Add(new TorrentPotatoResponseItem()
|
||||
{
|
||||
release_name = release.Title + "[" + indexer.DisplayName + "]", // Suffix the indexer so we can see which tracker we are using in CPS as it just says torrentpotato >.>
|
||||
torrent_id = release.Guid.ToString(),
|
||||
details_url = release.Comments.ToString(),
|
||||
download_url = release.Link.ToString(),
|
||||
imdb_id = release.Imdb.HasValue ? "tt" + release.Imdb : null,
|
||||
freeleech = false,
|
||||
type = "movie",
|
||||
size = (long)release.Size / (1024 * 1024), // This is in MB
|
||||
leechers = (int)release.Peers - (int)release.Seeders,
|
||||
seeders = (int)release.Seeders
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Log info
|
||||
if (string.IsNullOrWhiteSpace(torznabQuery.SanitizedSearchTerm))
|
||||
{
|
||||
logger.Info(string.Format("Found {0} torrentpotato releases from {1}", releases.Count(), indexer.DisplayName));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info(string.Format("Found {0} torrentpotato releases from {1} for: {2}", releases.Count(), indexer.DisplayName, torznabQuery.GetQueryString()));
|
||||
}
|
||||
|
||||
// Force the return as Json
|
||||
return new HttpResponseMessage()
|
||||
{
|
||||
Content = new JsonContent(potatoResponse)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
176
src/Jackett/Indexers/AnimeTorrents.cs
Normal file
176
src/Jackett/Indexers/AnimeTorrents.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using CsQuery;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class AnimeTorrents : BaseIndexer, IIndexer
|
||||
{
|
||||
private string LoginUrl { get { return SiteLink + "login.php"; } }
|
||||
private string SearchUrl { get { return SiteLink + "ajax/torrents_data.php"; } }
|
||||
private string SearchUrlReferer { get { return SiteLink + "torrents.php?cat=0&searchin=filename&search="; } }
|
||||
|
||||
new ConfigurationDataBasicLogin configData
|
||||
{
|
||||
get { return (ConfigurationDataBasicLogin)base.configData; }
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
public AnimeTorrents(IIndexerManagerService i, HttpWebClient c, Logger l, IProtectionService ps)
|
||||
: base(name: "AnimeTorrents",
|
||||
description: "Definitive source for anime and manga",
|
||||
link: "http://animetorrents.me/",
|
||||
caps: new TorznabCapabilities(),
|
||||
manager: i,
|
||||
client: c, // Forced HTTP client for custom headers
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataBasicLogin())
|
||||
{
|
||||
AddCategoryMapping(1, TorznabCatType.MoviesSD); // Anime Movie
|
||||
AddCategoryMapping(6, TorznabCatType.MoviesHD); // Anime Movie HD
|
||||
AddCategoryMapping(2, TorznabCatType.TVAnime); // Anime Series
|
||||
AddCategoryMapping(7, TorznabCatType.TVAnime); // Anime Series HD
|
||||
AddCategoryMapping(5, TorznabCatType.XXXDVD); // Hentai (censored)
|
||||
AddCategoryMapping(9, TorznabCatType.XXXDVD); // Hentai (censored) HD
|
||||
AddCategoryMapping(4, TorznabCatType.XXXDVD); // Hentai (un-censored)
|
||||
AddCategoryMapping(8, TorznabCatType.XXXDVD); // Hentai (un-censored) HD
|
||||
AddCategoryMapping(13, TorznabCatType.BooksForeign); // Light Novel
|
||||
AddCategoryMapping(3, TorznabCatType.BooksComics); // Manga
|
||||
AddCategoryMapping(10, TorznabCatType.BooksComics); // Manga 18+
|
||||
AddCategoryMapping(11, TorznabCatType.TVAnime); // OVA
|
||||
AddCategoryMapping(12, TorznabCatType.TVAnime); // OVA HD
|
||||
AddCategoryMapping(14, TorznabCatType.BooksComics); // Doujin Anime
|
||||
AddCategoryMapping(15, TorznabCatType.XXXDVD); // Doujin Anime 18+
|
||||
AddCategoryMapping(16, TorznabCatType.AudioForeign); // Doujin Music
|
||||
AddCategoryMapping(17, TorznabCatType.BooksComics); // Doujinshi
|
||||
AddCategoryMapping(18, TorznabCatType.BooksComics); // Doujinshi 18+
|
||||
AddCategoryMapping(19, TorznabCatType.Audio); // OST
|
||||
}
|
||||
|
||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
configData.LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value },
|
||||
{ "form", "login" },
|
||||
{ "rememberme[]", "1" }
|
||||
};
|
||||
|
||||
var loginPage = await RequestStringWithCookiesAndRetry(LoginUrl, null, null);
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, SearchUrl, SiteLink);
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
CQ dom = result.Content;
|
||||
var errorMessage = dom[".ui-state-error"].Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
var searchUrl = SearchUrl;
|
||||
var queryCollection = new NameValueCollection();
|
||||
|
||||
queryCollection.Add("total", "146"); // Not sure what this is about but its required!
|
||||
|
||||
var cat = "0";
|
||||
var queryCats = MapTorznabCapsToTrackers(query);
|
||||
if (queryCats.Count == 1)
|
||||
{
|
||||
cat = queryCats.First().ToString();
|
||||
}
|
||||
|
||||
queryCollection.Add("cat", cat);
|
||||
queryCollection.Add("searchin", "filename");
|
||||
queryCollection.Add("search", searchString);
|
||||
queryCollection.Add("page", "1");
|
||||
searchUrl += "?" + queryCollection.GetQueryString();
|
||||
|
||||
var extraHeaders = new Dictionary<string, string>()
|
||||
{
|
||||
{ "X-Requested-With", "XMLHttpRequest" }
|
||||
};
|
||||
|
||||
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, SearchUrlReferer, extraHeaders);
|
||||
|
||||
var results = response.Content;
|
||||
try
|
||||
{
|
||||
CQ dom = results;
|
||||
|
||||
var rows = dom["tr"];
|
||||
foreach (var row in rows.Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
var qRow = row.Cq();
|
||||
var qTitleLink = qRow.Find("td:eq(1) a:eq(0)").First();
|
||||
release.Title = qTitleLink.Find("strong").Text().Trim();
|
||||
|
||||
// If we search an get no results, we still get a table just with no info.
|
||||
if (string.IsNullOrWhiteSpace(release.Title))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(qTitleLink.Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
|
||||
var dateString = qRow.Find("td:eq(4)").Text();
|
||||
release.PublishDate = DateTime.ParseExact(dateString, "dd MMM yy", CultureInfo.InvariantCulture);
|
||||
|
||||
var qLink = qRow.Find("td:eq(2) a");
|
||||
release.Link = new Uri(qLink.Attr("href"));
|
||||
|
||||
var sizeStr = qRow.Find("td:eq(5)").Text();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
||||
|
||||
var connections = qRow.Find("td:eq(7)").Text().Trim().Split("/".ToCharArray(),StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(connections[0].Trim());
|
||||
release.Peers = ParseUtil.CoerceInt(connections[1].Trim()) + release.Seeders;
|
||||
|
||||
var rCat = row.Cq().Find("td:eq(0) a").First().Attr("href");
|
||||
var rCatIdx = rCat.IndexOf("cat=");
|
||||
if (rCatIdx > -1)
|
||||
{
|
||||
rCat = rCat.Substring(rCatIdx + 4);
|
||||
}
|
||||
|
||||
release.Category = MapTrackerCatToNewznab(rCat);
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results, ex);
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,451 +1,452 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jackett.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using AutoMapper;
|
||||
using System.Threading;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public abstract class BaseIndexer
|
||||
{
|
||||
public string SiteLink { get; private set; }
|
||||
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 TorznabCapabilities TorznabCaps { get; private set; }
|
||||
protected Logger logger;
|
||||
protected IIndexerManagerService indexerService;
|
||||
protected static List<CachedQueryResult> cache = new List<CachedQueryResult>();
|
||||
protected static readonly TimeSpan cacheTime = new TimeSpan(0, 9, 0);
|
||||
protected IWebClient webclient;
|
||||
protected IProtectionService protectionService;
|
||||
protected readonly string downloadUrlBase = "";
|
||||
|
||||
protected string CookieHeader
|
||||
{
|
||||
get { return configData.CookieHeader.Value; }
|
||||
set { configData.CookieHeader.Value = value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ConfigurationData configData;
|
||||
|
||||
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
|
||||
|
||||
public BaseIndexer(string name, string link, string description, IIndexerManagerService manager, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null)
|
||||
{
|
||||
if (!link.EndsWith("/"))
|
||||
throw new Exception("Site link must end with a slash.");
|
||||
|
||||
DisplayName = name;
|
||||
DisplayDescription = description;
|
||||
SiteLink = link;
|
||||
this.logger = logger;
|
||||
indexerService = manager;
|
||||
webclient = client;
|
||||
protectionService = p;
|
||||
this.downloadUrlBase = downloadBase;
|
||||
|
||||
this.configData = configData;
|
||||
|
||||
if (caps == null)
|
||||
caps = TorznabUtil.CreateDefaultTorznabTVCaps();
|
||||
TorznabCaps = caps;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<ReleaseInfo> CleanLinks(IEnumerable<ReleaseInfo> releases)
|
||||
{
|
||||
if (string.IsNullOrEmpty(downloadUrlBase))
|
||||
return releases;
|
||||
foreach (var release in releases)
|
||||
{
|
||||
if (release.Link.ToString().StartsWith(downloadUrlBase))
|
||||
{
|
||||
release.Link = new Uri(release.Link.ToString().Substring(downloadUrlBase.Length), UriKind.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
public Uri UncleanLink(Uri link)
|
||||
{
|
||||
return new Uri(downloadUrlBase + link.ToString(), UriKind.RelativeOrAbsolute);
|
||||
}
|
||||
|
||||
protected int MapTrackerCatToNewznab(string input)
|
||||
{
|
||||
if (null != input)
|
||||
{
|
||||
input = input.ToLowerInvariant();
|
||||
var mapping = categoryMapping.Where(m => m.TrackerCategory.ToLowerInvariant() == input.ToLowerInvariant()).FirstOrDefault();
|
||||
if (mapping != null)
|
||||
{
|
||||
return mapping.NewzNabCategory;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string GetIndexerID(Type type)
|
||||
{
|
||||
return StringUtil.StripNonAlphaNumeric(type.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
public virtual Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
return Task.FromResult<ConfigurationData>(configData);
|
||||
}
|
||||
|
||||
public virtual void ResetBaseConfig()
|
||||
{
|
||||
CookieHeader = string.Empty;
|
||||
IsConfigured = false;
|
||||
}
|
||||
|
||||
protected virtual void SaveConfig()
|
||||
{
|
||||
indexerService.SaveConfig(this as IIndexer, configData.ToJson(protectionService, forDisplay: false));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected void CleanCache()
|
||||
{
|
||||
foreach (var expired in cache.Where(i => i.Created - DateTime.Now > cacheTime).ToList())
|
||||
{
|
||||
cache.Remove(expired);
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task FollowIfRedirect(WebClientStringResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
var byteResult = new WebClientByteResult();
|
||||
// Map to byte
|
||||
Mapper.Map(response, byteResult);
|
||||
await FollowIfRedirect(byteResult, referrer, overrideRedirectUrl, overrideCookies);
|
||||
// Map to string
|
||||
Mapper.Map(byteResult, response);
|
||||
}
|
||||
|
||||
protected async Task FollowIfRedirect(WebClientByteResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
// Follow up to 5 redirects
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (!response.IsRedirect)
|
||||
break;
|
||||
await DoFollowIfRedirect(response, referrer, overrideRedirectUrl, overrideCookies);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoFollowIfRedirect(WebClientByteResult incomingResponse, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
if (incomingResponse.IsRedirect)
|
||||
{
|
||||
// Do redirect
|
||||
var redirectedResponse = await webclient.GetBytes(new WebRequest()
|
||||
{
|
||||
Url = overrideRedirectUrl ?? incomingResponse.RedirectingTo,
|
||||
Referer = referrer,
|
||||
Cookies = overrideCookies ?? CookieHeader
|
||||
});
|
||||
Mapper.Map(redirectedResponse, incomingResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void LoadLegacyCookieConfig(JToken jsonConfig)
|
||||
{
|
||||
string legacyCookieHeader = (string)jsonConfig["cookie_header"];
|
||||
if (!string.IsNullOrEmpty(legacyCookieHeader))
|
||||
{
|
||||
CookieHeader = legacyCookieHeader;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy cookie key
|
||||
var jcookies = jsonConfig["cookies"];
|
||||
if (jcookies is JArray)
|
||||
{
|
||||
var array = (JArray)jcookies;
|
||||
legacyCookieHeader = string.Empty;
|
||||
for (int i = 0; i < array.Count; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
legacyCookieHeader += "; ";
|
||||
legacyCookieHeader += array[i];
|
||||
}
|
||||
CookieHeader = legacyCookieHeader;
|
||||
}
|
||||
else if (jcookies != null)
|
||||
{
|
||||
CookieHeader = (string)jcookies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
if (jsonConfig is JArray)
|
||||
{
|
||||
configData.LoadValuesFromJson(jsonConfig, protectionService);
|
||||
IsConfigured = true;
|
||||
}
|
||||
// read and upgrade old settings file format
|
||||
else if (jsonConfig is Object)
|
||||
{
|
||||
LoadLegacyCookieConfig(jsonConfig);
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public async virtual Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var response = await RequestBytesWithCookiesAndRetry(link.ToString());
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
protected async Task<WebClientByteResult> RequestBytesWithCookiesAndRetry(string url, string cookieOverride = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await RequestBytesWithCookies(url, cookieOverride);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} downloading from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestStringWithCookies(string url, string cookieOverride = null, string referer = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.GET,
|
||||
Cookies = CookieHeader,
|
||||
Referer = referer
|
||||
};
|
||||
|
||||
if (cookieOverride != null)
|
||||
request.Cookies = cookieOverride;
|
||||
return await webclient.GetString(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestStringWithCookiesAndRetry(string url, string cookieOverride = null, string referer = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await RequestStringWithCookies(url, cookieOverride, referer);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} checking for results from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientByteResult> RequestBytesWithCookies(string url, string cookieOverride = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.GET,
|
||||
Cookies = cookieOverride ?? CookieHeader
|
||||
};
|
||||
|
||||
if (cookieOverride != null)
|
||||
request.Cookies = cookieOverride;
|
||||
return await webclient.GetBytes(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> PostDataWithCookies(string url, IEnumerable<KeyValuePair<string, string>> data, string cookieOverride = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.POST,
|
||||
Cookies = cookieOverride ?? CookieHeader,
|
||||
PostData = data
|
||||
};
|
||||
return await webclient.GetString(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> PostDataWithCookiesAndRetry(string url, IEnumerable<KeyValuePair<string, string>> data, string cookieOverride = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await PostDataWithCookies(url, data, cookieOverride);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} checking for results from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestLoginAndFollowRedirect(string url, IEnumerable<KeyValuePair<string, string>> data, string cookies, bool returnCookiesFromFirstCall, string redirectUrlOverride = null, string referer = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.POST,
|
||||
Cookies = cookies,
|
||||
Referer = referer,
|
||||
PostData = data
|
||||
};
|
||||
var response = await webclient.GetString(request);
|
||||
var firstCallCookies = response.Cookies;
|
||||
|
||||
if (response.IsRedirect)
|
||||
{
|
||||
await FollowIfRedirect(response, request.Url, null, response.Cookies);
|
||||
}
|
||||
|
||||
if (returnCookiesFromFirstCall)
|
||||
{
|
||||
response.Cookies = firstCallCookies;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
protected async Task ConfigureIfOK(string cookies, bool isLoggedin, Func<Task> onError)
|
||||
{
|
||||
if (isLoggedin)
|
||||
{
|
||||
CookieHeader = cookies;
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
await onError();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> results)
|
||||
{
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (query.Categories.Length == 0 || query.Categories.Contains(result.Category) || result.Category == 0 || TorznabCatType.QueryContainsParentCategory(query.Categories, result.Category))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(string trackerCategory, int newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory, newznabCategory));
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(int trackerCategory, int newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory));
|
||||
}
|
||||
|
||||
protected void AddMultiCategoryMapping(TorznabCategory newznabCategory, params int[] trackerCategories)
|
||||
{
|
||||
foreach (var trackerCat in trackerCategories)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCat.ToString(), newznabCategory.ID));
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddMultiCategoryMapping(int trackerCategory, params TorznabCategory[] newznabCategories)
|
||||
{
|
||||
foreach (var newznabCat in newznabCategories)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCat.ID));
|
||||
}
|
||||
}
|
||||
|
||||
protected List<string> MapTorznabCapsToTrackers(TorznabQuery query, bool mapChildrenCatsToParent = false)
|
||||
{
|
||||
var result = new List<string>();
|
||||
foreach (var cat in query.Categories)
|
||||
{
|
||||
var queryCats = new List<int> { cat };
|
||||
var newznabCat = TorznabCatType.AllCats.FirstOrDefault(c => c.ID == cat);
|
||||
if (newznabCat != null)
|
||||
{
|
||||
queryCats.AddRange(newznabCat.SubCategories.Select(c => c.ID));
|
||||
}
|
||||
|
||||
if (mapChildrenCatsToParent)
|
||||
{
|
||||
var parentNewznabCat = TorznabCatType.AllCats.FirstOrDefault(c => c.SubCategories.Contains(newznabCat));
|
||||
if (parentNewznabCat != null)
|
||||
{
|
||||
queryCats.Add(parentNewznabCat.ID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mapping in categoryMapping.Where(c => queryCats.Contains(c.NewzNabCategory)))
|
||||
{
|
||||
result.Add(mapping.TrackerCategory);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jackett.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using AutoMapper;
|
||||
using System.Threading;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public abstract class BaseIndexer
|
||||
{
|
||||
public string SiteLink { get; private set; }
|
||||
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 TorznabCapabilities TorznabCaps { get; private set; }
|
||||
protected Logger logger;
|
||||
protected IIndexerManagerService indexerService;
|
||||
protected static List<CachedQueryResult> cache = new List<CachedQueryResult>();
|
||||
protected static readonly TimeSpan cacheTime = new TimeSpan(0, 9, 0);
|
||||
protected IWebClient webclient;
|
||||
protected IProtectionService protectionService;
|
||||
protected readonly string downloadUrlBase = "";
|
||||
|
||||
protected string CookieHeader
|
||||
{
|
||||
get { return configData.CookieHeader.Value; }
|
||||
set { configData.CookieHeader.Value = value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ConfigurationData configData;
|
||||
|
||||
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
|
||||
|
||||
public BaseIndexer(string name, string link, string description, IIndexerManagerService manager, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null)
|
||||
{
|
||||
if (!link.EndsWith("/"))
|
||||
throw new Exception("Site link must end with a slash.");
|
||||
|
||||
DisplayName = name;
|
||||
DisplayDescription = description;
|
||||
SiteLink = link;
|
||||
this.logger = logger;
|
||||
indexerService = manager;
|
||||
webclient = client;
|
||||
protectionService = p;
|
||||
this.downloadUrlBase = downloadBase;
|
||||
|
||||
this.configData = configData;
|
||||
|
||||
if (caps == null)
|
||||
caps = TorznabUtil.CreateDefaultTorznabTVCaps();
|
||||
TorznabCaps = caps;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<ReleaseInfo> CleanLinks(IEnumerable<ReleaseInfo> releases)
|
||||
{
|
||||
if (string.IsNullOrEmpty(downloadUrlBase))
|
||||
return releases;
|
||||
foreach (var release in releases)
|
||||
{
|
||||
if (release.Link.ToString().StartsWith(downloadUrlBase))
|
||||
{
|
||||
release.Link = new Uri(release.Link.ToString().Substring(downloadUrlBase.Length), UriKind.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
public Uri UncleanLink(Uri link)
|
||||
{
|
||||
return new Uri(downloadUrlBase + link.ToString(), UriKind.RelativeOrAbsolute);
|
||||
}
|
||||
|
||||
protected int MapTrackerCatToNewznab(string input)
|
||||
{
|
||||
if (null != input)
|
||||
{
|
||||
input = input.ToLowerInvariant();
|
||||
var mapping = categoryMapping.Where(m => m.TrackerCategory.ToLowerInvariant() == input.ToLowerInvariant()).FirstOrDefault();
|
||||
if (mapping != null)
|
||||
{
|
||||
return mapping.NewzNabCategory;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string GetIndexerID(Type type)
|
||||
{
|
||||
return StringUtil.StripNonAlphaNumeric(type.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
public virtual Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
return Task.FromResult<ConfigurationData>(configData);
|
||||
}
|
||||
|
||||
public virtual void ResetBaseConfig()
|
||||
{
|
||||
CookieHeader = string.Empty;
|
||||
IsConfigured = false;
|
||||
}
|
||||
|
||||
protected virtual void SaveConfig()
|
||||
{
|
||||
indexerService.SaveConfig(this as IIndexer, configData.ToJson(protectionService, forDisplay: false));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected void CleanCache()
|
||||
{
|
||||
foreach (var expired in cache.Where(i => i.Created - DateTime.Now > cacheTime).ToList())
|
||||
{
|
||||
cache.Remove(expired);
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task FollowIfRedirect(WebClientStringResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
var byteResult = new WebClientByteResult();
|
||||
// Map to byte
|
||||
Mapper.Map(response, byteResult);
|
||||
await FollowIfRedirect(byteResult, referrer, overrideRedirectUrl, overrideCookies);
|
||||
// Map to string
|
||||
Mapper.Map(byteResult, response);
|
||||
}
|
||||
|
||||
protected async Task FollowIfRedirect(WebClientByteResult response, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
// Follow up to 5 redirects
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (!response.IsRedirect)
|
||||
break;
|
||||
await DoFollowIfRedirect(response, referrer, overrideRedirectUrl, overrideCookies);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoFollowIfRedirect(WebClientByteResult incomingResponse, string referrer = null, string overrideRedirectUrl = null, string overrideCookies = null)
|
||||
{
|
||||
if (incomingResponse.IsRedirect)
|
||||
{
|
||||
// Do redirect
|
||||
var redirectedResponse = await webclient.GetBytes(new WebRequest()
|
||||
{
|
||||
Url = overrideRedirectUrl ?? incomingResponse.RedirectingTo,
|
||||
Referer = referrer,
|
||||
Cookies = overrideCookies ?? CookieHeader
|
||||
});
|
||||
Mapper.Map(redirectedResponse, incomingResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void LoadLegacyCookieConfig(JToken jsonConfig)
|
||||
{
|
||||
string legacyCookieHeader = (string)jsonConfig["cookie_header"];
|
||||
if (!string.IsNullOrEmpty(legacyCookieHeader))
|
||||
{
|
||||
CookieHeader = legacyCookieHeader;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy cookie key
|
||||
var jcookies = jsonConfig["cookies"];
|
||||
if (jcookies is JArray)
|
||||
{
|
||||
var array = (JArray)jcookies;
|
||||
legacyCookieHeader = string.Empty;
|
||||
for (int i = 0; i < array.Count; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
legacyCookieHeader += "; ";
|
||||
legacyCookieHeader += array[i];
|
||||
}
|
||||
CookieHeader = legacyCookieHeader;
|
||||
}
|
||||
else if (jcookies != null)
|
||||
{
|
||||
CookieHeader = (string)jcookies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
if (jsonConfig is JArray)
|
||||
{
|
||||
configData.LoadValuesFromJson(jsonConfig, protectionService);
|
||||
IsConfigured = true;
|
||||
}
|
||||
// read and upgrade old settings file format
|
||||
else if (jsonConfig is Object)
|
||||
{
|
||||
LoadLegacyCookieConfig(jsonConfig);
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
public async virtual Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var response = await RequestBytesWithCookiesAndRetry(link.ToString());
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
protected async Task<WebClientByteResult> RequestBytesWithCookiesAndRetry(string url, string cookieOverride = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await RequestBytesWithCookies(url, cookieOverride);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} downloading from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestStringWithCookies(string url, string cookieOverride = null, string referer = null, Dictionary<string, string> headers = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.GET,
|
||||
Cookies = CookieHeader,
|
||||
Referer = referer,
|
||||
Headers = headers
|
||||
};
|
||||
|
||||
if (cookieOverride != null)
|
||||
request.Cookies = cookieOverride;
|
||||
return await webclient.GetString(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestStringWithCookiesAndRetry(string url, string cookieOverride = null, string referer = null, Dictionary<string,string> headers = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await RequestStringWithCookies(url, cookieOverride, referer, headers);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} checking for results from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientByteResult> RequestBytesWithCookies(string url, string cookieOverride = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.GET,
|
||||
Cookies = cookieOverride ?? CookieHeader
|
||||
};
|
||||
|
||||
if (cookieOverride != null)
|
||||
request.Cookies = cookieOverride;
|
||||
return await webclient.GetBytes(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> PostDataWithCookies(string url, IEnumerable<KeyValuePair<string, string>> data, string cookieOverride = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.POST,
|
||||
Cookies = cookieOverride ?? CookieHeader,
|
||||
PostData = data
|
||||
};
|
||||
return await webclient.GetString(request);
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> PostDataWithCookiesAndRetry(string url, IEnumerable<KeyValuePair<string, string>> data, string cookieOverride = null)
|
||||
{
|
||||
Exception lastException = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await PostDataWithCookies(url, data, cookieOverride);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(string.Format("On attempt {0} checking for results from {1}: {2}", (i + 1), DisplayName, e.Message));
|
||||
lastException = e;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
protected async Task<WebClientStringResult> RequestLoginAndFollowRedirect(string url, IEnumerable<KeyValuePair<string, string>> data, string cookies, bool returnCookiesFromFirstCall, string redirectUrlOverride = null, string referer = null)
|
||||
{
|
||||
var request = new Utils.Clients.WebRequest()
|
||||
{
|
||||
Url = url,
|
||||
Type = RequestType.POST,
|
||||
Cookies = cookies,
|
||||
Referer = referer,
|
||||
PostData = data
|
||||
};
|
||||
var response = await webclient.GetString(request);
|
||||
var firstCallCookies = response.Cookies;
|
||||
|
||||
if (response.IsRedirect)
|
||||
{
|
||||
await FollowIfRedirect(response, request.Url, null, response.Cookies);
|
||||
}
|
||||
|
||||
if (returnCookiesFromFirstCall)
|
||||
{
|
||||
response.Cookies = firstCallCookies;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
protected async Task ConfigureIfOK(string cookies, bool isLoggedin, Func<Task> onError)
|
||||
{
|
||||
if (isLoggedin)
|
||||
{
|
||||
CookieHeader = cookies;
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
await onError();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> results)
|
||||
{
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (query.Categories.Length == 0 || query.Categories.Contains(result.Category) || result.Category == 0 || TorznabCatType.QueryContainsParentCategory(query.Categories, result.Category))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(string trackerCategory, int newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory, newznabCategory));
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(int trackerCategory, int newznabCategory)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory));
|
||||
}
|
||||
|
||||
protected void AddMultiCategoryMapping(TorznabCategory newznabCategory, params int[] trackerCategories)
|
||||
{
|
||||
foreach (var trackerCat in trackerCategories)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCat.ToString(), newznabCategory.ID));
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddMultiCategoryMapping(int trackerCategory, params TorznabCategory[] newznabCategories)
|
||||
{
|
||||
foreach (var newznabCat in newznabCategories)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCat.ID));
|
||||
}
|
||||
}
|
||||
|
||||
protected List<string> MapTorznabCapsToTrackers(TorznabQuery query, bool mapChildrenCatsToParent = false)
|
||||
{
|
||||
var result = new List<string>();
|
||||
foreach (var cat in query.Categories)
|
||||
{
|
||||
var queryCats = new List<int> { cat };
|
||||
var newznabCat = TorznabCatType.AllCats.FirstOrDefault(c => c.ID == cat);
|
||||
if (newznabCat != null)
|
||||
{
|
||||
queryCats.AddRange(newznabCat.SubCategories.Select(c => c.ID));
|
||||
}
|
||||
|
||||
if (mapChildrenCatsToParent)
|
||||
{
|
||||
var parentNewznabCat = TorznabCatType.AllCats.FirstOrDefault(c => c.SubCategories.Contains(newznabCat));
|
||||
if (parentNewznabCat != null)
|
||||
{
|
||||
queryCats.Add(parentNewznabCat.ID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mapping in categoryMapping.Where(c => queryCats.Contains(c.NewzNabCategory)))
|
||||
{
|
||||
result.Add(mapping.TrackerCategory);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
213
src/Jackett/Indexers/NxtGn.cs
Normal file
213
src/Jackett/Indexers/NxtGn.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using CsQuery;
|
||||
using Jackett.Indexers;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class NxtGn : BaseIndexer, IIndexer
|
||||
{
|
||||
private string LoginUrl { get { return SiteLink + "login.php"; } }
|
||||
private string SearchUrl { get { return SiteLink + "browse.php"; } }
|
||||
private string ProfileUrl { get { return SiteLink + "my.php"; } }
|
||||
|
||||
new ConfigurationDataBasicLoginWithRSS configData
|
||||
{
|
||||
get { return (ConfigurationDataBasicLoginWithRSS)base.configData; }
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
public NxtGn(IIndexerManagerService i, Logger l, IWebClient c, IProtectionService ps)
|
||||
: base(name: "NextGen",
|
||||
description: "A danish closed torrent tracker",
|
||||
link: "https://nxtgn.org/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
manager: i,
|
||||
client: c,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataBasicLoginWithRSS())
|
||||
{
|
||||
AddCategoryMapping(47, TorznabCatType.Movies3D);
|
||||
AddCategoryMapping(38, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(38, TorznabCatType.MoviesWEBDL);
|
||||
AddCategoryMapping(38, TorznabCatType.MoviesBluRay);
|
||||
AddCategoryMapping(5, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(23, TorznabCatType.MoviesForeign);
|
||||
AddCategoryMapping(22, TorznabCatType.MoviesSD);
|
||||
//AddCategoryMapping(4, TorznabCatType.TVFOREIGN);
|
||||
//AddCategoryMapping(4, TorznabCatType.TVSD);
|
||||
//AddCategoryMapping(4, TorznabCatType.TVDocumentary);
|
||||
//AddCategoryMapping(4, TorznabCatType.TVSport);
|
||||
//AddCategoryMapping(4, TorznabCatType.TV);
|
||||
//AddCategoryMapping(31, TorznabCatType.TVHD);
|
||||
//AddCategoryMapping(21, TorznabCatType.TVFOREIGN);
|
||||
AddCategoryMapping(46, TorznabCatType.TV);
|
||||
AddCategoryMapping(46, TorznabCatType.TVHD);
|
||||
//AddCategoryMapping(45, TorznabCatType.TV);
|
||||
//AddCategoryMapping(45, TorznabCatType.TVSD);
|
||||
//AddCategoryMapping(24, TorznabCatType.TVFOREIGN);
|
||||
AddCategoryMapping(26, TorznabCatType.TV);
|
||||
AddCategoryMapping(26, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(26, TorznabCatType.TVWEBDL);
|
||||
AddCategoryMapping(33, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(33, TorznabCatType.Movies);
|
||||
AddCategoryMapping(17, TorznabCatType.MoviesForeign);
|
||||
AddCategoryMapping(17, TorznabCatType.MoviesDVD);
|
||||
AddCategoryMapping(9, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(9, TorznabCatType.Movies);
|
||||
AddCategoryMapping(9, TorznabCatType.MoviesBluRay);
|
||||
AddCategoryMapping(43, TorznabCatType.TV);
|
||||
AddCategoryMapping(43, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(43, TorznabCatType.TVWEBDL);
|
||||
}
|
||||
|
||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var loginPage = await RequestStringWithCookies(LoginUrl);
|
||||
CQ loginDom = loginPage.Content;
|
||||
var loginPostUrl = loginDom["#login"].Attr("action");
|
||||
|
||||
configData.LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value }
|
||||
};
|
||||
// Get inital cookies
|
||||
CookieHeader = string.Empty;
|
||||
var response = await RequestLoginAndFollowRedirect(SiteLink + loginPostUrl, pairs, CookieHeader, true, null, LoginUrl);
|
||||
|
||||
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("Velkommen tilbage"), () =>
|
||||
{
|
||||
CQ dom = response.Content;
|
||||
var messageEl = dom["inputs"];
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
|
||||
var profilePage = await RequestStringWithCookies(ProfileUrl, response.Cookies);
|
||||
CQ profileDom = profilePage.Content;
|
||||
var passKey = profileDom["input[name=resetkey]"].Parent().Text();
|
||||
passKey = passKey.Substring(0, passKey.IndexOf(' '));
|
||||
configData.RSSKey.Value = passKey;
|
||||
SaveConfig();
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var breakWhile = false;
|
||||
var page = 0;
|
||||
while (page < 3)
|
||||
{
|
||||
string episodeSearchUrl;
|
||||
if (string.IsNullOrEmpty(query.GetQueryString()))
|
||||
{
|
||||
episodeSearchUrl = SearchUrl + "?page=" + page;
|
||||
breakWhile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var cats = MapTorznabCapsToTrackers(query);
|
||||
var catsUrlPart = string.Join("&", cats.Select(c => $"c{c}=1"));
|
||||
episodeSearchUrl = string.Format("{0}?search={1}&cat=0&incldead=0&{2}&page={3}", SearchUrl, HttpUtility.UrlEncode(query.GetQueryString()), catsUrlPart, page);
|
||||
}
|
||||
page++;
|
||||
var results = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
|
||||
try
|
||||
{
|
||||
CQ dom = results.Content;
|
||||
|
||||
var rows = dom["#torrent-table-wrapper > div"];
|
||||
|
||||
foreach (var row in rows.Skip(1))
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
var qRow = row.Cq();
|
||||
var qLink = qRow.Find("#torrent-udgivelse2-users > a").First();
|
||||
var qDesc = qRow.Find("#torrent-udgivelse2-users > p").FirstOrDefault();
|
||||
|
||||
var moviesCats = new[] { 47, 38, 5, 23, 22, 33, 17, 9 };
|
||||
var seriesCats = new[] { 46, 26, 43 };
|
||||
var catUrl = qRow.Find(".torrent-icon > a").Attr("href");
|
||||
var cat = catUrl.Substring(catUrl.LastIndexOf('=') + 1);
|
||||
var catNo = int.Parse(cat);
|
||||
if (moviesCats.Contains(catNo))
|
||||
release.Category = TorznabCatType.Movies.ID;
|
||||
else if (seriesCats.Contains(catNo))
|
||||
release.Category = TorznabCatType.TV.ID;
|
||||
else
|
||||
continue;
|
||||
|
||||
releases.Add(release);
|
||||
|
||||
var torrentUrl = qLink.Attr("href");
|
||||
var torrentId = torrentUrl.Substring(torrentUrl.LastIndexOf('=') + 1);
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qLink.Attr("title");
|
||||
release.Description = qDesc != null ? qDesc.InnerText : release.Title;
|
||||
release.Guid = new Uri(SiteLink + torrentUrl);
|
||||
release.Comments = new Uri(release.Guid + "#startcomments");
|
||||
|
||||
var downloadUrl = $"{SiteLink}download.php?id={torrentId}&rss&passkey={configData.RSSKey.Value}";
|
||||
release.Link = new Uri(downloadUrl);
|
||||
|
||||
var qAdded = qRow.Find("#torrent-added").First();
|
||||
var addedStr = qAdded.Text().Trim();
|
||||
release.PublishDate = DateTime.ParseExact(addedStr, "dd-MM-yyyyHH:mm:ss", CultureInfo.InvariantCulture);
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find("#torrent-seeders").Text().Trim());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find("#torrent-leechers").Text().Trim()) + release.Seeders;
|
||||
|
||||
var sizeStr = qRow.Find("#torrent-size").First().Text();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
||||
|
||||
var infoLink = qRow.Find("#infolink");
|
||||
var linkContainer = infoLink.Children().First().Children().First();
|
||||
var url = linkContainer.Attr("href");
|
||||
var img = linkContainer.Children().First();
|
||||
var imgUrl = img.Attr("src");
|
||||
if (imgUrl == "/pic/imdb.png")
|
||||
{
|
||||
release.Imdb = long.Parse(url.Substring(url.LastIndexOf('t') + 1));
|
||||
}
|
||||
else if (imgUrl == "/pic/TV.png")
|
||||
{
|
||||
release.TheTvDbId = long.Parse(url.Substring(url.LastIndexOf('=') + 1));
|
||||
}
|
||||
}
|
||||
var nextPage = dom["#torrent-table-wrapper + p[align=center]"].Children().Last();
|
||||
if (!nextPage.Is("a"))
|
||||
breakWhile = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results.Content, ex);
|
||||
}
|
||||
if (breakWhile)
|
||||
break;
|
||||
}
|
||||
return releases;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,212 +1,213 @@
|
||||
using CsQuery;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentDay : BaseIndexer, IIndexer
|
||||
{
|
||||
private string StartPageUrl { get { return SiteLink + "login.php"; } }
|
||||
private string LoginUrl { get { return SiteLink + "tak3login.php"; } }
|
||||
private string SearchUrl { get { return SiteLink + "browse.php"; } }
|
||||
|
||||
new ConfigurationDataRecaptchaLogin configData
|
||||
{
|
||||
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
public TorrentDay(IIndexerManagerService i, Logger l, IWebClient wc, IProtectionService ps)
|
||||
: base(name: "TorrentDay",
|
||||
description: "TorrentDay",
|
||||
link: "https://torrentday.eu/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
manager: i,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataRecaptchaLogin())
|
||||
{
|
||||
|
||||
AddCategoryMapping(29, TorznabCatType.TVAnime);
|
||||
AddCategoryMapping(28, TorznabCatType.PC);
|
||||
AddCategoryMapping(28, TorznabCatType.AudioAudiobook);
|
||||
AddCategoryMapping(20, TorznabCatType.Books);
|
||||
AddCategoryMapping(30, TorznabCatType.TVDocumentary);
|
||||
//Freelech
|
||||
//Mac
|
||||
|
||||
AddCategoryMapping(25, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(11, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(5, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(3, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(21, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(22, TorznabCatType.MoviesForeign);
|
||||
// Movie packs
|
||||
AddCategoryMapping(44, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(1, TorznabCatType.MoviesSD);
|
||||
|
||||
// Music foreign
|
||||
// Music packs
|
||||
// Music videos
|
||||
|
||||
AddCategoryMapping(4, TorznabCatType.PCGames);
|
||||
// ps3
|
||||
// psp
|
||||
// wii
|
||||
// 360
|
||||
|
||||
AddCategoryMapping(24, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(32, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(31, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(33, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(14, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(26, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(7, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(2, TorznabCatType.TVSD);
|
||||
|
||||
AddCategoryMapping(6, TorznabCatType.XXX);
|
||||
AddCategoryMapping(15, TorznabCatType.XXX);
|
||||
}
|
||||
|
||||
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var loginPage = await RequestStringWithCookies(StartPageUrl, string.Empty);
|
||||
CQ cq = loginPage.Content;
|
||||
var result = new ConfigurationDataRecaptchaLogin();
|
||||
result.CookieHeader.Value = loginPage.Cookies;
|
||||
result.Captcha.SiteKey = cq.Find(".g-recaptcha").Attr("data-sitekey");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
configData.LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value },
|
||||
{ "g-recaptcha-response", configData.Captcha.Value }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
||||
{
|
||||
// Cookie was manually supplied
|
||||
CookieHeader = configData.Captcha.Cookie;
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (results.Count() == 0)
|
||||
{
|
||||
throw new Exception("Your cookie did not work");
|
||||
}
|
||||
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw new Exception("Your cookie did not work: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, configData.CookieHeader.Value, true, SiteLink, LoginUrl);
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
CQ dom = result.Content;
|
||||
var messageEl = dom["#login"];
|
||||
messageEl.Children("form").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(errorMessage))
|
||||
{
|
||||
errorMessage = dom.Text();
|
||||
}
|
||||
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
var queryUrl = SearchUrl;
|
||||
var queryCollection = new NameValueCollection();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchString))
|
||||
queryCollection.Add("search", searchString);
|
||||
|
||||
foreach (var cat in MapTorznabCapsToTrackers(query))
|
||||
queryCollection.Add("c" + cat, "1");
|
||||
|
||||
if (queryCollection.Count > 0)
|
||||
queryUrl += "?" + queryCollection.GetQueryString();
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(queryUrl);
|
||||
|
||||
// Check for being logged out
|
||||
if (results.IsRedirect)
|
||||
throw new AuthenticationException();
|
||||
|
||||
try
|
||||
{
|
||||
CQ dom = results.Content;
|
||||
var rows = dom["#torrentTable > tbody > tr.browse"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ qRow = row.Cq();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qRow.Find(".torrentName").Text();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(SiteLink + qRow.Find(".torrentName").Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(SiteLink + qRow.Find(".dlLinksInfo > a").Attr("href"));
|
||||
|
||||
var sizeStr = qRow.Find(".sizeInfo").Text();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
||||
|
||||
var dateStr = qRow.Find(".ulInfo").Text().Split('|').Last().Trim();
|
||||
var agoIdx = dateStr.IndexOf("ago");
|
||||
if (agoIdx > -1)
|
||||
{
|
||||
dateStr = dateStr.Substring(0, agoIdx);
|
||||
}
|
||||
release.PublishDate = DateTimeUtil.FromTimeAgo(dateStr);
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".seedersInfo").Text());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find(".leechersInfo").Text()) + release.Seeders;
|
||||
|
||||
var cat = qRow.Find("td:eq(0) a").First().Attr("href").Substring(15);//browse.php?cat=24
|
||||
release.Category = MapTrackerCatToNewznab(cat);
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results.Content, ex);
|
||||
}
|
||||
return releases;
|
||||
}
|
||||
}
|
||||
}
|
||||
using CsQuery;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
public class TorrentDay : BaseIndexer, IIndexer
|
||||
{
|
||||
private string StartPageUrl { get { return SiteLink + "login.php"; } }
|
||||
private string LoginUrl { get { return SiteLink + "tak3login.php"; } }
|
||||
private string SearchUrl { get { return SiteLink + "browse.php"; } }
|
||||
|
||||
new ConfigurationDataRecaptchaLogin configData
|
||||
{
|
||||
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
public TorrentDay(IIndexerManagerService i, Logger l, IWebClient wc, IProtectionService ps)
|
||||
: base(name: "TorrentDay",
|
||||
description: "TorrentDay",
|
||||
link: "https://torrentday.eu/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
manager: i,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataRecaptchaLogin())
|
||||
{
|
||||
|
||||
AddCategoryMapping(29, TorznabCatType.TVAnime);
|
||||
AddCategoryMapping(28, TorznabCatType.PC);
|
||||
AddCategoryMapping(28, TorznabCatType.AudioAudiobook);
|
||||
AddCategoryMapping(20, TorznabCatType.Books);
|
||||
AddCategoryMapping(30, TorznabCatType.TVDocumentary);
|
||||
//Freelech
|
||||
//Mac
|
||||
|
||||
AddCategoryMapping(25, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(11, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(5, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(3, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(21, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(22, TorznabCatType.MoviesForeign);
|
||||
// Movie packs
|
||||
AddCategoryMapping(44, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(1, TorznabCatType.MoviesSD);
|
||||
|
||||
// Music foreign
|
||||
// Music packs
|
||||
// Music videos
|
||||
|
||||
AddCategoryMapping(4, TorznabCatType.PCGames);
|
||||
// ps3
|
||||
// psp
|
||||
// wii
|
||||
// 360
|
||||
|
||||
AddCategoryMapping(24, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(32, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(31, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(33, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(14, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(26, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(7, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(2, TorznabCatType.TVSD);
|
||||
|
||||
AddCategoryMapping(6, TorznabCatType.XXX);
|
||||
AddCategoryMapping(15, TorznabCatType.XXX);
|
||||
}
|
||||
|
||||
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
||||
{
|
||||
var loginPage = await RequestStringWithCookies(StartPageUrl, string.Empty);
|
||||
CQ cq = loginPage.Content;
|
||||
var result = new ConfigurationDataRecaptchaLogin();
|
||||
result.CookieHeader.Value = loginPage.Cookies;
|
||||
result.Captcha.SiteKey = cq.Find(".g-recaptcha").Attr("data-sitekey");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
configData.LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value },
|
||||
{ "g-recaptcha-response", configData.Captcha.Value }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
||||
{
|
||||
// Cookie was manually supplied
|
||||
CookieHeader = configData.Captcha.Cookie;
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (results.Count() == 0)
|
||||
{
|
||||
throw new Exception("Your cookie did not work");
|
||||
}
|
||||
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
return IndexerConfigurationStatus.Completed;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw new Exception("Your cookie did not work: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, configData.CookieHeader.Value, true, SiteLink, LoginUrl);
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
CQ dom = result.Content;
|
||||
var messageEl = dom["#login"];
|
||||
messageEl.Children("form").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(errorMessage))
|
||||
{
|
||||
errorMessage = dom.Text();
|
||||
}
|
||||
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
var queryUrl = SearchUrl;
|
||||
var queryCollection = new NameValueCollection();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchString))
|
||||
queryCollection.Add("search", searchString);
|
||||
|
||||
foreach (var cat in MapTorznabCapsToTrackers(query))
|
||||
queryCollection.Add("c" + cat, "1");
|
||||
|
||||
if (queryCollection.Count > 0)
|
||||
queryUrl += "?" + queryCollection.GetQueryString();
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(queryUrl);
|
||||
|
||||
// Check for being logged out
|
||||
if (results.IsRedirect)
|
||||
throw new AuthenticationException();
|
||||
|
||||
try
|
||||
{
|
||||
CQ dom = results.Content;
|
||||
var rows = dom["#torrentTable > tbody > tr.browse"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ qRow = row.Cq();
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.Title = qRow.Find(".torrentName").Text();
|
||||
release.Description = release.Title;
|
||||
release.Guid = new Uri(SiteLink + qRow.Find(".torrentName").Attr("href"));
|
||||
release.Comments = release.Guid;
|
||||
release.Link = new Uri(SiteLink + qRow.Find(".dlLinksInfo > a").Attr("href"));
|
||||
|
||||
var sizeStr = qRow.Find(".sizeInfo").Text();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
||||
|
||||
var dateStr = qRow.Find(".ulInfo").Text().Split('|').Last().Trim();
|
||||
var agoIdx = dateStr.IndexOf("ago");
|
||||
if (agoIdx > -1)
|
||||
{
|
||||
dateStr = dateStr.Substring(0, agoIdx);
|
||||
}
|
||||
release.PublishDate = DateTimeUtil.FromTimeAgo(dateStr);
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".seedersInfo").Text());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find(".leechersInfo").Text()) + release.Seeders;
|
||||
|
||||
var cat = qRow.Find("td:eq(0) a").First().Attr("href").Substring(15);//browse.php?cat=24
|
||||
release.Category = MapTrackerCatToNewznab(cat);
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results.Content, ex);
|
||||
}
|
||||
return releases;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,81 +1,82 @@
|
||||
using Autofac;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Autofac.Integration.WebApi;
|
||||
using Jackett.Indexers;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public class JackettModule : Module
|
||||
{
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
// Just register everything!
|
||||
var thisAssembly = typeof(JackettModule).Assembly;
|
||||
builder.RegisterAssemblyTypes(thisAssembly).Except<IIndexer>().AsImplementedInterfaces().SingleInstance();
|
||||
builder.RegisterApiControllers(thisAssembly).InstancePerRequest();
|
||||
|
||||
// Register the best web client for the platform or the override
|
||||
switch (Startup.ClientOverride)
|
||||
{
|
||||
case "httpclient":
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "safecurl":
|
||||
builder.RegisterType<UnixSafeCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "libcurl":
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "automatic":
|
||||
default:
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Register indexers
|
||||
foreach (var indexer in thisAssembly.GetTypes()
|
||||
.Where(p => typeof(IIndexer).IsAssignableFrom(p) && !p.IsInterface)
|
||||
.ToArray())
|
||||
{
|
||||
builder.RegisterType(indexer).Named<IIndexer>(BaseIndexer.GetIndexerID(indexer));
|
||||
}
|
||||
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientStringResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) =>
|
||||
{
|
||||
str.Content = Encoding.UTF8.GetString(be.Content);
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientByteResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((str, be) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str.Content))
|
||||
{
|
||||
be.Content = Encoding.UTF8.GetBytes(str.Content);
|
||||
}
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientStringResult>();
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientByteResult>();
|
||||
Mapper.CreateMap<ReleaseInfo, ReleaseInfo>();
|
||||
|
||||
Mapper.CreateMap<ReleaseInfo, TrackerCacheResult>().AfterMap((r, t) =>
|
||||
{
|
||||
t.CategoryDesc = TorznabCatType.GetCatDesc(r.Category);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
using Autofac;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Autofac.Integration.WebApi;
|
||||
using Jackett.Indexers;
|
||||
using Jackett.Utils;
|
||||
using Jackett.Utils.Clients;
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
public class JackettModule : Module
|
||||
{
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
// Just register everything!
|
||||
var thisAssembly = typeof(JackettModule).Assembly;
|
||||
builder.RegisterAssemblyTypes(thisAssembly).Except<IIndexer>().AsImplementedInterfaces().SingleInstance();
|
||||
builder.RegisterApiControllers(thisAssembly).InstancePerRequest();
|
||||
builder.RegisterType<HttpWebClient>();
|
||||
|
||||
// Register the best web client for the platform or the override
|
||||
switch (Startup.ClientOverride)
|
||||
{
|
||||
case "httpclient":
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "safecurl":
|
||||
builder.RegisterType<UnixSafeCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "libcurl":
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "automatic":
|
||||
default:
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Register indexers
|
||||
foreach (var indexer in thisAssembly.GetTypes()
|
||||
.Where(p => typeof(IIndexer).IsAssignableFrom(p) && !p.IsInterface)
|
||||
.ToArray())
|
||||
{
|
||||
builder.RegisterType(indexer).Named<IIndexer>(BaseIndexer.GetIndexerID(indexer));
|
||||
}
|
||||
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientStringResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) =>
|
||||
{
|
||||
str.Content = Encoding.UTF8.GetString(be.Content);
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientByteResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((str, be) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str.Content))
|
||||
{
|
||||
be.Content = Encoding.UTF8.GetBytes(str.Content);
|
||||
}
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientStringResult>();
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientByteResult>();
|
||||
Mapper.CreateMap<ReleaseInfo, ReleaseInfo>();
|
||||
|
||||
Mapper.CreateMap<ReleaseInfo, TrackerCacheResult>().AfterMap((r, t) =>
|
||||
{
|
||||
t.CategoryDesc = TorznabCatType.GetCatDesc(r.Category);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ namespace Jackett.Models
|
||||
public long? Size { get; set; }
|
||||
public string Description { get; set; }
|
||||
public long? RageID { get; set; }
|
||||
public long? TheTvDbId { get; set; }
|
||||
public long? Imdb { get; set; }
|
||||
public int? Seeders { get; set; }
|
||||
public int? Peers { get; set; }
|
||||
|
@@ -81,6 +81,8 @@ namespace Jackett.Models
|
||||
),
|
||||
getTorznabElement("magneturl", r.MagnetUri),
|
||||
getTorznabElement("rageid", r.RageID),
|
||||
getTorznabElement("thetvdb", r.TheTvDbId),
|
||||
getTorznabElement("imdb", r.Imdb),
|
||||
getTorznabElement("seeders", r.Seeders),
|
||||
getTorznabElement("peers", r.Peers),
|
||||
getTorznabElement("infohash", r.InfoHash),
|
||||
|
@@ -12,7 +12,7 @@ namespace Jackett.Models
|
||||
public string torrent_id { get; set; }
|
||||
public string details_url { get; set; }
|
||||
public string download_url { get; set; }
|
||||
// public string imdb_id { get; set; }
|
||||
public string imdb_id { get; set; }
|
||||
public bool freeleech { get; set; }
|
||||
public string type { get; set; }
|
||||
public long size { get; set; }
|
||||
|
@@ -1,36 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Jackett")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Jackett")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5881fb69-3cb2-42b7-a744-2c1e537176bd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.6.3.0")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Jackett")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Jackett")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5881fb69-3cb2-42b7-a744-2c1e537176bd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.6.4.0")]
|
||||
[assembly: AssemblyFileVersion("0.6.4.0")]
|
||||
|
@@ -1,110 +1,118 @@
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils.Clients
|
||||
{
|
||||
class HttpWebClient : IWebClient
|
||||
{
|
||||
private Logger logger;
|
||||
|
||||
public HttpWebClient(Logger l)
|
||||
{
|
||||
logger = l;
|
||||
}
|
||||
|
||||
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<WebClientByteResult> GetBytes(WebRequest request)
|
||||
{
|
||||
logger.Debug(string.Format("WindowsWebClient:GetBytes(Url:{0})", request.Url));
|
||||
var result = await Run(request);
|
||||
logger.Debug(string.Format("WindowsWebClient: Returning {0} => {1} bytes", result.Status, (result.Content == null ? "<NULL>" : result.Content.Length.ToString())));
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<WebClientStringResult> GetString(WebRequest request)
|
||||
{
|
||||
logger.Debug(string.Format("WindowsWebClient:GetString(Url:{0})", request.Url));
|
||||
var result = await Run(request);
|
||||
logger.Debug(string.Format("WindowsWebClient: Returning {0} => {1}", result.Status, (result.Content == null ? "<NULL>" : Encoding.UTF8.GetString(result.Content))));
|
||||
return Mapper.Map<WebClientStringResult>(result);
|
||||
}
|
||||
|
||||
private async Task<WebClientByteResult> Run(WebRequest request)
|
||||
{
|
||||
var cookies = new CookieContainer();
|
||||
if (!string.IsNullOrEmpty(request.Cookies))
|
||||
{
|
||||
var uri = new Uri(request.Url);
|
||||
foreach (var c in request.Cookies.Split(';'))
|
||||
{
|
||||
try
|
||||
{
|
||||
cookies.SetCookies(uri, c);
|
||||
}
|
||||
catch (CookieException ex)
|
||||
{
|
||||
logger.Info("(Non-critical) Problem loading cookie {0}, {1}, {2}", uri, c, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var client = new HttpClient(new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = false, // Do not use this - Bugs ahoy! Lost cookies and more.
|
||||
UseCookies = true,
|
||||
});
|
||||
|
||||
client.DefaultRequestHeaders.Add("User-Agent", BrowserUtil.ChromeUserAgent);
|
||||
HttpResponseMessage response = null;
|
||||
|
||||
if (request.Type == RequestType.POST)
|
||||
{
|
||||
var content = new FormUrlEncodedContent(request.PostData);
|
||||
response = await client.PostAsync(request.Url, content);
|
||||
}
|
||||
else
|
||||
{
|
||||
response = await client.GetAsync(request.Url);
|
||||
}
|
||||
|
||||
var result = new WebClientByteResult();
|
||||
result.Content = await response.Content.ReadAsByteArrayAsync();
|
||||
if (response.Headers.Location != null)
|
||||
{
|
||||
result.RedirectingTo = response.Headers.Location.ToString();
|
||||
}
|
||||
result.Status = response.StatusCode;
|
||||
|
||||
// Compatiblity issue between the cookie format and httpclient
|
||||
// Pull it out manually ignoring the expiry date then set it manually
|
||||
// http://stackoverflow.com/questions/14681144/httpclient-not-storing-cookies-in-cookiecontainer
|
||||
IEnumerable<string> cookieHeaders;
|
||||
if (response.Headers.TryGetValues("set-cookie", out cookieHeaders))
|
||||
{
|
||||
var cookieBuilder = new StringBuilder();
|
||||
foreach (var c in cookieHeaders)
|
||||
{
|
||||
cookieBuilder.AppendFormat("{0} ", c.Substring(0, c.IndexOf(';') + 1));
|
||||
}
|
||||
|
||||
result.Cookies = cookieBuilder.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
ServerUtil.ResureRedirectIsFullyQualified(request, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
using AutoMapper;
|
||||
using Jackett.Models;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils.Clients
|
||||
{
|
||||
public class HttpWebClient : IWebClient
|
||||
{
|
||||
private Logger logger;
|
||||
|
||||
public HttpWebClient(Logger l)
|
||||
{
|
||||
logger = l;
|
||||
}
|
||||
|
||||
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<WebClientByteResult> GetBytes(WebRequest request)
|
||||
{
|
||||
logger.Debug(string.Format("WindowsWebClient:GetBytes(Url:{0})", request.Url));
|
||||
var result = await Run(request);
|
||||
logger.Debug(string.Format("WindowsWebClient: Returning {0} => {1} bytes", result.Status, (result.Content == null ? "<NULL>" : result.Content.Length.ToString())));
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<WebClientStringResult> GetString(WebRequest request)
|
||||
{
|
||||
logger.Debug(string.Format("WindowsWebClient:GetString(Url:{0})", request.Url));
|
||||
var result = await Run(request);
|
||||
logger.Debug(string.Format("WindowsWebClient: Returning {0} => {1}", result.Status, (result.Content == null ? "<NULL>" : Encoding.UTF8.GetString(result.Content))));
|
||||
return Mapper.Map<WebClientStringResult>(result);
|
||||
}
|
||||
|
||||
private async Task<WebClientByteResult> Run(WebRequest request)
|
||||
{
|
||||
var cookies = new CookieContainer();
|
||||
if (!string.IsNullOrEmpty(request.Cookies))
|
||||
{
|
||||
var uri = new Uri(request.Url);
|
||||
foreach (var c in request.Cookies.Split(';'))
|
||||
{
|
||||
try
|
||||
{
|
||||
cookies.SetCookies(uri, c);
|
||||
}
|
||||
catch (CookieException ex)
|
||||
{
|
||||
logger.Info("(Non-critical) Problem loading cookie {0}, {1}, {2}", uri, c, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var client = new HttpClient(new HttpClientHandler
|
||||
{
|
||||
CookieContainer = cookies,
|
||||
AllowAutoRedirect = false, // Do not use this - Bugs ahoy! Lost cookies and more.
|
||||
UseCookies = true,
|
||||
});
|
||||
|
||||
client.DefaultRequestHeaders.Add("User-Agent", BrowserUtil.ChromeUserAgent);
|
||||
HttpResponseMessage response = null;
|
||||
|
||||
if (request.Headers != null)
|
||||
{
|
||||
foreach (var header in request.Headers)
|
||||
{
|
||||
client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (request.Type == RequestType.POST)
|
||||
{
|
||||
var content = new FormUrlEncodedContent(request.PostData);
|
||||
response = await client.PostAsync(request.Url, content);
|
||||
}
|
||||
else
|
||||
{
|
||||
response = await client.GetAsync(request.Url);
|
||||
}
|
||||
|
||||
var result = new WebClientByteResult();
|
||||
result.Content = await response.Content.ReadAsByteArrayAsync();
|
||||
if (response.Headers.Location != null)
|
||||
{
|
||||
result.RedirectingTo = response.Headers.Location.ToString();
|
||||
}
|
||||
result.Status = response.StatusCode;
|
||||
|
||||
// Compatiblity issue between the cookie format and httpclient
|
||||
// Pull it out manually ignoring the expiry date then set it manually
|
||||
// http://stackoverflow.com/questions/14681144/httpclient-not-storing-cookies-in-cookiecontainer
|
||||
IEnumerable<string> cookieHeaders;
|
||||
if (response.Headers.TryGetValues("set-cookie", out cookieHeaders))
|
||||
{
|
||||
var cookieBuilder = new StringBuilder();
|
||||
foreach (var c in cookieHeaders)
|
||||
{
|
||||
cookieBuilder.AppendFormat("{0} ", c.Substring(0, c.IndexOf(';') + 1));
|
||||
}
|
||||
|
||||
result.Cookies = cookieBuilder.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
ServerUtil.ResureRedirectIsFullyQualified(request, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,89 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils.Clients
|
||||
{
|
||||
public class WebRequest
|
||||
{
|
||||
public WebRequest()
|
||||
{
|
||||
PostData = new List<KeyValuePair<string, string>>();
|
||||
Type = RequestType.GET;
|
||||
}
|
||||
|
||||
public WebRequest(string url)
|
||||
{
|
||||
PostData = new List<KeyValuePair<string, string>>();
|
||||
Type = RequestType.GET;
|
||||
Url = url;
|
||||
}
|
||||
|
||||
public string Url { get; set; }
|
||||
public IEnumerable<KeyValuePair<string, string>> PostData { get; set; }
|
||||
public string Cookies { get; set; }
|
||||
public string Referer { get; set; }
|
||||
public RequestType Type { get; set; }
|
||||
|
||||
|
||||
public override bool Equals(System.Object obj)
|
||||
{
|
||||
if (obj is WebRequest)
|
||||
{
|
||||
var other = obj as WebRequest;
|
||||
var postDataSame = PostData == null && other.PostData == null;
|
||||
if (!postDataSame)
|
||||
{
|
||||
if (!(PostData == null || other.PostData == null))
|
||||
{
|
||||
var ok = PostData.Count() == other.PostData.Count();
|
||||
foreach (var i in PostData)
|
||||
{
|
||||
if (!other.PostData.Any(item => item.Key == i.Key))
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (PostData.FirstOrDefault(item => item.Key == i.Key).Value != other.PostData.FirstOrDefault(item => item.Key == i.Key).Value)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
postDataSame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return other.Url == Url &&
|
||||
other.Referer == Referer &&
|
||||
other.Cookies == Cookies &&
|
||||
other.Type == Type &&
|
||||
postDataSame;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public enum RequestType
|
||||
{
|
||||
GET,
|
||||
POST
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils.Clients
|
||||
{
|
||||
public class WebRequest
|
||||
{
|
||||
public WebRequest()
|
||||
{
|
||||
PostData = new List<KeyValuePair<string, string>>();
|
||||
Type = RequestType.GET;
|
||||
Headers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public WebRequest(string url)
|
||||
{
|
||||
PostData = new List<KeyValuePair<string, string>>();
|
||||
Type = RequestType.GET;
|
||||
Url = url;
|
||||
Headers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string Url { get; set; }
|
||||
public IEnumerable<KeyValuePair<string, string>> PostData { get; set; }
|
||||
public string Cookies { get; set; }
|
||||
public string Referer { get; set; }
|
||||
public RequestType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Warning this is only implemented on HTTPWebClient currently!
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Headers { get; set; }
|
||||
|
||||
public override bool Equals(System.Object obj)
|
||||
{
|
||||
if (obj is WebRequest)
|
||||
{
|
||||
var other = obj as WebRequest;
|
||||
var postDataSame = PostData == null && other.PostData == null;
|
||||
if (!postDataSame)
|
||||
{
|
||||
if (!(PostData == null || other.PostData == null))
|
||||
{
|
||||
var ok = PostData.Count() == other.PostData.Count();
|
||||
foreach (var i in PostData)
|
||||
{
|
||||
if (!other.PostData.Any(item => item.Key == i.Key))
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (PostData.FirstOrDefault(item => item.Key == i.Key).Value != other.PostData.FirstOrDefault(item => item.Key == i.Key).Value)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
postDataSame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return other.Url == Url &&
|
||||
other.Referer == Referer &&
|
||||
other.Cookies == Cookies &&
|
||||
other.Type == Type &&
|
||||
postDataSame;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public enum RequestType
|
||||
{
|
||||
GET,
|
||||
POST
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ namespace Jackett.Utils
|
||||
protected override async Task SerializeToStreamAsync(Stream stream,
|
||||
TransportContext context)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(_value, Formatting.Indented);
|
||||
var json = JsonConvert.SerializeObject(_value, Formatting.Indented, new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore});
|
||||
var writer = new StreamWriter(stream);
|
||||
writer.Write(json);
|
||||
await writer.FlushAsync();
|
||||
|
@@ -1,53 +1,86 @@
|
||||
using Jackett.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils
|
||||
{
|
||||
public class TorznabUtil
|
||||
{
|
||||
static Regex reduceSpacesRegex = new Regex("\\s{2,}", RegexOptions.Compiled);
|
||||
|
||||
public static TorznabCapabilities CreateDefaultTorznabTVCaps()
|
||||
{
|
||||
var caps = new TorznabCapabilities();
|
||||
caps.Categories.AddRange(new[] {
|
||||
TorznabCatType.TV,
|
||||
TorznabCatType.TVSD,
|
||||
TorznabCatType.TVHD
|
||||
});
|
||||
return caps;
|
||||
}
|
||||
|
||||
public static IEnumerable<ReleaseInfo> FilterResultsToTitle(IEnumerable<ReleaseInfo> results, string name, int year)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return results;
|
||||
|
||||
name = CleanTitle(name);
|
||||
var filteredResults = new List<ReleaseInfo>();
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (result.Title == null)
|
||||
continue;
|
||||
if (CleanTitle(result.Title).Contains(name) &&
|
||||
(year ==0 || result.Title.Contains(year.ToString())))
|
||||
{
|
||||
filteredResults.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredResults;
|
||||
}
|
||||
|
||||
private static string CleanTitle(string title)
|
||||
{
|
||||
title = title.Replace(':', ' ').Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Replace('+', ' ');
|
||||
return reduceSpacesRegex.Replace(title, " ").ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Jackett.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Utils
|
||||
{
|
||||
public class TorznabUtil
|
||||
{
|
||||
static Regex reduceSpacesRegex = new Regex("\\s{2,}", RegexOptions.Compiled);
|
||||
|
||||
static Regex findYearRegex = new Regex(@"(?<=\[|\(|\s)(\d{4})(?=\]|\)|\s)", RegexOptions.Compiled);
|
||||
|
||||
public static TorznabCapabilities CreateDefaultTorznabTVCaps()
|
||||
{
|
||||
var caps = new TorznabCapabilities();
|
||||
caps.Categories.AddRange(new[] {
|
||||
TorznabCatType.TV,
|
||||
TorznabCatType.TVSD,
|
||||
TorznabCatType.TVHD
|
||||
});
|
||||
return caps;
|
||||
}
|
||||
|
||||
private static int GetYearFromTitle(string title)
|
||||
{
|
||||
var match = findYearRegex.Match(title);
|
||||
if (match.Success)
|
||||
{
|
||||
var year = ParseUtil.CoerceInt(match.Value);
|
||||
if(year>1850 && year < 2100)
|
||||
{
|
||||
return year;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static IEnumerable<ReleaseInfo> FilterResultsToTitle(IEnumerable<ReleaseInfo> results, string name, int imdbYear)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return results;
|
||||
|
||||
name = CleanTitle(name);
|
||||
var filteredResults = new List<ReleaseInfo>();
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (result.Title == null)
|
||||
continue;
|
||||
|
||||
// Match on title
|
||||
if (CleanTitle(result.Title).Contains(name))
|
||||
{
|
||||
// Match on year
|
||||
var titleYear = GetYearFromTitle(result.Title);
|
||||
if (imdbYear == 0 || titleYear == 0 || titleYear == imdbYear)
|
||||
{
|
||||
filteredResults.Add(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filteredResults;
|
||||
}
|
||||
|
||||
public static IEnumerable<ReleaseInfo> FilterResultsToImdb(IEnumerable<ReleaseInfo> results, string imdb)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(imdb))
|
||||
return results;
|
||||
// Filter out releases that do have a valid imdb ID, that is not equal to the one we're searching for.
|
||||
return
|
||||
results.Where(
|
||||
result => !result.Imdb.HasValue || result.Imdb.Value == 0 || ("tt" + result.Imdb.Value).Equals(imdb));
|
||||
}
|
||||
|
||||
private static string CleanTitle(string title)
|
||||
{
|
||||
title = title.Replace(':', ' ').Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Replace('+', ' ').Replace("'", "");
|
||||
return reduceSpacesRegex.Replace(title, " ").ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,58 +1,58 @@
|
||||
@{
|
||||
ViewBag.Title = "Home Page";
|
||||
}
|
||||
|
||||
<h4>What is Jackett?</h4>
|
||||
<p>
|
||||
Jackett creates a <a href="https://github.com/Sonarr/Sonarr/wiki/Implementing-a-Torznab-indexer">Torznab</a> (with <a href="https://github.com/nZEDb/nZEDb/blob/master/docs/newznab_api_specification.txt">nZEDb</a> category numbering) and <a href="https://github.com/RuudBurger/CouchPotatoServer/wiki/Couchpotato-torrent-provider">TorrentPotato</a> API server on your machine. This enables supporting software to access your favorite torrent indexers in a similar fashion to rss but with added features such as searching. To see the list of the trackers we support see our <a href="https://github.com/zone117x/Jackett">Github page</a>.
|
||||
</p>
|
||||
|
||||
<div class="row center">
|
||||
<div class="col-xs-12">
|
||||
<a href="/Download">
|
||||
<div class="btn btn-primary"> <i class="fa fa-download"></i> Download</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<h4>We are on Github</h4>
|
||||
<div class="row center">
|
||||
<div class="col-xs-8 center">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
Follow development, report issues and contribute on our <a href="https://github.com/zone117x/Jackett">Github page</a>.
|
||||
</div>
|
||||
<br /><br />
|
||||
<div class="col-xs-12">
|
||||
<a href="https://github.com/zone117x/Jackett">
|
||||
<img alt="stars" src="https://img.shields.io/github/stars/zone117x/Jackett.svg?style=social" />
|
||||
<img alt="followers" src="https://img.shields.io/github/followers/zone117x.svg?style=social" />
|
||||
<img alt="forks" src="https://img.shields.io/github/forks/zone117x/Jackett.svg?style=social" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://github.com/zone117x/Jackett"><img alt="Github" src="~/Content/Web/Octocat.jpg" style="height:100px" /></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<h4>Applications with support for Jackett</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://sonarr.tv">
|
||||
<img alt="Sonarr" src="~/Content/Web/sonarr.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://couchpota.to/">
|
||||
<img alt="Couchpotato" src="~/Content/Web/couchpotato.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://github.com/evilhero/mylar">
|
||||
<img alt="Mylar" src="~/Content/Web/mylar.png" />
|
||||
</a>
|
||||
</div>
|
||||
@{
|
||||
ViewBag.Title = "Home Page";
|
||||
}
|
||||
|
||||
<h4>What is Jackett?</h4>
|
||||
<p>
|
||||
Jackett creates a <a href="https://github.com/Sonarr/Sonarr/wiki/Implementing-a-Torznab-indexer">Torznab</a> (with <a href="https://github.com/nZEDb/nZEDb/blob/master/docs/newznab_api_specification.txt">nZEDb</a> category numbering) and <a href="https://github.com/RuudBurger/CouchPotatoServer/wiki/Couchpotato-torrent-provider">TorrentPotato</a> API server on your machine. This enables supporting software to access your favorite torrent indexers in a similar fashion to rss but with added features such as searching. To see the list of the trackers we support see our <a href="https://github.com/zone117x/Jackett">Github page</a>.
|
||||
</p>
|
||||
|
||||
<div class="row center">
|
||||
<div class="col-xs-12">
|
||||
<a href="/Download">
|
||||
<div class="btn btn-primary"> <i class="fa fa-download"></i> Download</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<h4>We are on Github</h4>
|
||||
<div class="row center">
|
||||
<div class="col-xs-8 center">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
Follow development, report issues and contribute on our <a href="https://github.com/zone117x/Jackett">Github page</a>.
|
||||
</div>
|
||||
<br /><br />
|
||||
<!--<div class="col-xs-12">
|
||||
<a href="https://github.com/zone117x/Jackett">
|
||||
<img alt="stars" src="https://img.shields.io/github/stars/zone117x/Jackett.svg?style=social" />
|
||||
<img alt="followers" src="https://img.shields.io/github/followers/zone117x.svg?style=social" />
|
||||
<img alt="forks" src="https://img.shields.io/github/forks/zone117x/Jackett.svg?style=social" />
|
||||
</a>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://github.com/zone117x/Jackett"><img alt="Github" src="~/Content/Web/Octocat.jpg" style="height:100px" /></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<h4>Applications with support for Jackett</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://sonarr.tv">
|
||||
<img alt="Sonarr" src="~/Content/Web/sonarr.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://couchpota.to/">
|
||||
<img alt="Couchpotato" src="~/Content/Web/couchpotato.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-4 center">
|
||||
<a href="https://github.com/evilhero/mylar">
|
||||
<img alt="Mylar" src="~/Content/Web/mylar.png" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
@@ -1,48 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel='shortcut icon' type='image/x-icon' href='~/content/favicon.ico' />
|
||||
<script src="~/content/libs/jquery.min.js"></script>
|
||||
<script src="~/content/libs/jquery.dataTables.min.js"></script>
|
||||
<script src="~/content/libs/handlebars.min.js"></script>
|
||||
<script src="~/content/libs/moment.min.js"></script>
|
||||
<script src="~/content/libs/handlebarsmoment.js"></script>
|
||||
<script src="~/Content/libs/jquery.timeago.js"></script>
|
||||
<script src="~/content/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="~/content/libs/bootstrap-notify.js"></script>
|
||||
<link href="~/content/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="~/content/animate.css" rel="stylesheet">
|
||||
<link href="~/content/custom.css" rel="stylesheet">
|
||||
<link href="~/content/web/web.css" rel="stylesheet">
|
||||
<link href="~/content/css/jquery.dataTables.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="~/content/css/font-awesome.min.css">
|
||||
<title>Jackett</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<a href="~/">
|
||||
<img id="logo" src="~/content/jacket_medium.png" /><span id="header-title">Jackett</span>
|
||||
</a>
|
||||
<hr />
|
||||
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<div id="footer">
|
||||
Jackett @DateTime.Now.Year
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modals"></div>
|
||||
<!--@Scripts.Render("~/bundles/jquery")
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
@RenderSection("scripts", required: false)-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("abbr.timeago").timeago();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta NAME="description" CONTENT="Access your favorite torrent indexers with a single API.">
|
||||
<meta NAME="keywords" CONTENT="jackett, torznab, torrent, indexer">
|
||||
<meta NAME="robot" CONTENT="index,follow">
|
||||
<meta NAME="language" CONTENT="en">
|
||||
<link rel='shortcut icon' type='image/x-icon' href='~/content/favicon.ico' />
|
||||
<script src="~/content/libs/jquery.min.js"></script>
|
||||
<script src="~/content/libs/jquery.dataTables.min.js"></script>
|
||||
<script src="~/content/libs/handlebars.min.js"></script>
|
||||
<script src="~/content/libs/moment.min.js"></script>
|
||||
<script src="~/content/libs/handlebarsmoment.js"></script>
|
||||
<script src="~/Content/libs/jquery.timeago.js"></script>
|
||||
<script src="~/content/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="~/content/libs/bootstrap-notify.js"></script>
|
||||
<link href="~/content/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="~/content/animate.css" rel="stylesheet">
|
||||
<link href="~/content/custom.css" rel="stylesheet">
|
||||
<link href="~/content/web/web.css" rel="stylesheet">
|
||||
<link href="~/content/css/jquery.dataTables.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="~/content/css/font-awesome.min.css">
|
||||
<title>Jackett Torznab Indexer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<a href="~/">
|
||||
<img id="logo" src="~/content/jacket_medium.png" /><span id="header-title">Jackett</span>
|
||||
</a>
|
||||
<hr />
|
||||
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<div id="footer">
|
||||
Jackett @DateTime.Now.Year
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modals"></div>
|
||||
<!--@Scripts.Render("~/bundles/jquery")
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
@RenderSection("scripts", required: false)-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("abbr.timeago").timeago();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user