lightnovelwp & novelDeGlace update (#851)

* lightnovelwp:
 - template accepte version increments
 - daotranslate update url

* novel de glace: - fix date parsing failing for single digit day value
This commit is contained in:
Justin COLLON
2024-03-23 04:44:21 +01:00
committed by GitHub
parent 6f0e679ba4
commit a45b859182
3 changed files with 14 additions and 10 deletions
+8 -7
View File
@@ -21,6 +21,12 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{
return (loadedCheerio); return (loadedCheerio);
} }
parseDate(date: string): string {
const monthMapping: { [key: string]: string } = { janvier: "January", fevrier: "February", mars: "March", avril: "April", mai: "May", juin: "June", juillet: "July", aout: "August", septembre: "September", octobre: "October", novembre: "November", decembre: "December"};
const [day, month, year] = date.split(" ");
return dayjs(`${day} ${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]} ${year}`, "D MMMM YYYY").format("YYYY-MM-DD");
}
parseNovels($: CheerioAPI, showLatestNovels: boolean | undefined): Plugin.NovelItem[] { parseNovels($: CheerioAPI, showLatestNovels: boolean | undefined): Plugin.NovelItem[] {
let novels: Plugin.NovelItem[] = []; let novels: Plugin.NovelItem[] = [];
@@ -155,7 +161,6 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{
let chapterName = "" let chapterName = ""
let site = this.site; let site = this.site;
const monthMapping: { [key: string]: string } = { janvier: "January", fevrier: "February", mars: "March", avril: "April", mai: "May", juin: "June", juillet: "July", aout: "August", septembre: "September", octobre: "October", novembre: "November", decembre: "December"};
volumes.each((volumeIndex: number, el) => { volumes.each((volumeIndex: number, el) => {
if (hasMultipleVolumes) if (hasMultipleVolumes)
chapterName = "T." + (volumeIndex + 1) + " "; chapterName = "T." + (volumeIndex + 1) + " ";
@@ -172,12 +177,9 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{
const dateHtml = cheerio.html()?.substring(cheerio.html()?.indexOf("</a>") || 0) || ""; const dateHtml = cheerio.html()?.substring(cheerio.html()?.indexOf("</a>") || 0) || "";
let releaseDate = dateHtml?.substring(dateHtml.indexOf("(") + 1, dateHtml.indexOf(")")) || undefined; let releaseDate = dateHtml?.substring(dateHtml.indexOf("(") + 1, dateHtml.indexOf(")")) || undefined;
if (releaseDate) if (releaseDate)
{
try { try {
const [day, month, year] = releaseDate.split(" "); releaseDate = this.parseDate(releaseDate);
releaseDate = dayjs(`${day} ${monthMapping[month.normalize("NFD").replace(/[\u0300-\u036f]/g, "")]} ${year}`, "DD MMMM YYYY").format("YYYY-MM-DD");
} catch (e) {} } catch (e) {}
}
const chapterUrl = cheerio.find("a").attr("href"); const chapterUrl = cheerio.find("a").attr("href");
if (chapterUrl) if (chapterUrl)
{ {
@@ -217,8 +219,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{
dates.forEach((date, index) => { dates.forEach((date, index) => {
let releaseDate = date; let releaseDate = date;
try { try {
const [day, month, year] = date.split(" "); releaseDate = this.parseDate(date);
releaseDate = dayjs(`${day} ${monthMapping[month.normalize("NFD").replace(/[\u0300-\u036f]/g, "")]} ${year}`, "DD MMMM YYYY").format("YYYY-MM-DD");
} catch (e) {} } catch (e) {}
const chapter: Plugin.ChapterItem = { const chapter: Plugin.ChapterItem = {
name: newChapterName + " (" + (index + 1) + ")", name: newChapterName + " (" + (index + 1) + ")",
+3 -2
View File
@@ -46,11 +46,12 @@
}, },
{ {
"id": "daotranslate", "id": "daotranslate",
"sourceSite": "https://daotranslate.com/", "sourceSite": "https://daotranslate.us/",
"sourceName": "DaoTranslate", "sourceName": "DaoTranslate",
"options": { "options": {
"lang": "English", "lang": "English",
"reverseChapters": true "reverseChapters": true,
"versionIncrements": 1
} }
}, },
{ {
+3 -1
View File
@@ -8,6 +8,7 @@ import { Filters } from "@libs/filterInputs";
interface LightNovelWPOptions { interface LightNovelWPOptions {
reverseChapters?: boolean; reverseChapters?: boolean;
lang?: string; lang?: string;
versionIncrements?: number;
} }
export interface LightNovelWPMetadata { export interface LightNovelWPMetadata {
@@ -32,7 +33,8 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
this.name = metadata.sourceName; this.name = metadata.sourceName;
this.icon = `multisrc/lightnovelwp/${metadata.id}.png`; this.icon = `multisrc/lightnovelwp/${metadata.id}.png`;
this.site = metadata.sourceSite; this.site = metadata.sourceSite;
this.version = "1.0.4"; const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.0.${4 + versionIncrements}`;
this.options = metadata.options; this.options = metadata.options;
this.filters = metadata.filters satisfies Filters; this.filters = metadata.filters satisfies Filters;
} }