mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Add codec and medium filters to HDBits API (#7209)
* Add codec and medium filters to HDBits API * Add checkboxes support to CardigannIndexer * Expose multi-select as template variable * update datestamp to force cache refresh Co-authored-by: garfield69 <garfield69@outlook.com>
This commit is contained in:
@@ -55,6 +55,14 @@ body {
|
|||||||
max-width: 255px;
|
max-width: 255px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.setup-item-inputcheckbox label {
|
||||||
|
padding: 0 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setup-item-inputcheckbox input {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.setup-item-inputbool input {
|
.setup-item-inputbool input {
|
||||||
max-width: 100px;
|
max-width: 100px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
@@ -34,6 +34,14 @@ $(document).ready(function () {
|
|||||||
return opts.inverse(this);
|
return opts.inverse(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('if_in', function(elem, list, opts) {
|
||||||
|
if(list.indexOf(elem) > -1) {
|
||||||
|
return opts.fn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts.inverse(this);
|
||||||
|
});
|
||||||
|
|
||||||
var index = window.location.pathname.indexOf("/UI");
|
var index = window.location.pathname.indexOf("/UI");
|
||||||
var pathPrefix = window.location.pathname.substr(0, index);
|
var pathPrefix = window.location.pathname.substr(0, index);
|
||||||
api.root = pathPrefix + api.root;
|
api.root = pathPrefix + api.root;
|
||||||
@@ -608,6 +616,11 @@ function getConfigModalJson(configForm) {
|
|||||||
case "inputbool":
|
case "inputbool":
|
||||||
itemEntry.value = $el.find(".setup-item-inputbool input").is(":checked");
|
itemEntry.value = $el.find(".setup-item-inputbool input").is(":checked");
|
||||||
break;
|
break;
|
||||||
|
case "inputcheckbox":
|
||||||
|
itemEntry.values = [];
|
||||||
|
$el.find(".setup-item-inputcheckbox input:checked").each(function () {
|
||||||
|
itemEntry.values.push($(this).val());
|
||||||
|
});
|
||||||
case "inputselect":
|
case "inputselect":
|
||||||
itemEntry.value = $el.find(".setup-item-inputselect select").val();
|
itemEntry.value = $el.find(".setup-item-inputselect select").val();
|
||||||
break;
|
break;
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="../bootstrap/bootstrap.min.css?changed=2017083001">
|
<link rel="stylesheet" type="text/css" href="../bootstrap/bootstrap.min.css?changed=2017083001">
|
||||||
<link rel="stylesheet" type="text/css" href="../animate.css?changed=2017083001">
|
<link rel="stylesheet" type="text/css" href="../animate.css?changed=2017083001">
|
||||||
<link rel="stylesheet" type="text/css" href="../custom.css?changed=20200102" media="only screen and (min-device-width: 480px)">
|
<link rel="stylesheet" type="text/css" href="../custom.css?changed=20200220" media="only screen and (min-device-width: 480px)">
|
||||||
<link rel="stylesheet" type="text/css" href="../custom_mobile.css?changed=20200102" media="only screen and (max-device-width: 480px)">
|
<link rel="stylesheet" type="text/css" href="../custom_mobile.css?changed=20200102" media="only screen and (max-device-width: 480px)">
|
||||||
<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.min.css?changed=2017083001">
|
<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.min.css?changed=2017083001">
|
||||||
<link rel="stylesheet" type="text/css" href="../css/bootstrap-multiselect.css?changed=2017083001" />
|
<link rel="stylesheet" type="text/css" href="../css/bootstrap-multiselect.css?changed=2017083001" />
|
||||||
@@ -235,6 +235,19 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
<script id="setup-item-inputcheckbox" type="text/x-handlebars-template">
|
||||||
|
<div class="setup-item-inputcheckbox">
|
||||||
|
{{#each options}}
|
||||||
|
<div class="checkbox"><label>
|
||||||
|
{{#if_in @key ../values}}
|
||||||
|
<input type="checkbox" data-id="{{../../id}}" class="form-control" value="{{@key}}" checked />
|
||||||
|
{{else}}
|
||||||
|
<input type="checkbox" data-id="{{../../id}}" class="form-control" value="{{@key}}" />
|
||||||
|
{{/if_in}}
|
||||||
|
{{this}}</label></div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
<script id="setup-item-inputselect" type="text/x-handlebars-template">
|
<script id="setup-item-inputselect" type="text/x-handlebars-template">
|
||||||
<div class="setup-item-inputselect">
|
<div class="setup-item-inputselect">
|
||||||
<select class="form-control" data-id="{{id}}">
|
<select class="form-control" data-id="{{id}}">
|
||||||
@@ -678,6 +691,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="../libs/api.js?changed=2017083001"></script>
|
<script type="text/javascript" src="../libs/api.js?changed=2017083001"></script>
|
||||||
<script type="text/javascript" src="../custom.js?changed=20200102"></script>
|
<script type="text/javascript" src="../custom.js?changed=20200220"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -118,6 +118,14 @@ namespace Jackett.Common.Indexers
|
|||||||
case "text":
|
case "text":
|
||||||
item = new StringItem { Value = Setting.Default };
|
item = new StringItem { Value = Setting.Default };
|
||||||
break;
|
break;
|
||||||
|
case "multi-select":
|
||||||
|
if (Setting.Options == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Options must be given for the 'multi-select' type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
item = new CheckboxItem(Setting.Options) { Values = Setting.Defaults };
|
||||||
|
break;
|
||||||
case "select":
|
case "select":
|
||||||
if (Setting.Options == null)
|
if (Setting.Options == null)
|
||||||
{
|
{
|
||||||
@@ -201,8 +209,16 @@ namespace Jackett.Common.Indexers
|
|||||||
variables[".Config.sitelink"] = SiteLink;
|
variables[".Config.sitelink"] = SiteLink;
|
||||||
foreach (var Setting in Definition.Settings)
|
foreach (var Setting in Definition.Settings)
|
||||||
{
|
{
|
||||||
string value;
|
|
||||||
var item = configData.GetDynamic(Setting.Name);
|
var item = configData.GetDynamic(Setting.Name);
|
||||||
|
|
||||||
|
// CheckBox item is an array of strings
|
||||||
|
if (item.GetType() == typeof(CheckboxItem))
|
||||||
|
{
|
||||||
|
variables[".Config." + Setting.Name] = ((CheckboxItem)item).Values;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string value;
|
||||||
if (item.GetType() == typeof(BoolItem))
|
if (item.GetType() == typeof(BoolItem))
|
||||||
{
|
{
|
||||||
value = (((BoolItem)item).Value == true ? "true" : "");
|
value = (((BoolItem)item).Value == true ? "true" : "");
|
||||||
@@ -217,6 +233,7 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
variables[".Config." + Setting.Name] = value;
|
variables[".Config." + Setting.Name] = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jackett.Common.Models;
|
using Jackett.Common.Models;
|
||||||
using Jackett.Common.Models.IndexerConfig;
|
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
using Jackett.Common.Utils.Clients;
|
using Jackett.Common.Utils.Clients;
|
||||||
@@ -17,9 +17,9 @@ namespace Jackett.Common.Indexers
|
|||||||
{
|
{
|
||||||
private string APIUrl { get { return SiteLink + "api/"; } }
|
private string APIUrl { get { return SiteLink + "api/"; } }
|
||||||
|
|
||||||
private new ConfigurationDataUserPasskey configData
|
private new ConfigurationDataHDBitsApi configData
|
||||||
{
|
{
|
||||||
get { return (ConfigurationDataUserPasskey)base.configData; }
|
get { return (ConfigurationDataHDBitsApi)base.configData; }
|
||||||
set { base.configData = value; }
|
set { base.configData = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ namespace Jackett.Common.Indexers
|
|||||||
client: wc,
|
client: wc,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataUserPasskey())
|
configData: new ConfigurationDataHDBitsApi())
|
||||||
{
|
{
|
||||||
Encoding = Encoding.UTF8;
|
Encoding = Encoding.UTF8;
|
||||||
Language = "en-us";
|
Language = "en-us";
|
||||||
@@ -99,6 +99,26 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configData.Codecs.Values.Length > 0)
|
||||||
|
{
|
||||||
|
requestData["codec"] = new JArray();
|
||||||
|
|
||||||
|
foreach (var codec in configData.Codecs.Values)
|
||||||
|
{
|
||||||
|
requestData["codec"].Add(new JValue(int.Parse(codec)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configData.Mediums.Values.Length > 0)
|
||||||
|
{
|
||||||
|
requestData["medium"] = new JArray();
|
||||||
|
|
||||||
|
foreach (var medium in configData.Mediums.Values)
|
||||||
|
{
|
||||||
|
requestData["medium"].Add(new JValue(int.Parse(medium)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestData["limit"] = 100;
|
requestData["limit"] = 100;
|
||||||
|
|
||||||
var response = await MakeApiRequest("torrents", requestData);
|
var response = await MakeApiRequest("torrents", requestData);
|
||||||
|
@@ -4,6 +4,7 @@ namespace Jackett.Common.Models.DTO
|
|||||||
{
|
{
|
||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
public string value { get; set; }
|
public string value { get; set; }
|
||||||
|
public string[] values { get; set; } // for array data (e.g. checkboxes)
|
||||||
public string cookie { get; set; } // for cookie alternative login (captcha needed + remote host)
|
public string cookie { get; set; } // for cookie alternative login (captcha needed + remote host)
|
||||||
public string challenge { get; set; } // for reCaptcha V1 compatibility
|
public string challenge { get; set; } // for reCaptcha V1 compatibility
|
||||||
public string version { get; set; } // for reCaptcha V1 compatibility
|
public string version { get; set; } // for reCaptcha V1 compatibility
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Jackett.Common.Models.IndexerConfig.Bespoke
|
||||||
|
{
|
||||||
|
internal class ConfigurationDataHDBitsApi : ConfigurationDataUserPasskey
|
||||||
|
{
|
||||||
|
public CheckboxItem Codecs { get; private set; }
|
||||||
|
public CheckboxItem Mediums { get; private set; }
|
||||||
|
|
||||||
|
public ConfigurationDataHDBitsApi(): base()
|
||||||
|
{
|
||||||
|
Codecs = new CheckboxItem(new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{"1", "H.264"},
|
||||||
|
{"5", "HEVC"},
|
||||||
|
{"2", "MPEG-2"},
|
||||||
|
{"3", "VC-1"},
|
||||||
|
{"6", "VP9"},
|
||||||
|
{"4", "XviD"}
|
||||||
|
})
|
||||||
|
{ Name = "Codec", Values = new string[]{ "1", "5", "2", "3", "6", "4" } };
|
||||||
|
|
||||||
|
Mediums = new CheckboxItem(new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{"1", "Blu-ray/HD DVD"},
|
||||||
|
{"4", "Capture"},
|
||||||
|
{"3", "Encode"},
|
||||||
|
{"5", "Remux"},
|
||||||
|
{"6", "WEB-DL"}
|
||||||
|
})
|
||||||
|
{ Name = "Medium", Values = new string[]{ "1", "4", "3", "5", "6" } };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -16,6 +16,7 @@ namespace Jackett.Common.Models.IndexerConfig
|
|||||||
{
|
{
|
||||||
InputString,
|
InputString,
|
||||||
InputBool,
|
InputBool,
|
||||||
|
InputCheckbox,
|
||||||
InputSelect,
|
InputSelect,
|
||||||
DisplayImage,
|
DisplayImage,
|
||||||
DisplayInfo,
|
DisplayInfo,
|
||||||
@@ -83,6 +84,11 @@ namespace Jackett.Common.Models.IndexerConfig
|
|||||||
case ItemType.InputBool:
|
case ItemType.InputBool:
|
||||||
((BoolItem)item).Value = arrItem.Value<bool>("value");
|
((BoolItem)item).Value = arrItem.Value<bool>("value");
|
||||||
break;
|
break;
|
||||||
|
case ItemType.InputCheckbox:
|
||||||
|
var values = arrItem.Value<JArray>("values");
|
||||||
|
if (values != null)
|
||||||
|
((CheckboxItem)item).Values = values.Values<string>().ToArray();
|
||||||
|
break;
|
||||||
case ItemType.InputSelect:
|
case ItemType.InputSelect:
|
||||||
((SelectItem)item).Value = arrItem.Value<string>("value");
|
((SelectItem)item).Value = arrItem.Value<string>("value");
|
||||||
break;
|
break;
|
||||||
@@ -130,6 +136,15 @@ namespace Jackett.Common.Models.IndexerConfig
|
|||||||
case ItemType.InputBool:
|
case ItemType.InputBool:
|
||||||
jObject["value"] = ((BoolItem)item).Value;
|
jObject["value"] = ((BoolItem)item).Value;
|
||||||
break;
|
break;
|
||||||
|
case ItemType.InputCheckbox:
|
||||||
|
jObject["values"] = new JArray(((CheckboxItem)item).Values);
|
||||||
|
jObject["options"] = new JObject();
|
||||||
|
|
||||||
|
foreach (var option in ((CheckboxItem)item).Options)
|
||||||
|
{
|
||||||
|
jObject["options"][option.Key] = option.Value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ItemType.InputSelect:
|
case ItemType.InputSelect:
|
||||||
jObject["value"] = ((SelectItem)item).Value;
|
jObject["value"] = ((SelectItem)item).Value;
|
||||||
jObject["options"] = new JObject();
|
jObject["options"] = new JObject();
|
||||||
@@ -166,7 +181,7 @@ namespace Jackett.Common.Models.IndexerConfig
|
|||||||
if (!forDisplay)
|
if (!forDisplay)
|
||||||
{
|
{
|
||||||
properties = properties
|
properties = properties
|
||||||
.Where(p => p.ItemType == ItemType.HiddenData || p.ItemType == ItemType.InputBool || p.ItemType == ItemType.InputString || p.ItemType == ItemType.InputSelect || p.ItemType == ItemType.Recaptcha || p.ItemType == ItemType.DisplayInfo)
|
.Where(p => p.ItemType == ItemType.HiddenData || p.ItemType == ItemType.InputBool || p.ItemType == ItemType.InputString || p.ItemType == ItemType.InputCheckbox || p.ItemType == ItemType.InputSelect || p.ItemType == ItemType.Recaptcha || p.ItemType == ItemType.DisplayInfo)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,6 +275,19 @@ namespace Jackett.Common.Models.IndexerConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CheckboxItem : Item
|
||||||
|
{
|
||||||
|
public string[] Values { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<string, string> Options { get; }
|
||||||
|
|
||||||
|
public CheckboxItem(Dictionary<string, string> options)
|
||||||
|
{
|
||||||
|
ItemType = ItemType.InputCheckbox;
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SelectItem : Item
|
public class SelectItem : Item
|
||||||
{
|
{
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
|
@@ -83,6 +83,7 @@ namespace Jackett.Common.Models
|
|||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public string Default { get; set; }
|
public string Default { get; set; }
|
||||||
|
public string[] Defaults { get; set; }
|
||||||
public Dictionary<string, string> Options { get; set; }
|
public Dictionary<string, string> Options { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user