Skip to content

Commit 753e62d

Browse files
committed
added down status to plugins
1 parent 020930e commit 753e62d

8 files changed

Lines changed: 135 additions & 9 deletions

File tree

scripts/json_plugins.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface HostedPluginItem {
4141
version: string;
4242
url: string;
4343
iconUrl: string;
44+
down: boolean;
4445
}
4546

4647
for (let language in languages) {
@@ -52,7 +53,7 @@ for (let language in languages) {
5253
if (plugin.startsWith('.')) return;
5354
minify(path.join(langPath, plugin));
5455
const instance: Plugin.PluginBase = require(
55-
`../plugins/${language.toLowerCase()}/${plugin.split('.')[0]}`,
56+
`../plugins/${language.toLowerCase()}/${plugin.replace('.js', '')}`,
5657
).default;
5758

5859
const { id, name, site, version, icon } = instance;
@@ -66,6 +67,7 @@ for (let language in languages) {
6667
version,
6768
url: `${PLUGIN_LINK}/${language.toLowerCase()}/${plugin}`,
6869
iconUrl: `${ICON_LINK}/${icon || 'siteNotAvailable.png'}`,
70+
down: plugin.endsWith('.down.js'),
6971
};
7072

7173
if (pluginSet.has(id)) {

scripts/multisrc/generate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type GeneratedScript = {
55
lang: string;
66
filename: string;
77
pluginScript: string;
8+
down?: boolean;
89
};
910

1011
export type ScrpitGeneratorFunction = (name: string) => GeneratedScript[];
@@ -21,7 +22,7 @@ const generate = async (name: string): Promise<boolean> => {
2122
if (!isScriptGenerator(generateAll)) return false;
2223
const sources = generateAll(name);
2324
for (let source of sources) {
24-
const { lang, filename, pluginScript } = source;
25+
const { lang, filename, pluginScript, down } = source;
2526
if (!lang || !filename || !pluginScript) {
2627
console.warn(name, ': lang, filename, pluginScript are required!');
2728
continue;
@@ -33,7 +34,8 @@ const generate = async (name: string): Promise<boolean> => {
3334
const filePath = path.join(
3435
pluginsDir,
3536
lang.toLowerCase(),
36-
filename.replace(/[\s-\.]+/g, '') + `[${name}].ts`,
37+
filename.replace(/[\s-\.]+/g, '') +
38+
`[${name}]${down ? '.down' : ''}.ts`,
3739
);
3840
fs.writeFileSync(filePath, pluginScript, { encoding: 'utf-8' });
3941
}

scripts/multisrc/lightnovelwp/generator.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ export const generateAll: ScrpitGeneratorFunction = function (name) {
1212
source.filters = filters.filters;
1313
} catch (e) {}
1414
console.log(
15-
`[${name}] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
15+
`[${name}]`,
16+
'Generating:',
17+
source.id.padEnd(20),
18+
source.options?.down
19+
? '🔽site is down🔽'
20+
: source.filters
21+
? '🔎with filters🔍'
22+
: '🚫 no filters 🚫',
23+
source.options?.downSince ? `since: ${source.options?.downSince}` : '',
1624
);
1725
return generator(source);
1826
});
@@ -39,5 +47,6 @@ export default plugin;
3947
lang: source.options?.lang || 'English',
4048
filename: source.sourceName,
4149
pluginScript,
50+
down: source.options?.down || false,
4251
};
4352
};

scripts/multisrc/lightnovelwp/template.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Filters } from '@libs/filterInputs';
77

88
interface LightNovelWPOptions {
99
reverseChapters?: boolean;
10+
down?: boolean;
11+
downSince?: string;
1012
lang?: string;
1113
versionIncrements?: number;
1214
seriesPath?: string;

scripts/multisrc/madara/generator.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ export const generateAll: ScrpitGeneratorFunction = function (name) {
1313
metadata.filters = filters.filters;
1414
} catch (e) {}
1515
console.log(
16-
`[${name}] Generating: ${metadata.id}${' '.repeat(20 - metadata.id.length)} ${metadata.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
16+
`[${name}]`,
17+
'Generating:',
18+
metadata.id.padEnd(20),
19+
metadata.options?.down
20+
? '🔽site is down🔽'
21+
: metadata.filters
22+
? '🔎with filters🔍'
23+
: '🚫 no filters 🚫',
24+
metadata.options?.downSince
25+
? `since: ${metadata.options?.downSince}`
26+
: '',
1727
);
1828
return generator(metadata);
1929
});
@@ -33,5 +43,6 @@ export default plugin;
3343
lang: metadata.options?.lang || 'English',
3444
filename: metadata.sourceName,
3545
pluginScript,
46+
down: metadata.options?.down,
3647
};
3748
};

scripts/multisrc/madara/sources.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
"useNewChapterEndpoint": true
88
}
99
},
10+
{
11+
"id": "zinnovel",
12+
"sourceSite": "https://zinnovel.com/",
13+
"sourceName": "ZinnNovel",
14+
"options": {
15+
"down": true,
16+
"downSince": "2024-03-04"
17+
}
18+
},
1019
{
1120
"id": "novelTL",
1221
"sourceSite": "https://noveltranslate.com/",
@@ -29,6 +38,15 @@
2938
"useNewChapterEndpoint": true
3039
}
3140
},
41+
{
42+
"id": "freenovel.me",
43+
"sourceSite": "https://freenovel.me/",
44+
"sourceName": "FreeNovelMe",
45+
"options": {
46+
"down": true,
47+
"downSince": "2024-03-04"
48+
}
49+
},
3250
{
3351
"id": "1stkissnovel",
3452
"sourceSite": "https://1stkissnovel.org/",
@@ -89,6 +107,15 @@
89107
"sourceSite": "https://www.webnovelover.com/",
90108
"sourceName": "WebNovelLover"
91109
},
110+
{
111+
"id": "readwebnovels",
112+
"sourceSite": "https://readwebnovels.net/",
113+
"sourceName": "ReadWebNovels",
114+
"options": {
115+
"down": true,
116+
"downSince": "2024-03-04"
117+
}
118+
},
92119
{
93120
"id": "wbnovel",
94121
"sourceSite": "https://wbnovel.com/",
@@ -122,6 +149,16 @@
122149
"lang": "Indonesian"
123150
}
124151
},
152+
{
153+
"id": "onlymtl",
154+
"sourceSite": "https://www.onlymtl.com/",
155+
"sourceName": "OnlyMTL",
156+
"options": {
157+
"useNewChapterEndpoint": true,
158+
"down": true,
159+
"downSince": "2024-03-04"
160+
}
161+
},
125162
{
126163
"id": "hizomanga",
127164
"sourceSite": "https://hizomanga.net/",
@@ -166,6 +203,16 @@
166203
"useNewChapterEndpoint": true
167204
}
168205
},
206+
{
207+
"id": "mtlnovel.club",
208+
"sourceSite": "https://mtlnovel.club/",
209+
"sourceName": "MTLNovel.Club",
210+
"options": {
211+
"useNewChapterEndpoint": true,
212+
"down": true,
213+
"downSince": "2024-03-04"
214+
}
215+
},
169216
{
170217
"id": "guavaread",
171218
"sourceSite": "https://guavaread.com/",
@@ -174,6 +221,26 @@
174221
"useNewChapterEndpoint": true
175222
}
176223
},
224+
{
225+
"id": "sweetEscapeTL",
226+
"sourceSite": "https://sweetescapetranslations.com/",
227+
"sourceName": "Sweet Escape Translations",
228+
"options": {
229+
"useNewChapterEndpoint": false,
230+
"down": true,
231+
"downSince": "2024-03-04"
232+
}
233+
},
234+
{
235+
"id": "novelstic",
236+
"sourceSite": "https://novelstic.com/",
237+
"sourceName": "Novelstic",
238+
"options": {
239+
"useNewChapterEndpoint": true,
240+
"down": true,
241+
"downSince": "2024-03-04"
242+
}
243+
},
177244
{
178245
"id": "neosekaiTLS",
179246
"sourceSite": "https://www.neosekaitranslations.com/",
@@ -193,6 +260,34 @@
193260
"sourceName": "Zetro Translation",
194261
"options": {}
195262
},
263+
{
264+
"id": "nocturneTLS",
265+
"sourceSite": "https://nocturnetls.net/",
266+
"sourceName": "Nocturne Translations",
267+
"options": {
268+
"down": true,
269+
"downSince": "2024-03-04"
270+
}
271+
},
272+
{
273+
"id": "novelroom",
274+
"sourceSite": "https://novelroom.net/",
275+
"sourceName": "Novelroom.net",
276+
"options": {
277+
"down": true,
278+
"downSince": "2024-03-04"
279+
}
280+
},
281+
{
282+
"id": "novelr18",
283+
"sourceSite": "https://novelr18.com/",
284+
"sourceName": "NovelR18",
285+
"options": {
286+
"useNewChapterEndpoint": true,
287+
"down": true,
288+
"downSince": "2024-03-04"
289+
}
290+
},
196291
{
197292
"id": "webnoveloku",
198293
"sourceSite": "https://www.webnoveloku.com/",

scripts/multisrc/madara/template.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const includesAny = (str: string, keywords: string[]) =>
1111

1212
interface MadaraOptions {
1313
useNewChapterEndpoint?: boolean;
14+
down?: boolean;
15+
downSince?: string;
1416
lang?: string;
1517
orderBy?: string;
1618
versionIncrements?: number;
@@ -69,7 +71,12 @@ class MadaraPlugin implements Plugin.PluginBase {
6971
: letter;
7072
})
7173
.join('');
72-
$el.html($el.html()?.replace($el.text(), reversedLetters).replace('\n', '<br>') || '');
74+
$el.html(
75+
$el
76+
.html()
77+
?.replace($el.text(), reversedLetters)
78+
.replace('\n', '<br>') || '',
79+
);
7380
});
7481
}
7582
return text;

test_web/api/plugins.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export const all_plugins = (): PluginList => {
1919
res[languageEnglish] = [];
2020
plugins.forEach(plugin => {
2121
if (plugin.startsWith('.')) return;
22-
const requirePath = `@plugins/${languageEnglish.toLowerCase()}/${
23-
plugin.split('.')[0]
24-
}`;
22+
const requirePath = `@plugins/${languageEnglish.toLowerCase()}/${plugin.replace('.js', '')}`;
2523
const instance = require(requirePath).default;
2624
const { id, name, version, icon } = instance;
2725
const info: Plugin.PluginItem = {

0 commit comments

Comments
 (0)