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:
@@ -28,7 +28,7 @@ const generate = async name => {
|
||||
const filePath = path.join(
|
||||
pluginsDir,
|
||||
lang.toLowerCase(),
|
||||
filename.replace(/[\s-\.]+/g, '') + `[${name}].ts`,
|
||||
filename.replace(/[\s-.]+/g, '') + `[${name}].ts`,
|
||||
);
|
||||
fs.writeFileSync(filePath, pluginScript, { encoding: 'utf-8' });
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const folder = dirname(fileURLToPath(import.meta.url));
|
||||
const FilterTypes = {
|
||||
TextInput: 'Text',
|
||||
Picker: 'Picker',
|
||||
@@ -40,12 +42,9 @@ export const generateAll = function () {
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const HotNovelPubTemplate = readFileSync(
|
||||
'./scripts/multisrc/hotnovelpub/template.ts',
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
);
|
||||
const HotNovelPubTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${HotNovelPubTemplate}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { fetchApi } from '@libs/fetch';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export interface HotNovelPubMetadata {
|
||||
id: string;
|
||||
@@ -135,10 +134,7 @@ class HotNovelPubPlugin implements Plugin.PluginBase {
|
||||
return chapterText.replace(/\.copy right hot novel pub/g, '');
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const result: responseSearch = await fetchApi(this.apiSite + '/search', {
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
@@ -162,7 +158,7 @@ class HotNovelPubPlugin implements Plugin.PluginBase {
|
||||
|
||||
return novels;
|
||||
}
|
||||
resolveUrl = (path: string, isNovel?: boolean) => this.site + '/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/' + path;
|
||||
}
|
||||
|
||||
interface responseNovels {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
import defaultSettings from './settings.json' with { type: 'json' };
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const folder = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export const generateAll = function () {
|
||||
return list.map(metadata => {
|
||||
@@ -12,12 +15,9 @@ export const generateAll = function () {
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const IfreedomTemplate = readFileSync(
|
||||
'./scripts/multisrc/ifreedom/template.ts',
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
);
|
||||
const IfreedomTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${IfreedomTemplate}
|
||||
|
||||
@@ -187,7 +187,7 @@ class IfreedomPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
января: 1,
|
||||
февраля: 2,
|
||||
марта: 3,
|
||||
|
||||
@@ -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(
|
||||
`[lightnovelworld] 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/lightnovelworld/template.ts',
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
);
|
||||
const LightNovelWPTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${LightNovelWPTemplate}
|
||||
|
||||
@@ -148,22 +148,19 @@ class LightNovelWorld implements Plugin.PagePlugin {
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio('#chapter-container').html() || '';
|
||||
const chapterText = loadedCheerio('#chapter-container').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}lnsearchlive`;
|
||||
const link = `${this.site}search`;
|
||||
const response = await fetchApi(link).then(r => r.text());
|
||||
const token = parseHTML(response);
|
||||
let verifytoken = token('#novelSearchForm > input').attr('value');
|
||||
const verifytoken = token('#novelSearchForm > input').attr('value');
|
||||
|
||||
let formData = new FormData();
|
||||
const formData = new FormData();
|
||||
formData.append('inputContent', searchTerm);
|
||||
|
||||
const results = await fetchApi(url, {
|
||||
@@ -172,7 +169,7 @@ class LightNovelWorld implements Plugin.PagePlugin {
|
||||
body: formData,
|
||||
}).then(r => r.json());
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
const loadedCheerio = parseHTML(results.resultview);
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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('.');
|
||||
}
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
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(metadata => {
|
||||
let filters = {};
|
||||
try {
|
||||
filters = require(`./filters/${metadata.id}`);
|
||||
metadata.filters = filters.filters;
|
||||
} catch (e) {}
|
||||
return list.map(source => {
|
||||
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(
|
||||
`[madara] Generating: ${metadata.id}${' '.repeat(20 - metadata.id.length)} ${metadata.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
`[madara] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
);
|
||||
return generator(metadata);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const madaraTemplate = readFileSync('./scripts/multisrc/madara/template.ts', {
|
||||
const generator = function generator(source) {
|
||||
const madaraTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${madaraTemplate}
|
||||
const plugin = new MadaraPlugin(${JSON.stringify(metadata)});
|
||||
const plugin = new MadaraPlugin(${JSON.stringify(source)});
|
||||
export default plugin;
|
||||
`.trim();
|
||||
return {
|
||||
lang: metadata.options?.lang || 'English',
|
||||
filename: metadata.sourceName,
|
||||
lang: source.options?.lang || 'English',
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Cheerio, AnyNode, CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
@@ -82,7 +82,7 @@ class MadaraPlugin 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('.');
|
||||
}
|
||||
@@ -203,7 +203,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
let summary =
|
||||
const summary =
|
||||
loadedCheerio('div.summary__content') ||
|
||||
loadedCheerio('#tab-manga-about') ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")').next();
|
||||
@@ -250,7 +250,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(element).find('a').attr('href') || '';
|
||||
const chapterUrl = loadedCheerio(element).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const folder = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
|
||||
export const generateAll = function () {
|
||||
return list.map(metadata => {
|
||||
return list.map(source => {
|
||||
console.log(
|
||||
`[readnovelfull] Generating: ${metadata.id}${' '.repeat(20 - metadata.id.length)}`,
|
||||
`[readnovelfull] Generating: ${source.id}${' '.repeat(20 - source.id.length)}`,
|
||||
);
|
||||
return generator(metadata);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const readNovelFullTemplate = readFileSync(
|
||||
'./scripts/multisrc/readnovelfull/template.ts',
|
||||
{ encoding: 'utf-8' },
|
||||
);
|
||||
const generator = function generator(source) {
|
||||
const readNovelFullTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${readNovelFullTemplate}
|
||||
const plugin = new ReadNovelFullPlugin(${JSON.stringify(metadata)});
|
||||
const plugin = new ReadNovelFullPlugin(${JSON.stringify(source)});
|
||||
export default plugin;
|
||||
`.trim();
|
||||
return {
|
||||
lang: metadata.options?.lang || 'English',
|
||||
filename: metadata.sourceName,
|
||||
lang: source.options?.lang || 'English',
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
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(metadata => {
|
||||
try {
|
||||
const { filters } = require(`./filters/${metadata.id}`);
|
||||
metadata.filters = filters;
|
||||
} catch (e) {}
|
||||
return list.map(source => {
|
||||
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(
|
||||
`[readwn] Generating: ${metadata.id}${' '.repeat(20 - metadata.id.length)} ${metadata.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
`[readwn] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
);
|
||||
return generator(metadata);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const readwnTemplate = readFileSync('./scripts/multisrc/readwn/template.ts', {
|
||||
const generator = function generator(source) {
|
||||
const readwnTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${readwnTemplate}
|
||||
const plugin = new ReadwnPlugin(${JSON.stringify(metadata)});
|
||||
const plugin = new ReadwnPlugin(${JSON.stringify(source)});
|
||||
export default plugin;
|
||||
`.trim();
|
||||
|
||||
return {
|
||||
lang: 'english',
|
||||
filename: metadata.sourceName,
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ async function getFilters(name: string, url: string) {
|
||||
?.replace('-0.html', ''),
|
||||
}),
|
||||
);
|
||||
let nextPage = $('.pagination > li:last-child > a').attr('href');
|
||||
const nextPage = $('.pagination > li:last-child > a').attr('href');
|
||||
if (nextPage) {
|
||||
const allpage = parseInt(nextPage.replace(/[^0-9]/g, '') || '0', 10);
|
||||
for (let pageNo = 0; pageNo < allpage; pageNo++) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
import defaultSettings from './settings.json' with { type: 'json' };
|
||||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const folder = dirname(fileURLToPath(import.meta.url));
|
||||
const FilterTypes = {
|
||||
TextInput: 'Text',
|
||||
Picker: 'Picker',
|
||||
@@ -31,20 +34,20 @@ export const generateAll = function () {
|
||||
}
|
||||
return { ...p, filters: d ? undefined : filters };
|
||||
})
|
||||
.map(metadata => {
|
||||
console.log(`[rulate]: Generating`, metadata.id);
|
||||
return generator(metadata);
|
||||
.map(source => {
|
||||
console.log(`[rulate]: Generating`, source.id);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(metadata) {
|
||||
const rulateTemplate = readFileSync('./scripts/multisrc/rulate/template.ts', {
|
||||
const generator = function generator(source) {
|
||||
const rulateTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${rulateTemplate}
|
||||
const plugin = new RulatePlugin(${JSON.stringify(metadata)
|
||||
const plugin = new RulatePlugin(${JSON.stringify(source)
|
||||
.replace(/"type":"([^"]+)"/g, '"type":FilterTypes.$1')
|
||||
.replace(/\.XCheckbox/g, '.ExcludableCheckboxGroup') //remember to redo
|
||||
.replace(/\.Checkbox/g, '.CheckboxGroup')});
|
||||
@@ -53,7 +56,7 @@ export default plugin;
|
||||
|
||||
return {
|
||||
lang: 'russian',
|
||||
filename: metadata.sourceName,
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -224,7 +224,7 @@ class RulatePlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
'янв.': 1,
|
||||
'февр.': 2,
|
||||
'мар.': 3,
|
||||
|
||||
Reference in New Issue
Block a user