Skip to content

Commit

Permalink
filter indexer categories (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaridas authored Jan 30, 2024
1 parent ce1a777 commit 2d5aaf1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/jackett.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ const getIndexers = async (host, apiKey, abortSignals) => {

if (indexers && indexers.elements && indexers.elements[0] && indexers.elements[0].elements) {
indexers = indexers.elements[0].elements;
indexers.forEach((elem, index) => {
if (elem.elements[5].elements[3].elements) {
for (const cat of elem.elements[5].elements[3].elements) {
if (indexers[index].movie && indexers[index].series) {
break; // Exit the loop when both movie and series are found
}
if (!cat.attributes.id) {
continue; // Skip this iteration if cat.attributes.id is falsy
}
if (cat.attributes.id === '2000') {
config.debug && console.log("Found category Movies for: ", indexers[index].attributes.id);
indexers[index].movie = true;
continue;
} else if (cat.attributes.id === '5000') {
config.debug && console.log("Found category TV for: ", indexers[index].attributes.id);
indexers[index].series = true;
continue
}
}
}
});
setCacheVariable(host, indexers, config.cacheIndexersTime);
return indexers;
} else {
Expand Down Expand Up @@ -97,6 +118,11 @@ const search = async (query, abortSignals, cb, end) => {
return;
}

if (!indexer[query.type]) {
config.debug && console.log("Skipping " + indexer.attributes.id + " because it has no category " + query.type);
return;
}

if (searchedIndexers[indexer.attributes.id]) {
config.debug && console.log("Skipping indexer " + indexer.attributes.id + " as we have already searched it from " + host);
return;
Expand Down

0 comments on commit 2d5aaf1

Please sign in to comment.