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
This commit is contained in:
Justin COLLON
2024-11-02 14:55:24 +01:00
committed by GitHub
parent bb403d7b82
commit ead1f93789
+49 -11
View File
@@ -39,7 +39,7 @@ class MadaraPlugin implements Plugin.PluginBase {
this.icon = `multisrc/madara/${metadata.id.toLowerCase()}/icon.png`; this.icon = `multisrc/madara/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite; this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0; const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.0.${4 + versionIncrements}`; this.version = `1.0.${5 + versionIncrements}`;
this.options = metadata.options; this.options = metadata.options;
this.filters = metadata.filters; this.filters = metadata.filters;
} }
@@ -179,41 +179,79 @@ class MadaraPlugin implements Plugin.PluginBase {
loadedCheerio('.post-content_item, .post-content').each(function () { loadedCheerio('.post-content_item, .post-content').each(function () {
const detailName = loadedCheerio(this).find('h5').text().trim(); 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) { switch (detailName) {
case 'Genre(s)': case 'Genre(s)':
case 'Genre': case 'Genre':
case 'Tags(s)':
case 'Tag(s)':
case 'Tags': case 'Tags':
case 'Género(s)': case 'Género(s)':
case 'التصنيفات': case 'التصنيفات':
if (novel.genres) novel.genres += ', ' + detail; if (novel.genres)
else novel.genres = detail; 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; break;
case 'Author(s)': case 'Author(s)':
case 'Author': case 'Author':
case 'Autor(es)': case 'Autor(es)':
case 'المؤلف': case 'المؤلف':
case 'المؤلف (ين)': case 'المؤلف (ين)':
novel.author = detail; novel.author = detail.text().trim();
break; break;
case 'Status': case 'Status':
case 'Novel': case 'Novel':
case 'Estado': case 'Estado':
novel.status = novel.status =
detail.includes('OnGoing') || detail.includes('مستمرة') detail.text().trim().includes('OnGoing') ||
detail.text().trim().includes('مستمرة')
? NovelStatus.Ongoing ? NovelStatus.Ongoing
: NovelStatus.Completed; : NovelStatus.Completed;
break; 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(); loadedCheerio('div.summary__content .code-block,script,noscript').remove();
const summary = novel.summary =
loadedCheerio('div.summary__content') || this.translateDragontea(loadedCheerio('div.summary__content'))
loadedCheerio('#tab-manga-about') || .text()
loadedCheerio('.post-content_item h5:contains("Summary")').next(); .trim() ||
novel.summary = this.translateDragontea(summary).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[] = []; const chapters: Plugin.ChapterItem[] = [];
let html = ''; let html = '';