From 7e3266489f1de09733f63fae2b05b3438ad938dc Mon Sep 17 00:00:00 2001 From: KZ Date: Sun, 16 Aug 2015 18:34:45 +0100 Subject: [PATCH] Fix issue with add indexer not working and rejig the UI a bit. --- src/Jackett/Content/custom.css | 15 +- src/Jackett/Content/custom.js | 613 +++++++++++---------- src/Jackett/Content/index.html | 193 +++---- src/Jackett/Controllers/AdminController.cs | 28 +- src/Jackett/Indexers/TVChaosUK.cs | 35 +- 5 files changed, 462 insertions(+), 422 deletions(-) diff --git a/src/Jackett/Content/custom.css b/src/Jackett/Content/custom.css index e448e7719..9c3f1f019 100644 --- a/src/Jackett/Content/custom.css +++ b/src/Jackett/Content/custom.css @@ -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 */ -} \ No newline at end of file +} + +#unconfigured-indexers-template { + display: none; +} +.jackett-apikey{ + margin-top: 10px; +} + +.jackett-apikey .input-header{ + width: 80px; +} + diff --git a/src/Jackett/Content/custom.js b/src/Jackett/Content/custom.js index 491a9a7b5..5a26e6a8f 100644 --- a/src/Jackett/Content/custom.js +++ b/src/Jackett/Content/custom.js @@ -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 = $('') - .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('') - }); - } - }); - } - }); - $("#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(""); - $.each(cats, function (value, key) { - select.append($("") - .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 = $('') - .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('') - }); - } - }); - } - }); - - }).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 = $('') + .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('') + }); + } + }); + } + }); + $("#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(""); + $.each(cats, function (value, key) { + select.append($("") + .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 = $('') + .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('') + }); + } + }); + } + }); + + }).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"); + }); + }); +} \ No newline at end of file diff --git a/src/Jackett/Content/index.html b/src/Jackett/Content/index.html index b3fb4b5e4..f30aef9fb 100644 --- a/src/Jackett/Content/index.html +++ b/src/Jackett/Content/index.html @@ -3,9 +3,7 @@ - - @@ -20,7 +18,83 @@ + Jackett + + +
+ Jackett + +
+ API Key: + +
+
+
+ + +
+

Configured Indexers

+
+
+ +
+

Adding a Jackett indexer in Sonarr

+
    +
  1. Go to Settings > Indexers > Add > Torznab > Custom.
  2. +
  3. For URL enter the Torznab Host of one of the indexers.
  4. +
  5. For the API key using the key below.
  6. +
+

Adding a Jackett indexer in Couchpoato

+
    +
  1. Go to Settings > Searchers.
  2. +
  3. Enable TorrentPotato and in the host field enter the TorrentPotato host of one of the indexers.
  4. +
  5. For the Passkey use the API key. Leave username blank.
  6. +
+ +
+
+

Jackett Configuration

+
+ Admin Password: + + + +
+
+ Server port: + + + +
+
+ Manual download blackhole directory: + +
+
+ External access: + +
+
+ +
+ +
+
+ - Jackett - - -
- - Jackett - -
- -
-

Adding a Jackett indexer in Sonarr

-
    -
  1. In Sonarr go to Settings > Indexers > Add > Torznab > Custom
  2. -
  3. For URL enter the Torznab Host of one of the indexers below
  4. -
  5. For API key using the key below
  6. -
- API Key: - -
- -
-
- - -
-

Configured Indexers

-
-
-

Jackett Configuration

-
- Admin Password: - - - -
-
- Server port: - - - -
-
- Manual download blackhole directory: - -
-
- External access: - -
-
- -
- - - -
\ No newline at end of file diff --git a/src/Jackett/Controllers/AdminController.cs b/src/Jackett/Controllers/AdminController.cs index 9f64abd7a..47d49fa86 100644 --- a/src/Jackett/Controllers/AdminController.cs +++ b/src/Jackett/Controllers/AdminController.cs @@ -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(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(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); diff --git a/src/Jackett/Indexers/TVChaosUK.cs b/src/Jackett/Indexers/TVChaosUK.cs index b55df89a9..3d42a570b 100644 --- a/src/Jackett/Indexers/TVChaosUK.cs +++ b/src/Jackett/Indexers/TVChaosUK.cs @@ -112,26 +112,33 @@ namespace Jackett.Indexers }; var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, SearchUrl, SiteLink); - - // Get RSS key - var rssParams = new Dictionary { - { "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 { + { "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> PerformQuery(TorznabQuery query)