Add TopLiba (#1003)

* test

* cleanup

deleted unused `fetchFile` import
replaced fetch with `fetchApi`

* eslint

* fix

* fix multi

* Hmm, what to do next.

* test URLSearchParams

* fix
This commit is contained in:
Rider21
2024-06-30 07:28:11 +03:00
committed by GitHub
parent 938e3b16a3
commit fae73534dd
121 changed files with 10534 additions and 8079 deletions
+15 -12
View File
@@ -1,13 +1,19 @@
import list from './sources.json' with { type: 'json' };
import { readFileSync } from 'fs';
import { existsSync, readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const folder = dirname(fileURLToPath(import.meta.url));
export const generateAll = function () {
return list.map(source => {
let filters = {};
try {
filters = require(`./filters/${source.id}`);
source.filters = filters.filters;
} catch (e) {}
const exist = existsSync(join(folder, 'filters', source.id + '.json'));
if (exist) {
const filters = readFileSync(
join(folder, 'filters', source.id + '.json'),
);
source.filters = JSON.parse(filters);
}
console.log(
`[lightnovelwp] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
);
@@ -16,12 +22,9 @@ export const generateAll = function () {
};
const generator = function generator(source) {
const LightNovelWPTemplate = readFileSync(
'./scripts/multisrc/lightnovelwp/template.ts',
{
encoding: 'utf-8',
},
);
const LightNovelWPTemplate = readFileSync(join(folder, 'template.ts'), {
encoding: 'utf-8',
});
const pluginScript = `
${LightNovelWPTemplate.replace(
+1 -1
View File
@@ -44,7 +44,7 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
getHostname(url: string): string {
url = url.split('/')[2];
let url_parts = url.split('.');
const url_parts = url.split('.');
url_parts.pop(); // remove TLD
return url_parts.join('.');
}