mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
#93 Change IPT to be category aware and render availible categories to the front end.
This commit is contained in:
@@ -210,4 +210,13 @@ hr {
|
||||
|
||||
.modal-fillwidth {
|
||||
width: 1200px;
|
||||
}
|
||||
|
||||
.indexer-caps {
|
||||
padding: 0px 15px 15px 15px;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.indexer-caps table {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
@@ -211,7 +211,7 @@ function displayIndexerSetup(id) {
|
||||
return;
|
||||
}
|
||||
|
||||
populateSetupForm(id, data.name, data.config);
|
||||
populateSetupForm(id, data.name, data.config, data.caps);
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
@@ -236,17 +236,12 @@ function populateConfigItems(configForm, config) {
|
||||
}
|
||||
}
|
||||
|
||||
function newConfigModal(title, config) {
|
||||
//config-setup-modal
|
||||
var configTemplate = Handlebars.compile($("#templates > .config-setup-modal")[0].outerHTML);
|
||||
var configForm = $(configTemplate({ title: title }));
|
||||
|
||||
function newConfigModal(title, config, caps) {
|
||||
var configTemplate = Handlebars.compile($("#jackett-config-setup-modal").html());
|
||||
var configForm = $(configTemplate({ title: title, caps: caps }));
|
||||
$("#modals").append(configForm);
|
||||
|
||||
populateConfigItems(configForm, config);
|
||||
|
||||
return configForm;
|
||||
//modal.remove();
|
||||
}
|
||||
|
||||
function getConfigModalJson(configForm) {
|
||||
@@ -267,8 +262,8 @@ function getConfigModalJson(configForm) {
|
||||
return configJson;
|
||||
}
|
||||
|
||||
function populateSetupForm(indexerId, name, config) {
|
||||
var configForm = newConfigModal(name, config);
|
||||
function populateSetupForm(indexerId, name, config, caps) {
|
||||
var configForm = newConfigModal(name, config, caps);
|
||||
var $goButton = configForm.find(".setup-indexer-go");
|
||||
$goButton.click(function () {
|
||||
var data = { indexer: indexerId, name: name };
|
||||
|
@@ -70,6 +70,45 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="jackett-config-setup-modal" type="text/x-handlebars-template">
|
||||
<div class="config-setup-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">{{title}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="config-setup-form"></form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary setup-indexer-go">Okay</button>
|
||||
</div>
|
||||
<div class="indexer-caps">
|
||||
<h4>Capabilities</h4>
|
||||
<table class="dataTable compact cell-border hover stripe">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each caps}}
|
||||
<tr>
|
||||
<td>{{ID}}</td>
|
||||
<td>{{Name}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<title>Jackett</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -149,24 +188,6 @@
|
||||
<div id="modals"></div>
|
||||
|
||||
<div id="templates">
|
||||
<div class="config-setup-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">{{title}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="config-setup-form"></form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary setup-indexer-go">Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="indexer card add-indexer" data-toggle="modal" data-target="#select-indexer-modal">
|
||||
<div class="indexer-add-content">
|
||||
<span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
|
@@ -3,6 +3,7 @@ using Jackett.Indexers;
|
||||
using Jackett.Models;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -146,6 +147,7 @@ namespace Jackett.Controllers
|
||||
var indexer = indexerService.GetIndexer((string)postData["indexer"]);
|
||||
var config = await indexer.GetConfigurationForSetup();
|
||||
jsonReply["config"] = config.ToJson();
|
||||
jsonReply["caps"] = indexer.TorznabCaps.CapsToJson();
|
||||
jsonReply["name"] = indexer.DisplayName;
|
||||
jsonReply["result"] = "success";
|
||||
}
|
||||
|
@@ -343,5 +343,19 @@ namespace Jackett.Indexers
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory));
|
||||
}
|
||||
|
||||
protected List<string> MapTorznabCapsToTrackers(TorznabQuery query)
|
||||
{
|
||||
var result = new List<string>();
|
||||
foreach (var cat in query.Categories)
|
||||
{
|
||||
foreach (var mapping in categoryMapping.Where(c => c.NewzNabCategory == cat))
|
||||
{
|
||||
result.Add(mapping.TrackerCategory);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -19,7 +20,7 @@ namespace Jackett.Indexers
|
||||
{
|
||||
public class IPTorrents : BaseIndexer, IIndexer
|
||||
{
|
||||
private string SearchUrl { get { return SiteLink + "t?26=&55=&78=&23=&24=&25=&66=&82=&65=&83=&79=&22=&5=&4=&60=&q="; } }
|
||||
private string BrowseUrl { get { return SiteLink + "t"; } }
|
||||
|
||||
public IPTorrents(IIndexerManagerService i, IWebClient wc, Logger l)
|
||||
: base(name: "IPTorrents",
|
||||
@@ -30,7 +31,47 @@ namespace Jackett.Indexers
|
||||
client: wc,
|
||||
logger: l)
|
||||
{
|
||||
TorznabCaps.Categories.Add(TorznabCatType.Anime);
|
||||
AddCategoryMapping(72, TorznabCatType.Movies);
|
||||
AddCategoryMapping(77, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(89, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(90, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(96, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(6, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(48, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(54, TorznabCatType.Movies);
|
||||
AddCategoryMapping(62, TorznabCatType.MoviesSD);
|
||||
AddCategoryMapping(38, TorznabCatType.MoviesForeign);
|
||||
AddCategoryMapping(68, TorznabCatType.Movies);
|
||||
AddCategoryMapping(20, TorznabCatType.MoviesHD);
|
||||
AddCategoryMapping(7, TorznabCatType.MoviesSD);
|
||||
|
||||
AddCategoryMapping(73, TorznabCatType.TV);
|
||||
AddCategoryMapping(26, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(55, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(78, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(23, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(24, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(25, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(66, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(82, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(65, TorznabCatType.TV);
|
||||
AddCategoryMapping(83, TorznabCatType.TV);
|
||||
AddCategoryMapping(79, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(22, TorznabCatType.TVHD);
|
||||
AddCategoryMapping(79, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(4, TorznabCatType.TVSD);
|
||||
AddCategoryMapping(5, TorznabCatType.TVHD);
|
||||
|
||||
AddCategoryMapping(75, TorznabCatType.Audio);
|
||||
AddCategoryMapping(73, TorznabCatType.Audio);
|
||||
AddCategoryMapping(80, TorznabCatType.AudioLossless);
|
||||
AddCategoryMapping(93, TorznabCatType.Audio);
|
||||
|
||||
AddCategoryMapping(60, TorznabCatType.Anime);
|
||||
AddCategoryMapping(1, TorznabCatType.Apps);
|
||||
AddCategoryMapping(64, TorznabCatType.AudioBooks);
|
||||
AddCategoryMapping(35, TorznabCatType.Books);
|
||||
AddCategoryMapping(94, TorznabCatType.Comic);
|
||||
}
|
||||
|
||||
public Task<ConfigurationData> GetConfigurationForSetup()
|
||||
@@ -71,8 +112,26 @@ namespace Jackett.Indexers
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
|
||||
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
|
||||
var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl, null, SearchUrl);
|
||||
var searchUrl = BrowseUrl;
|
||||
var trackerCats = MapTorznabCapsToTrackers(query);
|
||||
var queryCollection = new NameValueCollection();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchString))
|
||||
{
|
||||
queryCollection.Add("q", searchString);
|
||||
}
|
||||
|
||||
foreach (var cat in MapTorznabCapsToTrackers(query))
|
||||
{
|
||||
queryCollection.Add(cat, string.Empty);
|
||||
}
|
||||
|
||||
if (queryCollection.Count > 0)
|
||||
{
|
||||
searchUrl += "?" + string.Join("&", queryCollection.AllKeys.Select(a => a + "=" + HttpUtility.UrlEncode(queryCollection[a])));
|
||||
}
|
||||
|
||||
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
||||
|
||||
var results = response.Content;
|
||||
try
|
||||
@@ -111,6 +170,9 @@ namespace Jackett.Indexers
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".t_seeders").Text().Trim());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find(".t_leechers").Text().Trim()) + release.Seeders;
|
||||
|
||||
var cat = row.Cq().Find("td:eq(0) a").First().Attr("href").Substring(1);
|
||||
release.Category = MapTrackerCatToNewznab(cat);
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -46,6 +47,16 @@ namespace Jackett.Models
|
||||
}
|
||||
}
|
||||
|
||||
public JArray CapsToJson()
|
||||
{
|
||||
var jArray = new JArray();
|
||||
foreach (var cat in Categories.GroupBy(p => p.ID).Select(g => g.First()).OrderBy(c=>c.ID))
|
||||
{
|
||||
jArray.Add(cat.ToJson());
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
public string ToXml()
|
||||
{
|
||||
var xdoc = new XDocument(
|
||||
|
@@ -20,6 +20,7 @@ namespace Jackett.Models
|
||||
cats.Add(8020, "Books/Comics");
|
||||
cats.Add(4000, "PC");
|
||||
cats.Add(3030, "Audio/Audiobook");
|
||||
cats.Add(2000, "Movies");
|
||||
cats.Add(2040, "Movies/HD");
|
||||
cats.Add(2030, "Movies/SD");
|
||||
cats.Add(2010, "Movies/Foreign");
|
||||
@@ -107,6 +108,11 @@ namespace Jackett.Models
|
||||
get { return GetCat(3030); }
|
||||
}
|
||||
|
||||
public static TorznabCategory Movies
|
||||
{
|
||||
get { return GetCat(2000); }
|
||||
}
|
||||
|
||||
public static TorznabCategory MoviesHD
|
||||
{
|
||||
get { return GetCat(2040); }
|
||||
@@ -114,7 +120,7 @@ namespace Jackett.Models
|
||||
|
||||
public static TorznabCategory MoviesSD
|
||||
{
|
||||
get { return GetCat(2040); }
|
||||
get { return GetCat(2030); }
|
||||
}
|
||||
|
||||
public static TorznabCategory MoviesForeign
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -17,5 +18,13 @@ namespace Jackett.Models
|
||||
{
|
||||
SubCategories = new List<TorznabCategory>();
|
||||
}
|
||||
|
||||
public JToken ToJson()
|
||||
{
|
||||
var t = new JObject();
|
||||
t["ID"] = ID;
|
||||
t["Name"] = Name;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user