Advertisement
FirstFire

Add all public Jackett Indexer

Dec 1st, 2020
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////hack to add all free indexers in Jackett
  2. $(document).ready(function () {
  3.     EnableAllUnconfiguredIndexersList();
  4. });
  5.  
  6.  
  7. function EnableAllUnconfiguredIndexersList() {
  8.     var UnconfiguredIndexersDialog = $($("#select-indexer").html());
  9.  
  10.     var indexersTemplate = Handlebars.compile($("#unconfigured-indexer-table").html());
  11.     var indexersTable = $(indexersTemplate({ indexers: unconfiguredIndexers, total_unconfigured_indexers: unconfiguredIndexers.length  }));
  12.     indexersTable.find('.indexer-setup').each(function (i, btn) {
  13.         var indexer = unconfiguredIndexers[i];
  14.         $(btn).click(function () {
  15.             $('#select-indexer-modal').modal('hide').on('hidden.bs.modal', function (e) {
  16.                 displayIndexerSetup(indexer.id, indexer.name, indexer.caps, indexer.link, indexer.alternativesitelinks, indexer.description);
  17.             });
  18.         });
  19.     });
  20.     indexersTable.find('.indexer-add').each(function (i, btn) {
  21.        
  22.             $('#select-indexer-modal').modal('hide').on('hidden.bs.modal', function (e) {
  23.                 var indexerId = $(btn).attr("data-id");
  24.                 api.getIndexerConfig(indexerId, function (data) {
  25.                     if (data.result !== undefined && data.result == "error") {
  26.                         doNotify("Error: " + data.error, "danger", "glyphicon glyphicon-alert");
  27.                         return;
  28.                     }
  29.                     api.updateIndexerConfig(indexerId, data, function (data) {
  30.                         if (data == undefined) {
  31.                             reloadIndexers();
  32.                             doNotify("Successfully configured " + name, "success", "glyphicon glyphicon-ok");
  33.                         } else if (data.result == "error") {
  34.                             if (data.config) {
  35.                                 populateConfigItems(configForm, data.config);
  36.                             }
  37.                             doNotify("Configuration failed: " + data.error, "danger", "glyphicon glyphicon-alert");
  38.                         }
  39.                     }).fail(function (data) {
  40.                         if(data.responseJSON.error !== undefined) {
  41.                 doNotify("An error occured while configuring this indexer<br /><b>" + data.responseJSON.error + "</b><br /><i><a href=\"https://github.com/Jackett/Jackett/issues/new?title=[" + indexerId + "] " + data.responseJSON.error + " (Config)\" target=\"_blank\">Click here to open an issue on GitHub for this indexer.</a><i>", "danger", "glyphicon glyphicon-alert", false);
  42.             } else {
  43.                 doNotify("An error occured while configuring this indexer, is Jackett server running ?", "danger", "glyphicon glyphicon-alert");
  44.             }
  45.                        
  46.                     });
  47.                 });
  48.             });
  49.        
  50.     });
  51.     indexersTable.find("table").DataTable(
  52.         {
  53.             "stateSave": true,
  54.             "fnStateSaveParams": function (oSettings, sValue) {
  55.                 sValue.search.search = ""; // don't save the search filter content
  56.                 return sValue;
  57.             },
  58.             "bAutoWidth": false,
  59.             "pageLength": -1,
  60.             "lengthMenu": [[10, 20, 50, 100, 250, 500, -1], [10, 20, 50, 100, 250, 500, "All"]],
  61.             "order": [[0, "asc"]],
  62.             "columnDefs": [
  63.                 {
  64.                     "name": "name",
  65.                     "targets": 0,
  66.                     "visible": true,
  67.                     "searchable": true,
  68.                     "orderable": true
  69.                 },
  70.                 {
  71.                     "name": "description",
  72.                     "targets": 1,
  73.                     "visible": true,
  74.                     "searchable": true,
  75.                     "orderable": true
  76.                 },
  77.                 {
  78.                     "name": "type",
  79.                     "targets": 2,
  80.                     "visible": true,
  81.                     "searchable": true,
  82.                     "orderable": true
  83.                 },
  84.                 {
  85.                     "name": "type_string",
  86.                     "targets": 3,
  87.                     "visible": false,
  88.                     "searchable": true,
  89.                     "orderable": true,
  90.                 },
  91.                 {
  92.                     "name": "language",
  93.                     "targets": 4,
  94.                     "visible": true,
  95.                     "searchable": true,
  96.                     "orderable": true
  97.                 },
  98.                 {
  99.                     "name": "buttons",
  100.                     "targets": 5,
  101.                     "visible": true,
  102.                     "searchable" : false,
  103.                     "orderable": false
  104.                 }
  105.             ]
  106.         });
  107.  
  108.     var undefindexers = UnconfiguredIndexersDialog.find('#unconfigured-indexers');
  109.     undefindexers.append(indexersTable);
  110.  
  111.     UnconfiguredIndexersDialog.on('shown.bs.modal', function() {
  112.         $(this).find('div.dataTables_filter input').focusWithoutScrolling();
  113.     });
  114.  
  115.     UnconfiguredIndexersDialog.on('hidden.bs.modal', function (e) {
  116.         $('#indexers div.dataTables_filter input').focusWithoutScrolling();
  117.     });
  118.  
  119.     $("#modals").append(UnconfiguredIndexersDialog);
  120.  
  121.     UnconfiguredIndexersDialog.modal("show");
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement