Refactor findChar to utils

- Refactor and move finChar to utils, instead of slashcommands function
- Refactor scrapers to use actual init functionality
This commit is contained in:
Wolfsblvt
2024-09-29 03:20:01 +02:00
parent edcf52e3a8
commit d7bad6335c
6 changed files with 94 additions and 110 deletions

View File

@@ -13,6 +13,7 @@ import { isValidUrl } from './utils.js';
* @property {string} description
* @property {string} iconClass
* @property {boolean} iconAvailable
* @property {() => Promise<void>} [init=null]
* @property {() => Promise<boolean>} isAvailable
* @property {() => Promise<File[]>} scrape
*/
@@ -42,6 +43,10 @@ export class ScraperManager {
return;
}
if (scraper.init) {
scraper.init();
}
ScraperManager.#scrapers.push(scraper);
}
@@ -462,7 +467,9 @@ class YouTubeScraper {
this.description = 'Download a transcript from a YouTube video.';
this.iconClass = 'fa-brands fa-youtube';
this.iconAvailable = true;
}
async init() {
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'yt-script',
callback: async (args, url) => {
@@ -564,9 +571,11 @@ class YouTubeScraper {
}
}
ScraperManager.registerDataBankScraper(new FileScraper());
ScraperManager.registerDataBankScraper(new Notepad());
ScraperManager.registerDataBankScraper(new WebScraper());
ScraperManager.registerDataBankScraper(new MediaWikiScraper());
ScraperManager.registerDataBankScraper(new FandomScraper());
ScraperManager.registerDataBankScraper(new YouTubeScraper());
export function initScrapers() {
ScraperManager.registerDataBankScraper(new FileScraper());
ScraperManager.registerDataBankScraper(new Notepad());
ScraperManager.registerDataBankScraper(new WebScraper());
ScraperManager.registerDataBankScraper(new MediaWikiScraper());
ScraperManager.registerDataBankScraper(new FandomScraper());
ScraperManager.registerDataBankScraper(new YouTubeScraper());
}