From a45b85918238f347881022595d6764d10dd0dfa8 Mon Sep 17 00:00:00 2001 From: Justin COLLON <48163201+error7404@users.noreply.github.com> Date: Sat, 23 Mar 2024 04:44:21 +0100 Subject: [PATCH] lightnovelwp & novelDeGlace update (#851) * lightnovelwp: - template accepte version increments - daotranslate update url * novel de glace: - fix date parsing failing for single digit day value --- plugins/french/noveldeglace.ts | 15 ++++++++------- scripts/multisrc/lightnovelwp/sources.json | 5 +++-- scripts/multisrc/lightnovelwp/template.ts | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/french/noveldeglace.ts b/plugins/french/noveldeglace.ts index 37d6911..c04bd5f 100644 --- a/plugins/french/noveldeglace.ts +++ b/plugins/french/noveldeglace.ts @@ -21,6 +21,12 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{ 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[] { let novels: Plugin.NovelItem[] = []; @@ -155,7 +161,6 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{ let chapterName = "" 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) => { if (hasMultipleVolumes) chapterName = "T." + (volumeIndex + 1) + " "; @@ -172,12 +177,9 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{ const dateHtml = cheerio.html()?.substring(cheerio.html()?.indexOf("") || 0) || ""; let releaseDate = dateHtml?.substring(dateHtml.indexOf("(") + 1, dateHtml.indexOf(")")) || undefined; if (releaseDate) - { try { - const [day, month, year] = releaseDate.split(" "); - releaseDate = dayjs(`${day} ${monthMapping[month.normalize("NFD").replace(/[\u0300-\u036f]/g, "")]} ${year}`, "DD MMMM YYYY").format("YYYY-MM-DD"); + releaseDate = this.parseDate(releaseDate); } catch (e) {} - } const chapterUrl = cheerio.find("a").attr("href"); if (chapterUrl) { @@ -217,8 +219,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase{ dates.forEach((date, index) => { let releaseDate = date; try { - const [day, month, year] = date.split(" "); - releaseDate = dayjs(`${day} ${monthMapping[month.normalize("NFD").replace(/[\u0300-\u036f]/g, "")]} ${year}`, "DD MMMM YYYY").format("YYYY-MM-DD"); + releaseDate = this.parseDate(date); } catch (e) {} const chapter: Plugin.ChapterItem = { name: newChapterName + " (" + (index + 1) + ")", diff --git a/scripts/multisrc/lightnovelwp/sources.json b/scripts/multisrc/lightnovelwp/sources.json index 8476f25..89a52dc 100644 --- a/scripts/multisrc/lightnovelwp/sources.json +++ b/scripts/multisrc/lightnovelwp/sources.json @@ -46,11 +46,12 @@ }, { "id": "daotranslate", - "sourceSite": "https://daotranslate.com/", + "sourceSite": "https://daotranslate.us/", "sourceName": "DaoTranslate", "options": { "lang": "English", - "reverseChapters": true + "reverseChapters": true, + "versionIncrements": 1 } }, { diff --git a/scripts/multisrc/lightnovelwp/template.ts b/scripts/multisrc/lightnovelwp/template.ts index ce6de8b..4542453 100644 --- a/scripts/multisrc/lightnovelwp/template.ts +++ b/scripts/multisrc/lightnovelwp/template.ts @@ -8,6 +8,7 @@ import { Filters } from "@libs/filterInputs"; interface LightNovelWPOptions { reverseChapters?: boolean; lang?: string; + versionIncrements?: number; } export interface LightNovelWPMetadata { @@ -32,7 +33,8 @@ class LightNovelWPPlugin implements Plugin.PluginBase { this.name = metadata.sourceName; this.icon = `multisrc/lightnovelwp/${metadata.id}.png`; 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.filters = metadata.filters satisfies Filters; }