From ead1f937894a70f6abed7364f676fc43a37c3ff9 Mon Sep 17 00:00:00 2001 From: Justin COLLON <48163201+error7404@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:55:24 +0100 Subject: [PATCH] fix: [Madara]: Fix Summary Issue, Genre Separation, and Add Artist (#1290) - fix summary not working for some sources (closes #1257) - fix genres not being separated - added artist --- scripts/multisrc/madara/template.ts | 60 +++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/scripts/multisrc/madara/template.ts b/scripts/multisrc/madara/template.ts index 0078745..c3a457c 100644 --- a/scripts/multisrc/madara/template.ts +++ b/scripts/multisrc/madara/template.ts @@ -39,7 +39,7 @@ class MadaraPlugin implements Plugin.PluginBase { this.icon = `multisrc/madara/${metadata.id.toLowerCase()}/icon.png`; this.site = metadata.sourceSite; const versionIncrements = metadata.options?.versionIncrements || 0; - this.version = `1.0.${4 + versionIncrements}`; + this.version = `1.0.${5 + versionIncrements}`; this.options = metadata.options; this.filters = metadata.filters; } @@ -179,41 +179,79 @@ class MadaraPlugin implements Plugin.PluginBase { loadedCheerio('.post-content_item, .post-content').each(function () { const detailName = loadedCheerio(this).find('h5').text().trim(); - const detail = loadedCheerio(this).find('.summary-content').text().trim(); + const detail = loadedCheerio(this).find('.summary-content'); switch (detailName) { case 'Genre(s)': case 'Genre': + case 'Tags(s)': + case 'Tag(s)': case 'Tags': case 'Género(s)': case 'التصنيفات': - if (novel.genres) novel.genres += ', ' + detail; - else novel.genres = detail; + if (novel.genres) + novel.genres += + ', ' + + detail + .find('a') + .map((i, el) => loadedCheerio(el).text()) + .get() + .join(', '); + else + novel.genres = detail + .find('a') + .map((i, el) => loadedCheerio(el).text()) + .get() + .join(', '); break; case 'Author(s)': case 'Author': case 'Autor(es)': case 'المؤلف': case 'المؤلف (ين)': - novel.author = detail; + novel.author = detail.text().trim(); break; case 'Status': case 'Novel': case 'Estado': novel.status = - detail.includes('OnGoing') || detail.includes('مستمرة') + detail.text().trim().includes('OnGoing') || + detail.text().trim().includes('مستمرة') ? NovelStatus.Ongoing : NovelStatus.Completed; break; + case 'Artist(s)': + novel.artist = detail.text().trim(); + break; } }); + if (!novel.author) + novel.author = loadedCheerio('.manga-authors').text().trim(); + loadedCheerio('div.summary__content .code-block,script,noscript').remove(); - const summary = - loadedCheerio('div.summary__content') || - loadedCheerio('#tab-manga-about') || - loadedCheerio('.post-content_item h5:contains("Summary")').next(); - novel.summary = this.translateDragontea(summary).text().trim(); + novel.summary = + this.translateDragontea(loadedCheerio('div.summary__content')) + .text() + .trim() || + loadedCheerio('#tab-manga-about').text().trim() || + loadedCheerio('.post-content_item h5:contains("Summary")') + .next() + .find('span') + .map((i, el) => loadedCheerio(el).text()) + .get() + .join('\n\n') + .trim() || + loadedCheerio('.manga-summary p') + .map((i, el) => loadedCheerio(el).text()) + .get() + .join('\n\n') + .trim() || + loadedCheerio('.manga-excerpt p') + .map((i, el) => loadedCheerio(el).text()) + .get() + .join('\n\n') + .trim(); const chapters: Plugin.ChapterItem[] = []; let html = '';