Files
lnreader-plugins/scripts/multisrc/lightnovelwp/generator.ts
T
Justin COLLON 4842366870 Madara rework & Lightnovelwp update (#819)
* fix hizomanga

* added filters for systemtranslation & whitemoonlightnovels

* fix typos in lightnovelwp README

* fix arnovel domain change

* Madra: - added version Increments for sources

* Madara rework:
 - filters in seperate folder
 - added generator for filters
 - added README
 - removed path in sources (getting genres from advanced search)
 - added checking for Captcha errors
 - simplified code
 - better filter management
 - madara/icons/*.png => madara/*.png

* lightnovelwp:
 - better checks for Captcha
 - better log

* madra: - removed console.log

* Madara: - get_filter.ts better log

* Madara added sources:
 - Pancho Translations (SP)
 - Salmon Latte (EN)
 - Asura Light Novel (EN)
 - Fans Translations (EN)
 - Novel Lucky (TH)
 - new Thai language

* freewebnovel:

 - Web NOVEL => Free Web Novel

* Madara:  - icon filename from id instead of name

* Madara: - added filters for new sources
2024-03-07 12:46:29 +07:00

36 lines
1.1 KiB
TypeScript

import { ScrpitGeneratorFunction } from "../generate";
import { LightNovelWPMetadata } from "./template";
import list from "./sources.json";
import { readFileSync } from "fs";
import path from "path";
export const generateAll: ScrpitGeneratorFunction = function (name) {
return list.map((source: LightNovelWPMetadata) => {
let filters: any = {};
try {
filters = require(`./filters/${source.id}`);
source.filters = filters.filters;
} catch (e) {}
console.log(`[${name}] Generating: ${source.id}${" ".repeat(20 - source.id.length)} ${source.filters ? "🔎with filters🔍" : "🚫no filters🚫"}`);
return generator(source);
});
};
const generator = function generator(source: LightNovelWPMetadata) {
const LightNovelWPTemplate = readFileSync(path.join(__dirname, "template.ts"),{
encoding: "utf-8",
});
const pluginScript = `
${LightNovelWPTemplate}
const plugin = new LightNovelWPPlugin(${JSON.stringify(source)});
export default plugin;
`.trim();
return {
lang: source.options?.lang || "English",
filename: source.sourceName,
pluginScript,
};
};