Make site link configurable for all indexers

This commit is contained in:
kaso17 2017-01-02 21:39:28 +01:00
parent 8a9648d347
commit f99e104755
76 changed files with 185 additions and 219 deletions

View File

@ -301,7 +301,7 @@ function displayIndexerSetup(id, link) {
return;
}
populateSetupForm(id, data.name, data.config, data.caps, link);
populateSetupForm(id, data.name, data.config, data.caps, link, data.alternativesitelinks);
}).fail(function () {
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
@ -378,11 +378,18 @@ function populateConfigItems(configForm, config) {
}
}
function newConfigModal(title, config, caps, link) {
function newConfigModal(title, config, caps, link, alternativesitelinks) {
var configTemplate = Handlebars.compile($("#jackett-config-setup-modal").html());
var configForm = $(configTemplate({ title: title, caps: caps, link:link }));
$("#modals").append(configForm);
populateConfigItems(configForm, config);
if (alternativesitelinks.length >= 1) {
var AlternativeSiteLinksTemplate = Handlebars.compile($("#setup-item-alternativesitelinks").html());
var template = $(AlternativeSiteLinksTemplate({ "alternativesitelinks": alternativesitelinks }));
configForm.find("div[data-id='sitelink']").after(template);
}
return configForm;
}
@ -427,8 +434,8 @@ function getConfigModalJson(configForm) {
return configJson;
}
function populateSetupForm(indexerId, name, config, caps, link) {
var configForm = newConfigModal(name, config, caps, link);
function populateSetupForm(indexerId, name, config, caps, link, alternativesitelinks) {
var configForm = newConfigModal(name, config, caps, link, alternativesitelinks);
var $goButton = configForm.find(".setup-indexer-go");
$goButton.click(function () {
var data = { indexer: indexerId, name: name };

View File

@ -175,6 +175,16 @@
<input class="form-control" type="text" value="{{{value}}}" />
</div>
</script>
<script id="setup-item-alternativesitelinks" type="text/x-handlebars-template">
<div class="setup-item-alternativesitelinks alert alert-info" role="alert">
This indexer has multiple known URLs which you can change above:
<ul>
{{#each alternativesitelinks}}
<li>{{this}}</li>
{{/each}}
</ul>
</div>
</script>
<script id="configured-indexer-table" type="text/x-handlebars-template">

View File

@ -161,6 +161,7 @@ namespace Jackett.Controllers
jsonReply["config"] = config.ToJson(null);
jsonReply["caps"] = indexer.TorznabCaps.CapsToJson();
jsonReply["name"] = indexer.DisplayName;
jsonReply["alternativesitelinks"] = JToken.FromObject(indexer.AlternativeSiteLinks);
jsonReply["result"] = "success";
}
catch (Exception ex)

View File

@ -103,7 +103,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
// Retrieve config values set by Jackett's user
ConfigData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
// Check & Validate Config
validateConfig();

View File

@ -53,7 +53,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
var token = new Regex("<meta name=\"_token\" content=\"(.*?)\">").Match(loginPage.Content).Groups[1].ToString();
var pairs = new Dictionary<string, string> {

View File

@ -46,7 +46,7 @@ namespace Jackett.Indexers.Abstract
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -67,7 +67,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -75,7 +75,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -74,7 +74,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
lock (cache)
{

View File

@ -69,7 +69,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -62,8 +62,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
if (configJson != null)
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -69,7 +69,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -47,7 +47,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var loginForm = await webclient.GetString(new Utils.Clients.WebRequest()
{

View File

@ -12,12 +12,15 @@ using Jackett.Utils.Clients;
using AutoMapper;
using System.Threading;
using Jackett.Models.IndexerConfig;
using System.Text.RegularExpressions;
namespace Jackett.Indexers
{
public abstract class BaseIndexer
{
public string SiteLink { get; protected set; }
public string DefaultSiteLink { get; protected set; }
public string[] AlternativeSiteLinks { get; protected set; } = new string[] { };
public string DisplayDescription { get; protected set; }
public string DisplayName { get; protected set; }
public string Language { get; protected set; }
@ -66,8 +69,10 @@ namespace Jackett.Indexers
DisplayName = name;
DisplayDescription = description;
SiteLink = link;
DefaultSiteLink = link;
this.downloadUrlBase = downloadBase;
this.configData = configData;
LoadValuesFromJson(null);
if (caps == null)
caps = TorznabUtil.CreateDefaultTorznabTVCaps();
@ -290,11 +295,33 @@ namespace Jackett.Indexers
}
}
public void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)
{
IProtectionService ps = null;
if (useProtectionService)
ps = protectionService;
configData.LoadValuesFromJson(jsonConfig, ps);
if (string.IsNullOrWhiteSpace(configData.SiteLink.Value))
{
configData.SiteLink.Value = DefaultSiteLink;
}
if (!configData.SiteLink.Value.EndsWith("/"))
configData.SiteLink.Value += "/";
var match = Regex.Match(configData.SiteLink.Value, "^https?:\\/\\/[\\w\\-\\/\\.]+$");
if (!match.Success)
{
throw new Exception(string.Format("\"{0}\" is not a valid URL.", configData.SiteLink.Value));
}
SiteLink = configData.SiteLink.Value;
}
public virtual void LoadFromSavedConfiguration(JToken jsonConfig)
{
if (jsonConfig is JArray)
{
configData.LoadValuesFromJson(jsonConfig, protectionService);
LoadValuesFromJson(jsonConfig, true);
IsConfigured = true;
}
// read and upgrade old settings file format

View File

@ -93,7 +93,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs1 = new Dictionary<string, string>
{

View File

@ -86,7 +86,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var result = await RequestStringWithCookies(configData.LoginLink.Value);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("Welcome Back"), () =>

View File

@ -84,7 +84,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -59,7 +59,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -63,7 +63,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -22,15 +22,14 @@ namespace Jackett.Indexers
{
public class BitSoup : BaseIndexer, IIndexer
{
private string UseLink { get { return (this.configData.AlternateLink.Value != null && this.configData.AlternateLink.Value != "" ? this.configData.AlternateLink.Value : SiteLink); } }
private string BrowseUrl { get { return UseLink + "browse.php"; } }
private string LoginUrl { get { return UseLink + "takelogin.php"; } }
private string LoginReferer { get { return UseLink + "login.php"; } }
private List<String> KnownURLs = new List<String> { "https://www.bitsoup.me/", "https://www.bitsoup.org/" };
private string BrowseUrl { get { return SiteLink + "browse.php"; } }
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
private string LoginReferer { get { return SiteLink + "login.php"; } }
public new string[] AlternativeSiteLinks { get; protected set; } = new string[] { "https://www.bitsoup.me/", "https://www.bitsoup.org/" };
new ConfigurationDataBasicLoginWithAlternateLink configData
new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLoginWithAlternateLink)base.configData; }
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
}
@ -43,15 +42,11 @@ namespace Jackett.Indexers
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLoginWithAlternateLink())
configData: new ConfigurationDataBasicLogin())
{
Encoding = Encoding.UTF8;
Language = "en-us";
this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below.";
this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName;
this.configData.Instructions.Value += "<ul><li>" + String.Join("</li><li>", this.KnownURLs.ToArray()) + "</li></ul>";
//AddCategoryMapping("624", TorznabCatType.Console);
//AddCategoryMapping("307", TorznabCatType.ConsoleNDS);
//AddCategoryMapping("308", TorznabCatType.ConsolePSP);
@ -148,28 +143,14 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
if (configData.AlternateLink.Value != null && configData.AlternateLink.Value != "")
{
if (!configData.AlternateLink.Value.EndsWith("/"))
{
configData.AlternateLink.Value = null;
throw new Exception("AlternateLink must end with a slash.");
}
var match = Regex.Match(configData.AlternateLink.Value, "^https?:\\/\\/(?:[\\w]+\\.)+(?:[a-zA-Z]+)\\/$");
if (!match.Success)
{
configData.AlternateLink.Value = null;
throw new Exception("AlternateLink must be a valid url.");
}
}
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },
};
var loginPage = await RequestStringWithCookies(UseLink, string.Empty);
var loginPage = await RequestStringWithCookies(SiteLink, string.Empty);
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, null, LoginReferer, true);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
@ -221,9 +202,9 @@ namespace Jackett.Indexers
var release = new ReleaseInfo();
release.Title = row.Cq().Find("td:eq(1) a").First().Text().Trim();
release.Comments = new Uri(UseLink + row.Cq().Find("td:eq(1) a").First().Attr("href"));
release.Comments = new Uri(SiteLink + row.Cq().Find("td:eq(1) a").First().Attr("href"));
release.Link = new Uri(UseLink + row.Cq().Find("td:eq(2) a").First().Attr("href"));
release.Link = new Uri(SiteLink + row.Cq().Find("td:eq(2) a").First().Attr("href"));
release.Guid = release.Link;
release.Description = release.Title;
var cat = row.Cq().Find("td:eq(0) a").First().Attr("href").Substring(15);

View File

@ -47,7 +47,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
IsConfigured = false;
try

View File

@ -185,10 +185,10 @@ namespace Jackett.Indexers
// init missing mandatory attributes
DisplayName = Definition.Name;
DisplayDescription = Definition.Description;
SiteLink = Definition.Links[0]; // TODO: implement alternative links
DefaultSiteLink = Definition.Links[0]; // TODO: implement alternative links
Encoding = Encoding.GetEncoding(Definition.Encoding);
if (!SiteLink.EndsWith("/"))
SiteLink += "/";
if (!DefaultSiteLink.EndsWith("/"))
DefaultSiteLink += "/";
Language = Definition.Language;
TorznabCaps = new TorznabCapabilities();
@ -208,8 +208,8 @@ namespace Jackett.Indexers
continue;
}
AddCategoryMapping(Category.Key, TorznabCatType.GetCatByName(Category.Value));
}
LoadValuesFromJson(null);
}
protected Dictionary<string, object> getTemplateVariablesFromConfigData()

View File

@ -126,7 +126,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -57,7 +57,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "nickname", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -101,7 +101,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "returnto" , "/" },
{ "username", configData.Username.Value },

View File

@ -72,7 +72,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }

View File

@ -50,7 +50,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }

View File

@ -53,8 +53,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
if (configJson != null)
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -91,7 +91,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
var pairs = new Dictionary<string, string> {

View File

@ -77,6 +77,7 @@ namespace Jackett.Indexers
} else
{
var stdResult = new ConfigurationDataBasicLogin();
stdResult.SiteLink.Value = configData.SiteLink.Value;
stdResult.Username.Value = configData.Username.Value;
stdResult.Password.Value = configData.Password.Value;
stdResult.CookieHeader.Value = loginPage.Cookies;
@ -86,7 +87,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -83,7 +83,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -104,7 +104,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "returnto" , "/" },
{ "username", configData.Username.Value },

View File

@ -76,7 +76,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);

View File

@ -21,15 +21,14 @@ namespace Jackett.Indexers
{
public class HDTorrents : BaseIndexer, IIndexer
{
private string UseLink { get { return (!String.IsNullOrEmpty(this.configData.AlternateLink.Value) ? this.configData.AlternateLink.Value : SiteLink); } }
private string SearchUrl { get { return UseLink + "torrents.php?"; } }
private string LoginUrl { get { return UseLink + "login.php"; } }
private string SearchUrl { get { return SiteLink + "torrents.php?"; } }
private string LoginUrl { get { return SiteLink + "login.php"; } }
private const int MAXPAGES = 3;
private List<String> KnownURLs = new List<String> { "https://hdts.ru/", "https://hd-torrents.org/", "https://hd-torrents.net/", "https://hd-torrents.me/" };
public new string[] AlternativeSiteLinks { get; protected set; } = new string[] { "https://hdts.ru/", "https://hd-torrents.org/", "https://hd-torrents.net/", "https://hd-torrents.me/" };
new ConfigurationDataBasicLoginWithAlternateLink configData
new ConfigurationDataBasicLogin configData
{
get { return (ConfigurationDataBasicLoginWithAlternateLink)base.configData; }
get { return (ConfigurationDataBasicLogin)base.configData; }
set { base.configData = value; }
}
@ -41,15 +40,11 @@ namespace Jackett.Indexers
client: w,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLoginWithAlternateLink())
configData: new ConfigurationDataBasicLogin())
{
Encoding = Encoding.GetEncoding("UTF-8");
Language = "en-us";
this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below.";
this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName;
this.configData.Instructions.Value += "<ul><li>" + String.Join("</li><li>", this.KnownURLs.ToArray()) + "</li></ul>";
TorznabCaps.Categories.Clear();
AddCategoryMapping("1", TorznabCatType.MoviesHD);// Movie/Blu-Ray
@ -76,9 +71,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
if (!string.IsNullOrWhiteSpace(configData.AlternateLink.Value) && !configData.AlternateLink.Value.EndsWith("/"))
configData.AlternateLink.Value += "/";
LoadValuesFromJson(configJson);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);

View File

@ -57,7 +57,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }

View File

@ -84,7 +84,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -98,7 +98,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
// reset cookies, if we send expired cookies for a new session their code seems to get confused
// Due to the session not getting initiated correctly it will result in errors like this:

View File

@ -13,6 +13,7 @@ namespace Jackett.Indexers
public interface IIndexer
{
string SiteLink { get; }
string[] AlternativeSiteLinks { get; }
string DisplayName { get; }
string DisplayDescription { get; }
@ -23,9 +24,9 @@ namespace Jackett.Indexers
TorznabCapabilities TorznabCaps { get; }
// Whether this indexer has been configured, verified and saved in the past and has the settings required for functioning
bool IsConfigured { get; }
// Retrieved for starting setup for the indexer via web API
bool IsConfigured { get; }
// Retrieved for starting setup for the indexer via web API
Task<ConfigurationData> GetConfigurationForSetup();
// Called when web API wants to apply setup configuration via web API, usually this is where login and storing cookie happens

View File

@ -74,7 +74,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -21,15 +21,14 @@ namespace Jackett.Indexers
{
public class IPTorrents : BaseIndexer, IIndexer
{
private string UseLink { get { return (!String.IsNullOrEmpty(this.configData.AlternateLink.Value) ? this.configData.AlternateLink.Value : SiteLink); } }
string LoginUrl { get { return UseLink + "login.php"; } }
string TakeLoginUrl { get { return UseLink + "take_login.php"; } }
private string BrowseUrl { get { return UseLink + "t"; } }
private List<String> KnownURLs = new List<String> { "https://ipt-update.com/", "https://iptorrents.com/", "https://iptorrents.eu", "https://nemo.iptorrents.com/", "https://ipt.rocks/" };
string LoginUrl { get { return SiteLink + "login.php"; } }
string TakeLoginUrl { get { return SiteLink + "take_login.php"; } }
private string BrowseUrl { get { return SiteLink + "t"; } }
public new string[] AlternativeSiteLinks { get; protected set; } = new string[] { "https://ipt-update.com/", "https://iptorrents.com/", "https://iptorrents.eu/", "https://nemo.iptorrents.com/", "https://ipt.rocks/" };
new ConfigurationDataRecaptchaLoginWithAlternateLink configData
new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLoginWithAlternateLink)base.configData; }
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
}
@ -42,15 +41,11 @@ namespace Jackett.Indexers
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataRecaptchaLoginWithAlternateLink())
configData: new ConfigurationDataRecaptchaLogin())
{
Encoding = Encoding.GetEncoding("UTF-8");
Language = "en-us";
this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below.";
this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName;
this.configData.Instructions.Value += "<ul><li>" + String.Join("</li><li>", this.KnownURLs.ToArray()) + "</li></ul>";
AddCategoryMapping(72, TorznabCatType.Movies);
AddCategoryMapping(77, TorznabCatType.MoviesSD);
AddCategoryMapping(89, TorznabCatType.MoviesSD);
@ -110,19 +105,21 @@ namespace Jackett.Indexers
}
else
{
var result = new ConfigurationDataBasicLoginWithAlternateLink();
var result = new ConfigurationDataBasicLogin();
result.SiteLink.Value = configData.SiteLink.Value;
result.Instructions.Value = configData.Instructions.Value;
result.Username.Value = configData.Username.Value;
result.Password.Value = configData.Password.Value;
result.CookieHeader.Value = loginPage.Cookies;
return result;
}
}
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },
@ -155,7 +152,7 @@ namespace Jackett.Indexers
{
Url = TakeLoginUrl,
Type = RequestType.POST,
Referer = UseLink,
Referer = SiteLink,
Encoding = Encoding,
PostData = pairs
};
@ -218,7 +215,7 @@ namespace Jackett.Indexers
}
release.Description = release.Title;
release.Guid = new Uri(UseLink + qTitleLink.Attr("href").Substring(1));
release.Guid = new Uri(SiteLink + qTitleLink.Attr("href").Substring(1));
release.Comments = release.Guid;
var descString = qRow.Find(".t_ctime").Text();
@ -227,7 +224,7 @@ namespace Jackett.Indexers
release.PublishDate = DateTimeUtil.FromTimeAgo(dateString);
var qLink = row.ChildElements.ElementAt(3).Cq().Children("a");
release.Link = new Uri(UseLink + HttpUtility.UrlEncode(qLink.Attr("href").TrimStart('/')));
release.Link = new Uri(SiteLink + HttpUtility.UrlEncode(qLink.Attr("href").TrimStart('/')));
var sizeStr = row.ChildElements.ElementAt(5).Cq().Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);

View File

@ -72,8 +72,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
if (configJson != null)
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -46,7 +46,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
ConfigData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", ConfigData.Username.Value },
{ "password", ConfigData.Password.Value },

View File

@ -132,7 +132,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "email", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -76,7 +76,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
if (configData.Hungarian.Value == false && configData.English.Value == false)
throw new ExceptionWithConfigData("Please select atleast one language.", configData);

View File

@ -96,7 +96,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -72,7 +72,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
// Retrieve config values set by Jackett's user
ConfigData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
// Check & Validate Config
ValidateConfig();

View File

@ -58,7 +58,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
await DoLogin();

View File

@ -66,7 +66,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var result1 = await RequestStringWithCookies(CaptchaUrl);
var json1 = JObject.Parse(result1.Content);

View File

@ -173,7 +173,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);

View File

@ -187,7 +187,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -92,7 +92,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -93,7 +93,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{
{ "username", configData.Username.Value },

View File

@ -99,6 +99,7 @@ namespace Jackett.Indexers
else
{
var stdResult = new ConfigurationDataBasicLogin();
stdResult.SiteLink.Value = configData.SiteLink.Value;
stdResult.Username.Value = configData.Username.Value;
stdResult.Password.Value = configData.Password.Value;
stdResult.CookieHeader.Value = loginPage.Cookies;
@ -108,7 +109,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -54,7 +54,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "referer", "login"},
{ "query", ""},

View File

@ -74,7 +74,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
await DoLogin();

View File

@ -108,7 +108,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }

View File

@ -46,7 +46,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -57,7 +57,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
await DoLogin();

View File

@ -75,8 +75,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
if(configJson != null)
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -21,11 +21,10 @@ namespace Jackett.Indexers
{
public class TorrentDay : BaseIndexer, IIndexer
{
private string UseLink { get { return (!String.IsNullOrEmpty(this.configData.AlternateLink.Value) ? this.configData.AlternateLink.Value : SiteLink); } }
private string StartPageUrl { get { return UseLink + "login.php"; } }
private string LoginUrl { get { return UseLink + "tak3login.php"; } }
private string SearchUrl { get { return UseLink + "browse.php"; } }
private List<String> KnownURLs = new List<String> {
private string StartPageUrl { get { return SiteLink + "login.php"; } }
private string LoginUrl { get { return SiteLink + "tak3login.php"; } }
private string SearchUrl { get { return SiteLink + "browse.php"; } }
public new string[] AlternativeSiteLinks { get; protected set; } = new string[] {
"https://tdonline.org/",
"https://secure.torrentday.com/",
"https://torrentday.eu/",
@ -39,9 +38,9 @@ namespace Jackett.Indexers
"https://www.td.af/",
};
new ConfigurationDataRecaptchaLoginWithAlternateLink configData
new ConfigurationDataRecaptchaLogin configData
{
get { return (ConfigurationDataRecaptchaLoginWithAlternateLink)base.configData; }
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
set { base.configData = value; }
}
@ -54,15 +53,11 @@ namespace Jackett.Indexers
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataRecaptchaLoginWithAlternateLink())
configData: new ConfigurationDataRecaptchaLogin())
{
Encoding = Encoding.GetEncoding("UTF-8");
Language = "en-us";
this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below.";
this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName;
this.configData.Instructions.Value += "<ul><li>" + String.Join("</li><li>", this.KnownURLs.ToArray()) + "</li></ul>";
AddCategoryMapping(29, TorznabCatType.TVAnime); // Anime
AddCategoryMapping(28, TorznabCatType.PC); // Appz/Packs
AddCategoryMapping(42, TorznabCatType.AudioAudiobook); // Audio Books
@ -125,7 +120,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },
@ -155,7 +150,7 @@ namespace Jackett.Indexers
}
}
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, configData.CookieHeader.Value, true, UseLink, LoginUrl);
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;
@ -223,9 +218,9 @@ namespace Jackett.Indexers
release.MinimumSeedTime = 172800;
release.Title = qRow.Find(".torrentName").Text();
release.Description = release.Title;
release.Guid = new Uri(UseLink + qRow.Find(".torrentName").Attr("href"));
release.Guid = new Uri(SiteLink + qRow.Find(".torrentName").Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(UseLink + qRow.Find(".dlLinksInfo > a").Attr("href"));
release.Link = new Uri(SiteLink + qRow.Find(".dlLinksInfo > a").Attr("href"));
var sizeStr = qRow.Find(".sizeInfo").Text();
release.Size = ReleaseInfo.GetBytes(sizeStr);

View File

@ -111,7 +111,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -95,7 +95,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
await DoLogin();
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -84,7 +84,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -77,7 +77,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },

View File

@ -94,7 +94,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var result1 = await RequestStringWithCookies(CaptchaUrl);
var json1 = JObject.Parse(result1.Content);

View File

@ -50,7 +50,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -44,7 +44,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
await DoLogin();
return IndexerConfigurationStatus.RequiresTesting;
}

View File

@ -99,7 +99,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
// Retrieve config values set by Jackett's user
ConfigData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
// Check & Validate Config
validateConfig();

View File

@ -126,7 +126,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{
{"username", configData.Username.Value},

View File

@ -114,7 +114,7 @@ namespace Jackett.Indexers
IsConfigured = false;
// Retrieve config values set by Jackett's user
ConfigData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
// Check & Validate Config
ValidateConfig();

View File

@ -62,7 +62,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{

View File

@ -68,7 +68,7 @@ namespace Jackett.Indexers
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },

View File

@ -237,8 +237,6 @@
<Compile Include="Models\IndexerConfig\ConfigurationDataAPIKey.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataLoginLink.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithRSSAndDisplay.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithAlternateLink.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataRecaptchaLoginWithAlternateLink.cs" />
<Compile Include="Models\ManualSearchResult.cs" />
<Compile Include="Indexers\TVChaosUK.cs" />
<Compile Include="Indexers\NCore.cs" />

View File

@ -27,6 +27,7 @@ namespace Jackett.Models.IndexerConfig
public HiddenItem CookieHeader { get; private set; } = new HiddenItem { Name = "CookieHeader" };
public HiddenItem LastError { get; private set; } = new HiddenItem { Name = "LastError" };
public StringItem SiteLink { get; private set; } = new StringItem { Name = "Site Link" };
public ConfigurationData()
{
@ -44,6 +45,14 @@ namespace Jackett.Models.IndexerConfig
return;
var arr = (JArray)json;
// transistion from alternatelink to sitelink
var alternatelinkItem = arr.FirstOrDefault(f => f.Value<string>("id") == "alternatelink");
if (alternatelinkItem != null && !string.IsNullOrEmpty(alternatelinkItem.Value<string>("value")))
{
//SiteLink.Value = alternatelinkItem.Value<string>("value");
}
foreach (var item in GetItems(forDisplay: false))
{
var arrItem = arr.FirstOrDefault(f => f.Value<string>("id") == item.ID);
@ -64,7 +73,8 @@ namespace Jackett.Models.IndexerConfig
if (ps != null)
sItem.Value = ps.UnProtect(newValue);
}
} else
}
else
{
sItem.Value = newValue;
}
@ -131,19 +141,23 @@ namespace Jackett.Models.IndexerConfig
Item[] GetItems(bool forDisplay)
{
var properties = GetType()
List<Item> properties = GetType()
.GetProperties()
.Where(p => p.CanRead)
.Where(p => p.PropertyType.IsSubclassOf(typeof(Item)))
.Select(p => (Item)p.GetValue(this));
.Select(p => (Item)p.GetValue(this)).ToList();
// remove/insert Site Link manualy to make sure it shows up first
properties.Remove(SiteLink);
properties.Insert(0, SiteLink);
properties = properties.Concat(dynamics.Values).ToArray();
properties.AddRange(dynamics.Values);
if (!forDisplay)
{
properties = properties
.Where(p => p.ItemType == ItemType.HiddenData || p.ItemType == ItemType.InputBool || p.ItemType == ItemType.InputString || p.ItemType == ItemType.Recaptcha || p.ItemType == ItemType.DisplayInfo)
.ToArray();
.ToList();
}
return properties.ToArray();

View File

@ -1,27 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Models.IndexerConfig
{
public class ConfigurationDataBasicLoginWithAlternateLink : ConfigurationData
{
public StringItem Username { get; private set; }
public StringItem Password { get; private set; }
public DisplayItem Instructions { get; private set; }
public StringItem AlternateLink { get; set; }
public ConfigurationDataBasicLoginWithAlternateLink(string instructionMessageOptional = null)
{
Username = new StringItem { Name = "Username" };
Password = new StringItem { Name = "Password" };
Instructions = new DisplayItem(instructionMessageOptional) { Name = "" };
AlternateLink = new StringItem { Name = "Alternate Link" };
}
}
}

View File

@ -1,29 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Models.IndexerConfig
{
public class ConfigurationDataRecaptchaLoginWithAlternateLink : ConfigurationData
{
public StringItem Username { get; private set; }
public StringItem Password { get; private set; }
public DisplayItem Instructions { get; private set; }
public StringItem AlternateLink { get; set; }
public RecaptchaItem Captcha { get; private set; }
public ConfigurationDataRecaptchaLoginWithAlternateLink(string instructionMessageOptional = null)
{
Username = new StringItem { Name = "Username" };
Password = new StringItem { Name = "Password" };
Instructions = new DisplayItem(instructionMessageOptional) { Name = "" };
AlternateLink = new StringItem { Name = "Alternate Link" };
Captcha = new RecaptchaItem() { Name = "Recaptcha" };
}
}
}