@@ -691,8 +691,11 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
No extra categories found
+
+ Enable provider for categories
+
- Loading categories...
+ Loading categories...
diff --git a/gui/slick/interfaces/default/inc_top.tmpl b/gui/slick/interfaces/default/inc_top.tmpl
index 44448072..a3f4171b 100644
--- a/gui/slick/interfaces/default/inc_top.tmpl
+++ b/gui/slick/interfaces/default/inc_top.tmpl
@@ -74,7 +74,7 @@
diff --git a/gui/slick/js/configProviders.js b/gui/slick/js/configProviders.js
index e15a2e4f..00e0703c 100644
--- a/gui/slick/js/configProviders.js
+++ b/gui/slick/js/configProviders.js
@@ -1,610 +1,572 @@
+/** @namespace $.SickGear.Root */
+/** @namespace $.SickGear.anonURL */
$(document).ready(function(){
- $.sgd = !1;
- $.fn.showHideProviders = function() {
- $('.providerDiv').each(function(){
- var providerName = $(this).attr('id');
- var selectedProvider = $('#editAProvider :selected').val();
- if (selectedProvider + 'Div' == providerName) {
- $(this).show();
- } else {
- $(this).hide();
- }
- });
- }
+ $.sgd = !1;
- /**
- * Gets categories for the provided newznab provider.
- * @param {String} isDefault
- * @param {Array} selectedProvider
- * @return no return data. Function updateNewznabCaps() is run at callback
- */
- $.fn.getCategories = function (isDefault, selectedProvider) {
+ $.fn.showHideProviders = function(){
+ $('.providerDiv').each(function(){
+ var providerName = $(this).attr('id');
+ var selectedProvider = $('#editAProvider').find(':selected').val();
- var name = selectedProvider[0];
- var url = selectedProvider[1];
- var key = selectedProvider[2];
+ if (selectedProvider + 'Div' == providerName){
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
+ });
+ };
- if (!name)
- return;
+ /**
+ * Gets categories for the provided newznab provider.
+ * no return data. Function updateNewznabCaps() is run at callback
+ * @param {String} isNative
+ * @param {Array} selectedProvider
+ * @return
+ */
+ $.fn.getCategories = function(isNative, selectedProvider){
- if (!url)
- return;
+ var name = selectedProvider[0];
+ var url = selectedProvider[1];
+ var key = selectedProvider[2];
- if (!key)
- return;
+ if (!name || !url || !key)
+ return;
- var params = {url: url, name: name, key: key};
- var returnData;
+ var params = {url: url, name: name, key: key};
- $.getJSON(sbRoot + '/config/providers/getNewznabCategories', params,
- function(data){
- updateNewznabCaps( data, selectedProvider );
- });
- }
+ $.getJSON($.SickGear.Root + '/config/providers/getNewznabCategories', params,
+ function(data){
+ updateNewznabCaps(data, selectedProvider);
+ });
+ };
+
+ $.fn.addProvider = function(id, name, url, key, cat, isNative, showProvider){
+
+ url = $.trim(url);
+ if (!url)
+ return;
+
+ if (!/^https?:\/\//i.test(url))
+ url = 'http://' + url;
+
+ url += /[^/]$/.test(url) && '/' || '';
+
+ newznabProviders[id] = [isNative, [name, url, key, cat]];
+
+ if (!isNative){
+ $('#editANewznabProvider').addOption(id, name);
+ $(this).populateNewznabSection();
+ }
+
+ if (0 == $('#provider_order_list > #' + id).length && !1 != showProvider){
+ var toAdd = '
'
+ + ' '
+ + ''
+ + ' '
+ + name + '', prov$ = $('#provider_order_list');
+
+ prov$.append(toAdd);
+ prov$.sortable('refresh');
+ }
+
+ $(this).makeNewznabProviderString();
+ };
+
+ $.fn.addTorrentRssProvider = function(id, name, url, cookies){
+
+ torrentRssProviders[id] = [name, url, cookies];
+
+ $('#editATorrentRssProvider').addOption(id, name);
+ $(this).populateTorrentRssSection();
+
+ if (0 == $('#provider_order_list > #' + id).length){
+ var toAdd = '
'
+ + ' '
+ + ''
+ + ' '
+ + name + '', prov$ = $('#provider_order_list');
+
+ prov$.append(toAdd);
+ prov$.sortable('refresh');
+ }
+
+ $(this).makeTorrentRssProviderString();
+ };
+
+ $.fn.updateProvider = function(id, url, key, cat){
+
+ newznabProviders[id][1][1] = url;
+ newznabProviders[id][1][2] = key;
+ newznabProviders[id][1][3] = cat;
+
+ $(this).populateNewznabSection();
+
+ $(this).makeNewznabProviderString();
+ };
+
+ $.fn.deleteProvider = function(id){
+
+ $('#editANewznabProvider').removeOption(id);
+ delete newznabProviders[id];
+ $(this).populateNewznabSection();
+ $('li').remove('#' + id);
+ $(this).makeNewznabProviderString();
+ };
+
+ $.fn.updateTorrentRssProvider = function(id, url, cookies){
+ torrentRssProviders[id][1] = url;
+ torrentRssProviders[id][2] = cookies;
+ $(this).populateTorrentRssSection();
+ $(this).makeTorrentRssProviderString();
+ };
+
+ $.fn.deleteTorrentRssProvider = function(id){
+ $('#editATorrentRssProvider').removeOption(id);
+ delete torrentRssProviders[id];
+ $(this).populateTorrentRssSection();
+ $('li').remove('#' + id);
+ $(this).makeTorrentRssProviderString();
+ };
+
+ $.fn.populateNewznabSection = function(){
+
+ var data, isNative, rrcat, selectedProvider = $('#editANewznabProvider').find(':selected').val(),
+ nnName$ = $('#newznab_name'), nnCat$ = $('#newznab_cat'), nn$ = $('#newznab_cat, #newznab_cap');
+
+ if ('addNewznab' == selectedProvider){
+ data = ['','',''];
+ isNative = 0;
+ $('#newznab_add_div').show();
+ $('#newznab_update_div').hide();
+ nn$.find('option').each(function(){
+ $(this).remove();
+ });
+ nn$.attr('disabled', 'disabled');
+ } else {
+ data = newznabProviders[selectedProvider][1];
+ isNative = newznabProviders[selectedProvider][0];
+ $('#newznab_add_div').hide();
+ $('#newznab_update_div').show();
+ nn$.removeAttr('disabled');
+ }
+
+ nnName$.val(data[0]);
+ $('#newznab_url').val(data[1]);
+ $('#newznab_key').val(data[2]);
+
+ //Check if not already array
+ rrcat = ('string' === typeof data[3]) ? data[3].split(',') : data[3];
+
+ // Update the category select box (on the right)
+ var newCatOptions = [];
+ if (rrcat){
+ rrcat.forEach(function(cat){
+ newCatOptions.push({text : cat, value : cat});
+ });
+ nnCat$.replaceOptions(newCatOptions);
+ }
+
+ if ('addNewznab' == selectedProvider) {
+
+ $('#newznab_url, #newznab_name').removeAttr('disabled');
+
+ } else {
+
+ nnName$.attr('disabled', 'disabled');
+
+ if (isNative){
+ $('#newznab_url, #newznab_delete').attr('disabled', 'disabled');
+ } else {
+ $('#newznab_url, #newznab_delete').removeAttr('disabled');
+
+ //Get Categories Capabilities
+ if (data[0] && data[1] && data[2] && !ifExists($.fn.newznabProvidersCapabilities, data[0])){
+ $(this).getCategories(isNative, data);
+ } else {
+ updateNewznabCaps(null, data);
+ }
+ }
+ }
+ };
+
+ var ifExists = function(loopThroughArray, searchFor){
+ var found = !1;
+
+ loopThroughArray.forEach(function(rootObject){
+ if (rootObject.name == searchFor){
+ found = !0;
+ }
+ });
+ return found;
+ };
+
+ /**
+ * Updates the Global array $.fn.newznabProvidersCapabilities with a combination of newznab prov name
+ * and category capabilities. Return
+ * @param {Array} newzNabCaps, is the returned object with newzNabprod Name and Capabilities.
+ * @param {Array} selectedProvider
+ * @return no return data. The multiselect input $("#newznab_cap") is updated, as a result.
+ */
+ /** @namespace newzNabCaps.tv_categories */
+ var updateNewznabCaps = function(newzNabCaps, selectedProvider){
+
+ if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])){
+
+ $.fn.newznabProvidersCapabilities.push({
+ 'name' : selectedProvider[0],
+ 'enabled' : newzNabCaps.state,
+ 'categories' : newzNabCaps.tv_categories
+ .sort(function(a, b){return a.name > b.name})})
+ }
+
+ $.sgd && console.log(selectedProvider);
+ //Loop through the array and if currently selected newznab provider name matches one in the array, use it to
+ //update the capabilities select box (on the left).
+ if (selectedProvider[0]){
+ var elShow, newCapOptions = [], catName = '', hasCats = !1, enabled = !1;
+ if ($.fn.newznabProvidersCapabilities.length){
+ $.fn.newznabProvidersCapabilities.forEach(function(newzNabCap){
+ if (newzNabCap.name && newzNabCap.name == selectedProvider[0]) {
+ $.sgd && console.log('newzNabCap...');
+ $.sgd && console.log(newzNabCap);
+ enabled = newzNabCap.enabled;
+
+ if (newzNabCap.categories instanceof Array) {
+ newzNabCap.categories.forEach(function(category_set){
+ if (category_set.id && category_set.name){
+ catName = category_set.name.replace(/Docu([^\w]|$)(.*?)/i, 'Documentary$1');
+ newCapOptions.push({
+ value: category_set.id,
+ text: catName + ' (' + category_set.id + ')'
+ });
+ }
+ });
+ $('#newznab_cap').replaceOptions(newCapOptions);
+ hasCats = !!newCapOptions.length
+ }
+ return !1;
+ }
+ });
+
+ $('#nn-cats, #nn-nocats, #nn-enable-for-cats, #nn-loadcats').removeClass('show').addClass('hide');
+ if (!enabled) {
+ elShow = '#nn-enable-for-cats'
+ } else if (hasCats){
+ elShow = '#nn-cats';
+ } else {
+ elShow = '#nn-nocats';
+ }
+ $.sgd && console.log('for ' + selectedProvider[0] + ' unhide("' + elShow + '")');
+ $(elShow).removeClass('hide').addClass('show');
+
+ } else {
+
+ $.sgd && console.log('no caps - yet');
+ $('#nn-cats, #nn-nocats').removeClass('show').addClass('hide');
+ $('#nn-loadcats').removeClass('hide').addClass('show');
+ }
+ }
+ };
+
+ $.fn.makeNewznabProviderString = function(){
+
+ var provStrings = [];
+
+ for (var id in newznabProviders){
+ provStrings.push(newznabProviders[id][1].join('|'));
+ }
+
+ $('#newznab_string').val(provStrings.join('!!!'))
+ };
+
+ $.fn.populateTorrentRssSection = function(){
+
+ var data, selectedProvider = $('#editATorrentRssProvider').find(':selected').val(),
+ torRSSadd$ = $('#torrentrss_add_div'), torRSSupd$ = $('#torrentrss_update_div'),
+ torRSSname$ = $('#torrentrss_name');
+
+ if ('addTorrentRss' == selectedProvider) {
+ data = ['', '', ''];
+ torRSSadd$.show();
+ torRSSupd$.hide();
+ } else {
+ data = torrentRssProviders[selectedProvider];
+ torRSSadd$.hide();
+ torRSSupd$.show();
+ }
+
+ torRSSname$.val(data[0]);
+ $('#torrentrss_url').val(data[1]);
+ $('#torrentrss_cookies').val(data[2]);
+
+ if ('addTorrentRss' == selectedProvider) {
+ $('#torrentrss_name, #torrentrss_url, #torrentrss_cookies').removeAttr('disabled');
+ } else {
+ torRSSname$.attr('disabled', 'disabled');
+ $('#torrentrss_url, #torrentrss_cookies, #torrentrss_delete').removeAttr('disabled');
+ }
+ };
+
+ $.fn.makeTorrentRssProviderString = function(){
+
+ var provStrings = [];
+ for (var id in torrentRssProviders){
+ provStrings.push(torrentRssProviders[id].join('|'));
+ }
+ $('#torrentrss_string').val(provStrings.join('!!!'))
+ };
+
+
+ $.fn.refreshProviderList = function(){
+ var idArr = $('#provider_order_list').sortable('toArray');
+ var finalArr = [];
+ $.each(idArr, function(key, val){
+ var checked = + $('#enable_' + val).prop('checked') ? '1' : '0';
+ finalArr.push(val + ':' + checked);
+ });
- $.fn.addProvider = function (id, name, url, key, cat, isDefault, showProvider) {
+ $('#provider_order').val(finalArr.join(' '));
+ };
- url = $.trim(url);
- if (!url)
- return;
+ var newznabProviders = [];
+ var torrentRssProviders = [];
- if (!/^https?:\/\//i.test(url))
- url = 'http://' + url;
+ $(this).on('change', '.newznab_key', function(){
- if (url.match('/$') == null)
- url = url + '/';
+ var provider_id = $(this).attr('id');
+ provider_id = provider_id.substring(0, provider_id.length-'_hash'.length);
- var newData = [isDefault, [name, url, key, cat]];
- newznabProviders[id] = newData;
+ var url = $('#' + provider_id + '_url').val();
+ var cat = $('#' + provider_id + '_cat').val();
+ var key = $(this).val();
- if (!isDefault){
- $('#editANewznabProvider').addOption(id, name);
- $(this).populateNewznabSection();
- }
+ $(this).updateProvider(provider_id, url, key, cat);
- if ($('#provider_order_list > #' + id).length == 0 && showProvider != false) {
- var toAdd = '
' + name + ''
+ });
- $('#provider_order_list').append(toAdd);
- $('#provider_order_list').sortable('refresh');
- }
+ $('#newznab_key, #newznab_url').change(function(){
- $(this).makeNewznabProviderString();
+ var selectedProvider = $('#editANewznabProvider').find(':selected').val();
- }
+ if ('addNewznab' == selectedProvider)
+ return;
- $.fn.addTorrentRssProvider = function (id, name, url, cookies) {
+ var url = $('#newznab_url').val(),
+ key = $('#newznab_key').val(),
+ cat = $('#newznab_cat').find('option').map(function(i, opt){
+ return $(opt).text();
+ }).toArray().join(',');
- var newData = [name, url, cookies];
- torrentRssProviders[id] = newData;
-
- $('#editATorrentRssProvider').addOption(id, name);
- $(this).populateTorrentRssSection();
-
- if ($('#provider_order_list > #' + id).length == 0) {
- var toAdd = '
' + name + ''
-
- $('#provider_order_list').append(toAdd);
- $('#provider_order_list').sortable('refresh');
- }
-
- $(this).makeTorrentRssProviderString();
-
- }
-
- $.fn.updateProvider = function (id, url, key, cat) {
-
- newznabProviders[id][1][1] = url;
- newznabProviders[id][1][2] = key;
- newznabProviders[id][1][3] = cat;
-
- $(this).populateNewznabSection();
-
- $(this).makeNewznabProviderString();
-
- }
-
- $.fn.deleteProvider = function (id) {
-
- $('#editANewznabProvider').removeOption(id);
- delete newznabProviders[id];
- $(this).populateNewznabSection();
- $('li').remove('#' + id);
- $(this).makeNewznabProviderString();
-
- }
-
- $.fn.updateTorrentRssProvider = function (id, url, cookies) {
- torrentRssProviders[id][1] = url;
- torrentRssProviders[id][2] = cookies;
- $(this).populateTorrentRssSection();
- $(this).makeTorrentRssProviderString();
- }
-
- $.fn.deleteTorrentRssProvider = function (id) {
- $('#editATorrentRssProvider').removeOption(id);
- delete torrentRssProviders[id];
- $(this).populateTorrentRssSection();
- $('li').remove('#' + id);
- $(this).makeTorrentRssProviderString();
- }
-
- $.fn.populateNewznabSection = function() {
-
- var selectedProvider = $('#editANewznabProvider :selected').val();
-
- if (selectedProvider == 'addNewznab') {
- var data = ['','',''];
- var isDefault = 0;
- $('#newznab_add_div').show();
- $('#newznab_update_div').hide();
- $('#newznab_cat').attr('disabled','disabled');
- $('#newznab_cap').attr('disabled','disabled');
-
- $('#newznab_cat option').each(function() {
- $(this).remove();
- return;
- });
-
- $('#newznab_cap option').each(function() {
- $(this).remove();
- return;
- });
-
- } else {
- var data = newznabProviders[selectedProvider][1];
- var isDefault = newznabProviders[selectedProvider][0];
- $('#newznab_add_div').hide();
- $('#newznab_update_div').show();
- $('#newznab_cat').removeAttr('disabled');
- $('#newznab_cap').removeAttr('disabled');
- }
-
- $('#newznab_name').val(data[0]);
- $('#newznab_url').val(data[1]);
- $('#newznab_key').val(data[2]);
-
- //Check if not already array
- if (typeof data[3] === 'string') {
- rrcat = data[3].split(',')
- }
- else {
- rrcat = data[3];
- }
-
- // Update the category select box (on the right)
- var newCatOptions = [];
- if (rrcat) {
- rrcat.forEach(function (cat) {
- newCatOptions.push({text : cat, value : cat});
- });
- $('#newznab_cat').replaceOptions(newCatOptions);
- };
-
- if (selectedProvider == 'addNewznab') {
- $('#newznab_name').removeAttr('disabled');
- $('#newznab_url').removeAttr('disabled');
- } else {
-
- $('#newznab_name').attr('disabled', 'disabled');
-
- if (isDefault) {
- $('#newznab_url').attr('disabled', 'disabled');
- $('#newznab_delete').attr('disabled', 'disabled');
- } else {
- $('#newznab_url').removeAttr('disabled');
- $('#newznab_delete').removeAttr('disabled');
-
- //Get Categories Capabilities
- if (data[0] && data[1] && data[2] && !ifExists($.fn.newznabProvidersCapabilities, data[0])) {
- $(this).getCategories(isDefault, data);
- }
- else {
- updateNewznabCaps( null, data );
- }
- }
- }
- }
-
- ifExists = function(loopThroughArray, searchFor) {
- var found = false;
-
- loopThroughArray.forEach(function(rootObject) {
- if (rootObject.name == searchFor) {
- found = true;
- }
- });
- return found;
- };
-
- /**
- * Updates the Global array $.fn.newznabProvidersCapabilities with a combination of newznab prov name
- * and category capabilities. Return
- * @param {Array} newzNabCaps, is the returned object with newzNabprod Name and Capabilities.
- * @param {Array} selectedProvider
- * @return no return data. The multiselect input $("#newznab_cap") is updated, as a result.
- */
- updateNewznabCaps = function( newzNabCaps, selectedProvider ) {
-
- if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])) {
-
- $.fn.newznabProvidersCapabilities.push({
- 'name' : selectedProvider[0],
- 'categories' : newzNabCaps.tv_categories
- .sort(function(a, b){return a.name > b.name})})
- }
- $.sgd && console.log(selectedProvider);
- //Loop through the array and if currently selected newznab provider name matches one in the array, use it to
- //update the capabilities select box (on the left).
- if (selectedProvider[0]) {
- var newCapOptions = [], catName = '', hasCats = false;
- if ($.fn.newznabProvidersCapabilities.length) {
- $.fn.newznabProvidersCapabilities.forEach(function (newzNabCap) {
- $.sgd && console.log('array found:' + (newzNabCap.categories instanceof Array ? 'yes': 'no'));
-
- if (newzNabCap.name && newzNabCap.name == selectedProvider[0] && newzNabCap.categories instanceof Array) {
- newzNabCap.categories.forEach(function (category_set) {
- if (category_set.id && category_set.name) {
- catName = category_set.name.replace(/Docu([^\w]|$)(.*?)/i, 'Documentary$1');
- newCapOptions.push({
- value: category_set.id,
- text: catName + ' (' + category_set.id + ')'
- });
- }
- });
- $('#newznab_cap').replaceOptions(newCapOptions);
- hasCats = !!newCapOptions.length
- }
- });
- $('#nn-loadcats').removeClass('show').addClass('hide');
- if (hasCats) {
- $.sgd && console.log('hasCats');
- $('#nn-nocats').removeClass('show').addClass('hide');
- $('#nn-cats').removeClass('hide').addClass('show');
- } else {
- $.sgd && console.log('noCats');
- $('#nn-cats').removeClass('show').addClass('hide');
- $('#nn-nocats').removeClass('hide').addClass('show');
- }
- } else {
- $.sgd && console.log('errCats');
- // error - no caps
- $('#nn-cats').removeClass('show').addClass('hide');
- $('#nn-nocats').removeClass('show').addClass('hide');
- $('#nn-loadcats').removeClass('hide').addClass('show');
- }
- }
- }
-
- $.fn.makeNewznabProviderString = function() {
-
- var provStrings = new Array();
-
- for (var id in newznabProviders) {
- provStrings.push(newznabProviders[id][1].join('|'));
- }
-
- $('#newznab_string').val(provStrings.join('!!!'))
-
- }
-
- $.fn.populateTorrentRssSection = function() {
-
- var selectedProvider = $('#editATorrentRssProvider :selected').val();
-
- if (selectedProvider == 'addTorrentRss') {
- var data = ['','',''];
- $('#torrentrss_add_div').show();
- $('#torrentrss_update_div').hide();
- } else {
- var data = torrentRssProviders[selectedProvider];
- $('#torrentrss_add_div').hide();
- $('#torrentrss_update_div').show();
- }
-
- $('#torrentrss_name').val(data[0]);
- $('#torrentrss_url').val(data[1]);
- $('#torrentrss_cookies').val(data[2]);
-
- if (selectedProvider == 'addTorrentRss') {
- $('#torrentrss_name').removeAttr('disabled');
- $('#torrentrss_url').removeAttr('disabled');
- $('#torrentrss_cookies').removeAttr('disabled');
- } else {
- $('#torrentrss_name').attr('disabled', 'disabled');
- $('#torrentrss_url').removeAttr('disabled');
- $('#torrentrss_cookies').removeAttr('disabled');
- $('#torrentrss_delete').removeAttr('disabled');
- }
-
- }
-
- $.fn.makeTorrentRssProviderString = function() {
-
- var provStrings = new Array();
- for (var id in torrentRssProviders) {
- provStrings.push(torrentRssProviders[id].join('|'));
- }
-
- $('#torrentrss_string').val(provStrings.join('!!!'))
-
- }
-
-
- $.fn.refreshProviderList = function() {
- var idArr = $('#provider_order_list').sortable('toArray');
- var finalArr = new Array();
- $.each(idArr, function(key, val) {
- var checked = + $('#enable_' + val).prop('checked') ? '1' : '0';
- finalArr.push(val + ':' + checked);
- });
+ $(this).updateProvider(selectedProvider, url, key, cat);
- $('#provider_order').val(finalArr.join(' '));
- }
+ });
- var newznabProviders = new Array();
- var torrentRssProviders = new Array();
+ $('#torrentrss_url, #torrentrss_cookies').change(function(){
- $(this).on('change', '.newznab_key', function(){
+ var selectedProvider = $('#editATorrentRssProvider').find(':selected').val();
- var provider_id = $(this).attr('id');
- provider_id = provider_id.substring(0, provider_id.length-'_hash'.length);
+ if ('addTorrentRss' == selectedProvider)
+ return;
- var url = $('#' + provider_id + '_url').val();
- var cat = $('#' + provider_id + '_cat').val();
- var key = $(this).val();
+ var url = $('#torrentrss_url').val(),
+ cookies = $('#torrentrss_cookies').val();
- $(this).updateProvider(provider_id, url, key, cat);
+ $(this).updateTorrentRssProvider(selectedProvider, url, cookies);
+ });
- });
- $('#newznab_key,#newznab_url').change(function(){
+ $('#editAProvider').change(function(){
+ $(this).showHideProviders();
+ });
- var selectedProvider = $('#editANewznabProvider :selected').val();
+ $('#editANewznabProvider').change(function(){
+ $(this).populateNewznabSection();
+ });
- if (selectedProvider == 'addNewznab')
- return;
+ $('#editATorrentRssProvider').change(function(){
+ $(this).populateTorrentRssSection();
+ });
- var url = $('#newznab_url').val();
- var key = $('#newznab_key').val();
+ $(this).on('click', '.provider_enabler', function(){
+ $(this).refreshProviderList();
+ });
- var cat = $('#newznab_cat option').map(function(i, opt) {
- return $(opt).text();
- }).toArray().join(',');
+ $(this).on('click', '#newznab_cat_update', function(){
- $(this).updateProvider(selectedProvider, url, key, cat);
+ var nnCat$ = $('#newznab_cat');
+ //Maybe check if there is anything selected?
+ nnCat$.find('option').each(function(){
+ $(this).remove();
+ });
- });
+ var newOptions = [];
- $('#torrentrss_url,#torrentrss_cookies').change(function(){
+ // When the update botton is clicked, loop through the capabilities list
+ // and copy the selected category id's to the category list on the right.
+ $('#newznab_cap').find(':selected').each(function(){
+ var selected_cat = $(this).val();
+ newOptions.push({text: selected_cat, value: selected_cat})
+ });
- var selectedProvider = $('#editATorrentRssProvider :selected').val();
+ nnCat$.replaceOptions(newOptions);
- if (selectedProvider == 'addTorrentRss')
- return;
+ var selectedProvider = $('#editANewznabProvider').find(':selected').val();
+ if ('addNewznab' == selectedProvider)
+ return;
- var url = $('#torrentrss_url').val();
- var cookies = $('#torrentrss_cookies').val();
+ var url = $('#newznab_url').val();
+ var key = $('#newznab_key').val();
- $(this).updateTorrentRssProvider(selectedProvider, url, cookies);
- });
+ var cat = nnCat$.find('option').map(function(i, opt){
+ return $(opt).text();
+ }).toArray().join(',');
+ nnCat$.find('option:not([value])').remove();
- $('#editAProvider').change(function(){
- $(this).showHideProviders();
- });
+ $(this).updateProvider(selectedProvider, url, key, cat);
+ });
- $('#editANewznabProvider').change(function(){
- $(this).populateNewznabSection();
- });
- $('#editATorrentRssProvider').change(function(){
- $(this).populateTorrentRssSection();
- });
+ $('#newznab_add').click(function(){
- $(this).on('click', '.provider_enabler', function(){
- $(this).refreshProviderList();
- });
+ var name = $.trim($('#newznab_name').val());
+ var url = $.trim($('#newznab_url').val());
+ var key = $.trim($('#newznab_key').val());
- $(this).on('click', '#newznab_cat_update', function(){
+ var cat = $.trim($('#newznab_cat').find('option').map(function(i, opt){
+ return $(opt).text();}).toArray().join(','));
- //Maybe check if there is anything selected?
- $('#newznab_cat option').each(function() {
- $(this).remove();
- return;
- });
+ if (!name || !url || !key)
+ return;
- var newOptions = [];
+ // send to the form with ajax, get a return value
+ $.getJSON($.SickGear.Root + '/config/providers/canAddNewznabProvider', {name: name},
+ function(data){
+ if (data.error != undefined){
+ alert(data.error);
+ return;
+ }
+ $(this).addProvider(data.success, name, url, key, cat, 0);
+ });
+ });
- // When the update botton is clicked, loop through the capabilities list
- // and copy the selected category id's to the category list on the right.
- $('#newznab_cap option').each(function(){
- if($(this).attr('selected') == 'selected')
- {
- var selected_cat = $(this).val();
- newOptions.push({text: selected_cat, value: selected_cat})
- };
- });
+ $('.newznab_delete').click(function(){
- $('#newznab_cat').replaceOptions(newOptions);
+ var selectedProvider = $('#editANewznabProvider').find(':selected').val();
+ $(this).deleteProvider(selectedProvider);
+ });
- var selectedProvider = $('#editANewznabProvider :selected').val();
- if (selectedProvider == 'addNewznab')
- return;
+ $('#torrentrss_add').click(function(){
- var url = $('#newznab_url').val();
- var key = $('#newznab_key').val();
+ var name = $('#torrentrss_name').val();
+ var url = $('#torrentrss_url').val();
+ var cookies = $('#torrentrss_cookies').val();
+ var params = { name: name, url: url, cookies: cookies};
- var cat = $('#newznab_cat option').map(function(i, opt) {
- return $(opt).text();
- }).toArray().join(',');
+ // send to the form with ajax, get a return value
+ $.getJSON($.SickGear.Root + '/config/providers/canAddTorrentRssProvider', params,
+ function(data){
+ if (data.error != undefined){
+ alert(data.error);
+ return;
+ }
+ $(this).addTorrentRssProvider(data.success, name, url, cookies);
+ });
+ });
- $('#newznab_cat option:not([value])').remove();
+ $('.torrentrss_delete').on('click', function(){
+ var selectedProvider = $('#editATorrentRssProvider').find(':selected').val();
+ $(this).deleteTorrentRssProvider(selectedProvider);
+ });
- $(this).updateProvider(selectedProvider, url, key, cat);
- });
+ $(this).on('change', '[class="providerDiv_tip"] input', function(){
+ $('div .providerDiv ' + '[name=' + $(this).attr('name') + ']').replaceWith($(this).clone());
+ $('div .providerDiv ' + '[newznab_name=' + $(this).attr('id') + ']').replaceWith($(this).clone());
+ });
+ $(this).on('change', '[class="providerDiv_tip"] select', function(){
- $('#newznab_add').click(function(){
+ $(this).find('option').each(function(){
+ if ($(this).is(':selected')){
+ $(this).prop('defaultSelected', !0)
+ } else {
+ $(this).prop('defaultSelected', !1);
+ }
+ });
- var selectedProvider = $('#editANewznabProvider :selected').val();
+ $('div .providerDiv ' + '[name=' + $(this).attr('name') + ']').empty().replaceWith($(this).clone())});
- var name = $.trim($('#newznab_name').val());
- var url = $.trim($('#newznab_url').val());
- var key = $.trim($('#newznab_key').val());
- //var cat = $.trim($('#newznab_cat').val());
+ $(this).on('change', '.enabler', function(){
+ if ($(this).is(':checked')){
+ $('.content_' + $(this).attr('id')).each(function(){
+ $(this).show()
+ })
+ } else {
+ $('.content_' + $(this).attr('id')).each(function(){
+ $(this).hide()
+ })
+ }
+ });
- var cat = $.trim($('#newznab_cat option').map(function(i, opt) {
- return $(opt).text();}).toArray().join(','));
+ $('.enabler').each(function(){
+ if (!$(this).is(':checked')){
+ $('.content_' + $(this).attr('id')).hide();
+ } else {
+ $('.content_' + $(this).attr('id')).show();
+ }
+ });
+ $.fn.makeTorrentOptionString = function(provider_id){
- if (!name)
- return;
+ var seed_ratio = $('.providerDiv_tip #' + provider_id + '_seed_ratio').prop('value');
+ var seed_time = $('.providerDiv_tip #' + provider_id + '_seed_time').prop('value');
+ var process_met = $('.providerDiv_tip #' + provider_id + '_process_method').prop('value');
+ var option_string = $('.providerDiv_tip #' + provider_id + '_option_string');
+
+ option_string.val([seed_ratio, seed_time, process_met].join('|'))
+ };
+
+ $(this).on('change', '.seed_option', function(){
+
+ var provider_id = $(this).attr('id').split('_')[0];
+
+ $(this).makeTorrentOptionString(provider_id);
+ });
+
+
+ $.fn.replaceOptions = function(options){
+
+ var self, $option;
+
+ this.empty();
+ self = this;
+
+ $.each(options, function(index, option){
+ $option = $('
')
+ .attr('value', option.value)
+ .text(option.text);
+ self.append($option);
+ });
+ };
- if (!url)
- return;
-
- if (!key)
- return;
-
- var params = {name: name};
-
- // send to the form with ajax, get a return value
- $.getJSON(sbRoot + '/config/providers/canAddNewznabProvider', params,
- function(data){
- if (data.error != undefined) {
- alert(data.error);
- return;
- }
-
- $(this).addProvider(data.success, name, url, key, cat, 0);
- });
-
- });
-
- $('.newznab_delete').click(function(){
-
- var selectedProvider = $('#editANewznabProvider :selected').val();
-
- $(this).deleteProvider(selectedProvider);
-
- });
-
- $('#torrentrss_add').click(function(){
- var selectedProvider = $('#editATorrentRssProvider :selected').val();
-
- var name = $('#torrentrss_name').val();
- var url = $('#torrentrss_url').val();
- var cookies = $('#torrentrss_cookies').val();
- var params = { name: name, url: url, cookies: cookies}
-
- // send to the form with ajax, get a return value
- $.getJSON(sbRoot + '/config/providers/canAddTorrentRssProvider', params,
- function(data){
- if (data.error != undefined) {
- alert(data.error);
- return;
- }
-
- $(this).addTorrentRssProvider(data.success, name, url, cookies);
- });
- });
-
- $('.torrentrss_delete').on('click', function(){
- var selectedProvider = $('#editATorrentRssProvider :selected').val();
- $(this).deleteTorrentRssProvider(selectedProvider);
- });
-
-
- $(this).on('change', '[class="providerDiv_tip"] input', function(){
- $('div .providerDiv ' + '[name=' + $(this).attr('name') + ']').replaceWith($(this).clone());
- $('div .providerDiv ' + '[newznab_name=' + $(this).attr('id') + ']').replaceWith($(this).clone());
- });
-
- $(this).on('change', '[class="providerDiv_tip"] select', function(){
-
- $(this).find('option').each( function() {
- if ($(this).is(':selected')) {
- $(this).prop('defaultSelected', true)
- } else {
- $(this).prop('defaultSelected', false);
- }
- });
-
- $('div .providerDiv ' + '[name=' + $(this).attr('name') + ']').empty().replaceWith($(this).clone())});
-
- $(this).on('change', '.enabler', function(){
- if ($(this).is(':checked')) {
- $('.content_' + $(this).attr('id')).each( function() {
- $(this).show()
- })
- } else {
- $('.content_' + $(this).attr('id')).each( function() {
- $(this).hide()
- })
- }
- });
-
- $('.enabler').each(function(){
- if (!$(this).is(':checked')) {
- $('.content_' + $(this).attr('id')).hide();
- } else {
- $('.content_' + $(this).attr('id')).show();
- }
- });
-
- $.fn.makeTorrentOptionString = function(provider_id) {
-
- var seed_ratio = $('.providerDiv_tip #' + provider_id + '_seed_ratio').prop('value');
- var seed_time = $('.providerDiv_tip #' + provider_id + '_seed_time').prop('value');
- var process_met = $('.providerDiv_tip #' + provider_id + '_process_method').prop('value');
- var option_string = $('.providerDiv_tip #' + provider_id + '_option_string');
-
- option_string.val([seed_ratio, seed_time, process_met].join('|'))
-
- }
-
- $(this).on('change', '.seed_option', function(){
-
- var provider_id = $(this).attr('id').split('_')[0];
-
- $(this).makeTorrentOptionString(provider_id);
-
- });
-
-
- $.fn.replaceOptions = function(options) {
- var self, $option;
-
- this.empty();
- self = this;
-
- $.each(options, function(index, option) {
- $option = $('
')
- .attr('value', option.value)
- .text(option.text);
- self.append($option);
- });
- };
-
- // initialization stuff
-
-
- $.fn.newznabProvidersCapabilities = [];
-
- $(this).showHideProviders();
-
- $('#provider_order_list').sortable({
- placeholder: 'ui-state-highlight',
- update: function (event, ui) {
- $(this).refreshProviderList();
- }
- });
-
- $('#provider_order_list').disableSelection();
+ //
+ // initialization stuff
+ //
+ $.fn.newznabProvidersCapabilities = [];
+
+ $(this).showHideProviders();
+
+ var providers$ = $('#provider_order_list');
+
+ providers$.sortable({
+ placeholder: 'ui-state-highlight',
+ update: function(event, ui){
+ $(this).refreshProviderList();
+ }
+ });
+
+ providers$.disableSelection();
});
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index cbead89e..4460551e 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -5121,7 +5121,9 @@ class ConfigProviders(Config):
return json.dumps({'success': False, 'error': error})
if name in [n.name for n in sickbeard.newznabProviderList if n.url == url]:
- tv_categories = newznab.NewznabProvider.clean_newznab_categories([n for n in sickbeard.newznabProviderList if n.name == name][0].all_cats)
+ provider = [n for n in sickbeard.newznabProviderList if n.name == name][0]
+ tv_categories = newznab.NewznabProvider.clean_newznab_categories(provider.all_cats)
+ state = provider.is_enabled()
else:
providers = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
temp_provider = newznab.NewznabProvider(name, url, key)
@@ -5129,8 +5131,9 @@ class ConfigProviders(Config):
temp_provider.key = providers[temp_provider.get_id()].key
tv_categories = newznab.NewznabProvider.clean_newznab_categories(temp_provider.all_cats)
+ state = False
- return json.dumps({'success': True, 'tv_categories': tv_categories, 'error': ''})
+ return json.dumps({'success': True, 'tv_categories': tv_categories, 'state': state, 'error': ''})
def deleteNewznabProvider(self, nnid):