mirror of https://github.com/Jackett/Jackett
Fix issue with add indexer not working and rejig the UI a bit.
This commit is contained in:
parent
e65a8abf5e
commit
7e3266489f
|
@ -33,6 +33,7 @@
|
|||
|
||||
#indexers {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
|
||||
|
@ -262,4 +263,16 @@ pre {
|
|||
|
||||
.modal-open .modal {
|
||||
overflow-x: auto; /* Model can be bigger than the screen on mobiles */
|
||||
}
|
||||
}
|
||||
|
||||
#unconfigured-indexers-template {
|
||||
display: none;
|
||||
}
|
||||
.jackett-apikey{
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.jackett-apikey .input-header{
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +1,22 @@
|
|||
$(document).ready(function () {
|
||||
$.ajaxSetup({ cache: false });
|
||||
window.jackettIsLocal = window.location.hostname === 'localhost' ||
|
||||
window.location.hostname === '127.0.0.1';
|
||||
|
||||
bindUIButtons();
|
||||
reloadIndexers();
|
||||
loadJackettSettings();
|
||||
|
||||
window.jackettIsLocal = window.location.hostname === 'localhost' ||
|
||||
window.location.hostname === '127.0.0.1';
|
||||
|
||||
$('body').on('click', '.downloadlink', function (e, b) {
|
||||
$(e.target).addClass('jackettdownloaded');
|
||||
});
|
||||
|
||||
|
||||
$('body').on('click', '.jacketdownloadserver', function (event) {
|
||||
var href = $(event.target).parent().attr('href');
|
||||
var jqxhr = $.get(href, function (data) {
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Downloaded sent to the blackhole successfully.", "success", "glyphicon glyphicon-ok");
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function getJackettConfig(callback) {
|
||||
var jqxhr = $.get("/admin/get_jackett_config", function (data) {
|
||||
|
||||
callback(data);
|
||||
}).fail(function () {
|
||||
doNotify("Error loading Jackett settings, request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
}
|
||||
|
||||
function loadJackettSettings() {
|
||||
getJackettConfig(function (data) {
|
||||
$("#api-key-input").val(data.config.api_key);
|
||||
|
@ -44,276 +32,6 @@ function loadJackettSettings() {
|
|||
});
|
||||
}
|
||||
|
||||
$("#jackett-show-releases").click(function () {
|
||||
var jqxhr = $.get("/admin/GetCache", function (data) {
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-releases").html());
|
||||
var item = { releases: data, Title: 'Releases' };
|
||||
var releaseDialog = $(releaseTemplate(item));
|
||||
releaseDialog.find('table').DataTable(
|
||||
{
|
||||
"pageLength": 20,
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
||||
"order": [[0, "desc"]],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 1,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 2,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 0
|
||||
},
|
||||
{
|
||||
"targets": 3,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 1
|
||||
}
|
||||
],
|
||||
initComplete: function () {
|
||||
var count = 0;
|
||||
this.api().columns().every(function () {
|
||||
count++;
|
||||
if (count === 5 || count === 7) {
|
||||
var column = this;
|
||||
var select = $('<select><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
|
||||
column
|
||||
.search(val ? '^' + val + '$' : '', true, false)
|
||||
.draw();
|
||||
});
|
||||
|
||||
column.data().unique().sort().each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#jackett-show-search").click(function () {
|
||||
$('#select-indexer-modal').remove();
|
||||
var jqxhr = $.get("/admin/get_indexers", function (data) {
|
||||
var scope = {
|
||||
items: data.items
|
||||
};
|
||||
|
||||
var indexers = [];
|
||||
indexers.push({ id: '', name: '-- All --' });
|
||||
for (var i = 0; i < data.items.length; i++) {
|
||||
if (data.items[i].configured === true) {
|
||||
indexers.push(data.items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-search").html());
|
||||
var releaseDialog = $(releaseTemplate({ indexers: indexers }));
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
var setCategories = function (tracker, items) {
|
||||
var cats = {};
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].configured === true && (items[i].id === tracker || tracker ==='')) {
|
||||
indexers["'" + items[i].id + "'"] = items[i].name;
|
||||
for (var prop in items[i].caps) {
|
||||
cats[prop] = items[i].caps[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
var select = $('#searchCategory');
|
||||
select.html("<option value=''>-- All --</option>");
|
||||
$.each(cats, function (value, key) {
|
||||
select.append($("<option></option>")
|
||||
.attr("value", value).text(key + ' (' + value + ')'));
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
setCategories('', data.items);
|
||||
$('#searchTracker').change(jQuery.proxy(function () {
|
||||
var trackerId = $('#searchTracker').val();
|
||||
setCategories(trackerId, this.items);
|
||||
}, scope));
|
||||
|
||||
|
||||
$('#jackett-search-perform').click(function () {
|
||||
if ($('#jackett-search-perform').text().trim() !== 'Search trackers') {
|
||||
// We are searchin already
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var queryObj = {
|
||||
Query: releaseDialog.find('#searchquery').val(),
|
||||
Category: releaseDialog.find('#searchCategory').val(),
|
||||
Tracker: releaseDialog.find('#searchTracker').val().replace("'", "").replace("'", ""),
|
||||
};
|
||||
$('#searchResults').empty();
|
||||
|
||||
$('#jackett-search-perform').html($('#spinner').html());
|
||||
var jqxhr = $.post("/admin/search", queryObj, function (data) {
|
||||
$('#jackett-search-perform').html('Search trackers');
|
||||
var resultsTemplate = Handlebars.compile($("#jackett-search-results").html());
|
||||
var results = $('#searchResults');
|
||||
results.html($(resultsTemplate(data)));
|
||||
|
||||
results.find('table').DataTable(
|
||||
{
|
||||
"pageLength": 20,
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
||||
"order": [[0, "desc"]],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 1,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 0
|
||||
},
|
||||
],
|
||||
initComplete: function () {
|
||||
var count = 0;
|
||||
this.api().columns().every(function () {
|
||||
count++;
|
||||
if (count === 3 || count === 5) {
|
||||
var column = this;
|
||||
var select = $('<select><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
|
||||
column
|
||||
.search(val ? '^' + val + '$' : '', true, false)
|
||||
.draw();
|
||||
});
|
||||
|
||||
column.data().unique().sort().each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).fail(function () {
|
||||
$('#jackett-search-perform').html('Search trackers');
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Error loading indexers, request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#view-jackett-logs").click(function () {
|
||||
var jqxhr = $.get("/admin/GetLogs", function (data) {
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-logs").html());
|
||||
var item = { logs: data };
|
||||
var releaseDialog = $(releaseTemplate(item));
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#change-jackett-port").click(function () {
|
||||
var jackett_port = $("#jackett-port").val();
|
||||
var jackett_external = $("#jackett-allowext").is(':checked');
|
||||
var jsonObject = {
|
||||
port: jackett_port,
|
||||
external: jackett_external,
|
||||
blackholedir: $("#jackett-savedir").val()
|
||||
};
|
||||
var jqxhr = $.post("/admin/set_config", JSON.stringify(jsonObject), function (data) {
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
||||
window.setTimeout(function () {
|
||||
url = window.location.href;
|
||||
if (data.external) {
|
||||
window.location.href = url.substr(0, url.lastIndexOf(":") + 1) + data.port;
|
||||
} else {
|
||||
window.location.href = 'http://127.0.0.1:' + data.port;
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
$("#change-jackett-password").click(function () {
|
||||
var password = $("#jackett-adminpwd").val();
|
||||
var jsonObject = { password: password };
|
||||
|
||||
var jqxhr = $.post("/admin/set_admin_password", JSON.stringify(jsonObject), function (data) {
|
||||
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Admin password has been set.", "success", "glyphicon glyphicon-ok");
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.location = window.location.pathname;
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
function getJackettConfig(callback) {
|
||||
var jqxhr = $.get("/admin/get_jackett_config", function (data) {
|
||||
|
||||
callback(data);
|
||||
}).fail(function () {
|
||||
doNotify("Error loading Jackett settings, request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
}
|
||||
|
||||
function reloadIndexers() {
|
||||
$('#indexers').hide();
|
||||
$('#indexers > .indexer').remove();
|
||||
|
@ -328,6 +46,7 @@ function reloadIndexers() {
|
|||
function displayIndexers(items) {
|
||||
var indexerTemplate = Handlebars.compile($("#configured-indexer").html());
|
||||
var unconfiguredIndexerTemplate = Handlebars.compile($("#unconfigured-indexer").html());
|
||||
$('#unconfigured-indexers-template').empty();
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
item.torznab_host = resolveUrl("/torznab/" + item.id);
|
||||
|
@ -335,11 +54,28 @@ function displayIndexers(items) {
|
|||
if (item.configured)
|
||||
$('#indexers').append(indexerTemplate(item));
|
||||
else
|
||||
$('#unconfigured-indexers').append($(unconfiguredIndexerTemplate(item)));
|
||||
$('#unconfigured-indexers-template').append($(unconfiguredIndexerTemplate(item)));
|
||||
}
|
||||
|
||||
var addIndexerButton = $('#add-indexer').html();
|
||||
$('#indexers').append(addIndexerButton);
|
||||
var addIndexerButton = $($('#add-indexer').html());
|
||||
addIndexerButton.appendTo($('#indexers'));
|
||||
|
||||
addIndexerButton.click(function () {
|
||||
$("#modals").empty();
|
||||
var dialog = $($("#select-indexer").html());
|
||||
dialog.find('#unconfigured-indexers').html($('#unconfigured-indexers-template').html());
|
||||
$("#modals").append(dialog);
|
||||
dialog.modal("show");
|
||||
$('.indexer-setup').each(function (i, btn) {
|
||||
var $btn = $(btn);
|
||||
var id = $btn.data("id");
|
||||
$btn.click(function () {
|
||||
$('#select-indexer-modal').modal('hide').on('hidden.bs.modal', function (e) {
|
||||
displayIndexerSetup(id);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#indexers').fadeIn();
|
||||
prepareSetupButtons();
|
||||
|
@ -386,10 +122,10 @@ function prepareTestButtons() {
|
|||
doNotify("Test started for " + id, "info", "glyphicon glyphicon-transfer");
|
||||
var jqxhr = $.post("/admin/test_indexer", JSON.stringify({ indexer: id }), function (data) {
|
||||
if (data.result == "error") {
|
||||
doNotify("Test failed for " + data.name + "\n" + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
doNotify("Test failed for " + id + ": \n" + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
}
|
||||
else {
|
||||
doNotify("Test successful for " + data.name, "success", "glyphicon glyphicon-ok");
|
||||
doNotify("Test successful for " + id, "success", "glyphicon glyphicon-ok");
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Error testing indexer, request to Jackett server error", "danger", "glyphicon glyphicon-alert");
|
||||
|
@ -536,8 +272,6 @@ function resolveUrl(url) {
|
|||
return url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doNotify(message, type, icon) {
|
||||
$.notify({
|
||||
message: message,
|
||||
|
@ -559,5 +293,278 @@ function clearNotifications() {
|
|||
$('[data-notify="container"]').remove();
|
||||
}
|
||||
|
||||
$('#test').click(doNotify);
|
||||
|
||||
function bindUIButtons() {
|
||||
$('body').on('click', '.downloadlink', function (e, b) {
|
||||
$(e.target).addClass('jackettdownloaded');
|
||||
});
|
||||
|
||||
$('body').on('click', '.jacketdownloadserver', function (event) {
|
||||
var href = $(event.target).parent().attr('href');
|
||||
var jqxhr = $.get(href, function (data) {
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Downloaded sent to the blackhole successfully.", "success", "glyphicon glyphicon-ok");
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#jackett-show-releases").click(function () {
|
||||
var jqxhr = $.get("/admin/GetCache", function (data) {
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-releases").html());
|
||||
var item = { releases: data, Title: 'Releases' };
|
||||
var releaseDialog = $(releaseTemplate(item));
|
||||
releaseDialog.find('table').DataTable(
|
||||
{
|
||||
"pageLength": 20,
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
||||
"order": [[0, "desc"]],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 1,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 2,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 0
|
||||
},
|
||||
{
|
||||
"targets": 3,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 1
|
||||
}
|
||||
],
|
||||
initComplete: function () {
|
||||
var count = 0;
|
||||
this.api().columns().every(function () {
|
||||
count++;
|
||||
if (count === 5 || count === 7) {
|
||||
var column = this;
|
||||
var select = $('<select><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
|
||||
column
|
||||
.search(val ? '^' + val + '$' : '', true, false)
|
||||
.draw();
|
||||
});
|
||||
|
||||
column.data().unique().sort().each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
$("#jackett-show-search").click(function () {
|
||||
$('#select-indexer-modal').remove();
|
||||
var jqxhr = $.get("/admin/get_indexers", function (data) {
|
||||
var scope = {
|
||||
items: data.items
|
||||
};
|
||||
|
||||
var indexers = [];
|
||||
indexers.push({ id: '', name: '-- All --' });
|
||||
for (var i = 0; i < data.items.length; i++) {
|
||||
if (data.items[i].configured === true) {
|
||||
indexers.push(data.items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-search").html());
|
||||
var releaseDialog = $(releaseTemplate({ indexers: indexers }));
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
var setCategories = function (tracker, items) {
|
||||
var cats = {};
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].configured === true && (items[i].id === tracker || tracker === '')) {
|
||||
indexers["'" + items[i].id + "'"] = items[i].name;
|
||||
for (var prop in items[i].caps) {
|
||||
cats[prop] = items[i].caps[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
var select = $('#searchCategory');
|
||||
select.html("<option value=''>-- All --</option>");
|
||||
$.each(cats, function (value, key) {
|
||||
select.append($("<option></option>")
|
||||
.attr("value", value).text(key + ' (' + value + ')'));
|
||||
});
|
||||
};
|
||||
|
||||
setCategories('', data.items);
|
||||
$('#searchTracker').change(jQuery.proxy(function () {
|
||||
var trackerId = $('#searchTracker').val();
|
||||
setCategories(trackerId, this.items);
|
||||
}, scope));
|
||||
|
||||
|
||||
$('#jackett-search-perform').click(function () {
|
||||
if ($('#jackett-search-perform').text().trim() !== 'Search trackers') {
|
||||
// We are searchin already
|
||||
return;
|
||||
}
|
||||
var queryObj = {
|
||||
Query: releaseDialog.find('#searchquery').val(),
|
||||
Category: releaseDialog.find('#searchCategory').val(),
|
||||
Tracker: releaseDialog.find('#searchTracker').val().replace("'", "").replace("'", ""),
|
||||
};
|
||||
$('#searchResults').empty();
|
||||
|
||||
$('#jackett-search-perform').html($('#spinner').html());
|
||||
var jqxhr = $.post("/admin/search", queryObj, function (data) {
|
||||
$('#jackett-search-perform').html('Search trackers');
|
||||
var resultsTemplate = Handlebars.compile($("#jackett-search-results").html());
|
||||
var results = $('#searchResults');
|
||||
results.html($(resultsTemplate(data)));
|
||||
|
||||
results.find('table').DataTable(
|
||||
{
|
||||
"pageLength": 20,
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
||||
"order": [[0, "desc"]],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"type": 'date'
|
||||
},
|
||||
{
|
||||
"targets": 1,
|
||||
"visible": true,
|
||||
"searchable": false,
|
||||
"iDataSort": 0
|
||||
},
|
||||
],
|
||||
initComplete: function () {
|
||||
var count = 0;
|
||||
this.api().columns().every(function () {
|
||||
count++;
|
||||
if (count === 3 || count === 5) {
|
||||
var column = this;
|
||||
var select = $('<select><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
|
||||
column
|
||||
.search(val ? '^' + val + '$' : '', true, false)
|
||||
.draw();
|
||||
});
|
||||
|
||||
column.data().unique().sort().each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).fail(function () {
|
||||
$('#jackett-search-perform').html('Search trackers');
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Error loading indexers, request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
$("#view-jackett-logs").click(function () {
|
||||
var jqxhr = $.get("/admin/GetLogs", function (data) {
|
||||
var releaseTemplate = Handlebars.compile($("#jackett-logs").html());
|
||||
var item = { logs: data };
|
||||
var releaseDialog = $(releaseTemplate(item));
|
||||
$("#modals").append(releaseDialog);
|
||||
releaseDialog.modal("show");
|
||||
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
$("#change-jackett-port").click(function () {
|
||||
var jackett_port = $("#jackett-port").val();
|
||||
var jackett_external = $("#jackett-allowext").is(':checked');
|
||||
var jsonObject = {
|
||||
port: jackett_port,
|
||||
external: jackett_external,
|
||||
blackholedir: $("#jackett-savedir").val()
|
||||
};
|
||||
var jqxhr = $.post("/admin/set_config", JSON.stringify(jsonObject), function (data) {
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
||||
window.setTimeout(function () {
|
||||
url = window.location.href;
|
||||
if (data.external) {
|
||||
window.location.href = url.substr(0, url.lastIndexOf(":") + 1) + data.port;
|
||||
} else {
|
||||
window.location.href = 'http://127.0.0.1:' + data.port;
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
|
||||
$("#change-jackett-password").click(function () {
|
||||
var password = $("#jackett-adminpwd").val();
|
||||
var jsonObject = { password: password };
|
||||
|
||||
var jqxhr = $.post("/admin/set_admin_password", JSON.stringify(jsonObject), function (data) {
|
||||
|
||||
if (data.result == "error") {
|
||||
doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
|
||||
return;
|
||||
} else {
|
||||
doNotify("Admin password has been set.", "success", "glyphicon glyphicon-ok");
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.location = window.location.pathname;
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
}).fail(function () {
|
||||
doNotify("Request to Jackett server failed", "danger", "glyphicon glyphicon-alert");
|
||||
});
|
||||
});
|
||||
}
|
|
@ -3,9 +3,7 @@
|
|||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
|
||||
|
||||
<script src="/libs/jquery.min.js"></script>
|
||||
<script src="/libs/jquery.dataTables.min.js"></script>
|
||||
<script src="/libs/handlebars.min.js"></script>
|
||||
|
@ -20,7 +18,83 @@
|
|||
<link href="/custom.css" rel="stylesheet">
|
||||
<link href="/css/jquery.dataTables.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
||||
<title>Jackett</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
|
||||
<img id="logo" src="/jacket_medium.png" /><span id="header-title">Jackett</span>
|
||||
|
||||
<div class="pull-right jackett-apikey">
|
||||
<span class="input-header">API Key: </span>
|
||||
<input id="api-key-input" class="form-control input-right" type="text" value="" placeholder="API Key" readonly="">
|
||||
</div>
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button id="jackett-show-search" class="btn btn-success btn-sm">
|
||||
<i class="fa fa-search"></i> Manual Search <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button id="jackett-show-releases" class="btn btn-primary btn-sm">
|
||||
<i class="fa fa-database"></i> View cached releases <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<h3>Configured Indexers</h3>
|
||||
<div id="indexers"> </div>
|
||||
<hr />
|
||||
|
||||
<div class="input-area">
|
||||
<h4>Adding a Jackett indexer in Sonarr</h4>
|
||||
<ol>
|
||||
<li>Go to <b>Settings > Indexers > Add > Torznab > Custom</b>.</li>
|
||||
<li>For <b>URL</b> enter the <b>Torznab Host</b> of one of the indexers.</li>
|
||||
<li>For the <b>API key</b> using the key below.</li>
|
||||
</ol>
|
||||
<h4>Adding a Jackett indexer in Couchpoato</h4>
|
||||
<ol>
|
||||
<li>Go to <b>Settings > Searchers</b>.</li>
|
||||
<li>Enable <b>TorrentPotato</b> and in the host field enter the <b>TorrentPotato host</b> of one of the indexers.</li>
|
||||
<li>For the <b>Passkey</b> use the <b>API key</b>. Leave username blank.</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<h3>Jackett Configuration</h3>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Admin Password: </span>
|
||||
<input id="jackett-adminpwd" class="form-control input-right" type="password" value="" placeholder="Blank to disable" />
|
||||
<button id="change-jackett-password" class="btn btn-primary btn-sm">
|
||||
<i class="fa fa-user-secret"></i> Set Password <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<a href="Dashboard?logout=true" id="logoutBtn" style="display:none" class="btn btn-danger btn-sm">
|
||||
Logout
|
||||
</a>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Server port: </span>
|
||||
<input id="jackett-port" class="form-control input-right" type="text" value="" placeholder="9117">
|
||||
<button id="change-jackett-port" class="btn btn-primary btn-sm">
|
||||
<i class="fa fa-wrench"></i> Apply server settings <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button id="view-jackett-logs" class="btn btn-danger btn-sm">
|
||||
<i class="fa fa-rss"></i> View logs <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Manual download blackhole directory: </span>
|
||||
<input id="jackett-savedir" class="form-control input-right" type="text" value="" placeholder="c:\torrents\">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">External access: </span>
|
||||
<input id="jackett-allowext" class="form-control input-right" type="checkbox" />
|
||||
</div>
|
||||
<hr />
|
||||
<div id="footer">
|
||||
Jackett Version <span id="app-version"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modals"></div>
|
||||
<div id="unconfigured-indexers-template"></div>
|
||||
|
||||
<script id="setup-item-nonlocalrecaptcha" type="text/x-handlebars-template">
|
||||
<div class="setup-item-recaptcha">
|
||||
|
@ -115,7 +189,7 @@
|
|||
<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">Releases</h4>
|
||||
<h4 class="modal-title">Cached Releases</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>This screen shows releases which have been recently returned from Jackett. Only the last 300 releases for each tracker are returned.</p>
|
||||
|
@ -185,7 +259,7 @@
|
|||
<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">Metasearch</h4>
|
||||
<h4 class="modal-title">Manual search</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>You can search all configured indexers from this screen.</p>
|
||||
|
@ -200,7 +274,7 @@
|
|||
{{/each}}
|
||||
</select>
|
||||
<button id="jackett-search-perform" class="btn btn-success btn-sm">
|
||||
Search trackers<span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
<i class="fa fa-search"></i> Search trackers<span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div id="searchResults"></div>
|
||||
</div>
|
||||
|
@ -213,7 +287,7 @@
|
|||
</script>
|
||||
|
||||
<script id="jackett-search-results" type="text/x-handlebars-template">
|
||||
<hr/>
|
||||
<hr />
|
||||
<p>Your search was done using: {{#each Indexers}}{{this}}, {{/each}}</p>
|
||||
<table class="dataTable compact cell-border hover stripe">
|
||||
<thead>
|
||||
|
@ -261,6 +335,25 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
</script>
|
||||
<script id="select-indexer" type="text/x-handlebars-template">
|
||||
<div id="select-indexer-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<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">Select an indexer to setup</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="unconfigured-indexers">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="jackett-logs" type="text/x-handlebars-template">
|
||||
<div id="select-indexer-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
|
@ -337,7 +430,7 @@
|
|||
</div>
|
||||
</script>
|
||||
<script id="add-indexer" type="text/x-handlebars-template">
|
||||
<button class="indexer card add-indexer" data-toggle="modal" data-target="#select-indexer-modal">
|
||||
<button class="indexer card add-indexer" data-toggle="modal">
|
||||
<div class="indexer-add-content">
|
||||
<span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
<div class="light-text">Add</div>
|
||||
|
@ -348,92 +441,6 @@
|
|||
<span class="spinner glyphicon glyphicon-refresh"></span>
|
||||
</script>
|
||||
|
||||
<title>Jackett</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
|
||||
<img id="logo" src="/jacket_medium.png" /><span id="header-title">Jackett</span>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="input-area">
|
||||
<h4>Adding a Jackett indexer in Sonarr</h4>
|
||||
<ol>
|
||||
<li>In Sonarr go to <b>Settings > Indexers > Add > Torznab > Custom</b></li>
|
||||
<li>For <b>URL</b> enter the <b>Torznab Host</b> of one of the indexers below</li>
|
||||
<li>For <b>API key</b> using the key below</li>
|
||||
</ol>
|
||||
<span class="input-header">API Key: </span>
|
||||
<input id="api-key-input" class="form-control input-right" type="text" value="" placeholder="API Key" readonly="">
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button id="jackett-show-search" class="btn btn-success btn-sm">
|
||||
Metasearch <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button id="jackett-show-releases" class="btn btn-primary btn-sm">
|
||||
View cached releases <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<h3>Configured Indexers</h3>
|
||||
<div id="indexers"> </div>
|
||||
<hr />
|
||||
<h3>Jackett Configuration</h3>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Admin Password: </span>
|
||||
<input id="jackett-adminpwd" class="form-control input-right" type="password" value="" placeholder="Blank to disable" />
|
||||
<button id="change-jackett-password" class="btn btn-primary btn-sm">
|
||||
Set Password <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<a href="Dashboard?logout=true" id="logoutBtn" style="display:none" class="btn btn-danger btn-sm">
|
||||
Logout
|
||||
</a>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Server port: </span>
|
||||
<input id="jackett-port" class="form-control input-right" type="text" value="" placeholder="9117">
|
||||
<button id="change-jackett-port" class="btn btn-primary btn-sm">
|
||||
Apply server settings <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button id="view-jackett-logs" class="btn btn-danger btn-sm">
|
||||
View logs <span class="glyphicon glyphicon-ok-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Manual download blackhole directory: </span>
|
||||
<input id="jackett-savedir" class="form-control input-right" type="text" value="" placeholder="c:\torrents\">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">External access: </span>
|
||||
<input id="jackett-allowext" class="form-control input-right" type="checkbox" />
|
||||
</div>
|
||||
<hr />
|
||||
<div id="footer">
|
||||
Jackett Version <span id="app-version"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="select-indexer-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<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">Select an indexer to setup</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="unconfigured-indexers">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modals"></div>
|
||||
<script src="/custom.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -453,21 +453,27 @@ namespace Jackett.Controllers
|
|||
|
||||
Parallel.ForEach(trackers.ToList(), indexer =>
|
||||
{
|
||||
var searchResults = indexer.PerformQuery(query).Result;
|
||||
cacheService.CacheRssResults(indexer, searchResults);
|
||||
searchResults = indexer.FilterResults(query, searchResults);
|
||||
try {
|
||||
var searchResults = indexer.PerformQuery(query).Result;
|
||||
cacheService.CacheRssResults(indexer, searchResults);
|
||||
searchResults = indexer.FilterResults(query, searchResults);
|
||||
|
||||
lock (results)
|
||||
{
|
||||
foreach (var result in searchResults)
|
||||
lock (results)
|
||||
{
|
||||
var item = Mapper.Map<TrackerCacheResult>(result);
|
||||
item.Tracker = indexer.DisplayName;
|
||||
item.TrackerId = indexer.ID;
|
||||
item.Peers = item.Peers - item.Seeders; // Use peers as leechers
|
||||
results.Add(item);
|
||||
foreach (var result in searchResults)
|
||||
{
|
||||
var item = Mapper.Map<TrackerCacheResult>(result);
|
||||
item.Tracker = indexer.DisplayName;
|
||||
item.TrackerId = indexer.ID;
|
||||
item.Peers = item.Peers - item.Seeders; // Use peers as leechers
|
||||
results.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
logger.Error(e, "An error occured during manual search on " + indexer.DisplayName + ": " + e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
ConfigureCacheResults(results);
|
||||
|
|
|
@ -112,26 +112,33 @@ namespace Jackett.Indexers
|
|||
};
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, SearchUrl, SiteLink);
|
||||
|
||||
// Get RSS key
|
||||
var rssParams = new Dictionary<string, string> {
|
||||
{ "feedtype", "download" },
|
||||
{ "timezone", "0" },
|
||||
{ "showrows", "50" }
|
||||
};
|
||||
|
||||
var rssPage = await PostDataWithCookies(GetRSSKeyUrl, rssParams, result.Cookies);
|
||||
var match = Regex.Match(rssPage.Content, "(?<=secret_key\\=)([a-zA-z0-9]*)");
|
||||
configData.RSSKey.Value = match.Success ? match.Value : string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(configData.RSSKey.Value))
|
||||
throw new Exception("Failed to get RSS Key");
|
||||
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
CQ dom = result.Content;
|
||||
var errorMessage = dom[".left_side table:eq(0) tr:eq(1)"].Text().Trim().Replace("\n\t", " ");
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
// Get RSS key
|
||||
var rssParams = new Dictionary<string, string> {
|
||||
{ "feedtype", "download" },
|
||||
{ "timezone", "0" },
|
||||
{ "showrows", "50" }
|
||||
};
|
||||
var rssPage = await PostDataWithCookies(GetRSSKeyUrl, rssParams, result.Cookies);
|
||||
var match = Regex.Match(rssPage.Content, "(?<=secret_key\\=)([a-zA-z0-9]*)");
|
||||
configData.RSSKey.Value = match.Success ? match.Value : string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(configData.RSSKey.Value))
|
||||
throw new Exception("Failed to get RSS Key");
|
||||
SaveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
|
|
Loading…
Reference in New Issue