From 5ebbae94695291ec02a1a8faf348f99214bd93f9 Mon Sep 17 00:00:00 2001 From: masterhc Date: Sat, 20 Apr 2024 15:36:00 +0100 Subject: [PATCH] Feat: SearchWithExtraInfo: Slower search that returns extra info about the manga like tags and description --- lib.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/lib.js b/lib.js index 8f07d8e..e18dd14 100644 --- a/lib.js +++ b/lib.js @@ -162,6 +162,59 @@ module.exports.Search = class Search } return this.results } + /** + * SLOWER + * @returns {Array} + * @typedef {Object} Results + * @property {Array} Results + * @property {Scanlator} scanlator + * @typedef {Object} Manga + * @property {String} link - Manga Link + * @property {String} title - Manga Title + * @property {String} img - Image Link + * @property {Array} tags - Manga Tags + * @typedef {String} Scanlator + * @pattern /^[\w-]+-scans$/ + */ + async searchExtraInfo() + { + await this.initialized; + if(this.Modules.length==0) return + for(const module of this.Modules) + { + const auxModule = new module() + if(!this.scanlator || this.scanlator == auxModule.scanlator ) + try + { + var results = await auxModule.Search(this.ss); + //TODO: Defaults for missing info from the modules; + // console.log('Lib: Search: search method: result:', result); + for(let i = 0; i { + if (a.title.toUpperCase() < b.title.toUpperCase()) return -1; + else return 1; + }); + for(var i = 0; i< results.length; i++) + { + results[i]['Status'] = results[i].status; + } + this.results.push({ + Results:results, + scanlator:auxModule.scanlator + }); + } + catch (error) + { + console.error('Lib: Module Errored:', auxModule.scanlator, 'Error:', error) + } + } + return this.results + } } module.exports.SearchByTag = class SearchByTag