fix MTL Novel (#1085)

* MTL Novel:
- fix chapters not loading
- fix geners & author & status not working
- renamed MTL Novel for languages

* MTL Novel version update
This commit is contained in:
Justin COLLON
2024-07-24 17:17:39 +02:00
committed by GitHub
parent 4bb772f207
commit 0b86806fcf
2 changed files with 40 additions and 14 deletions
+3 -3
View File
@@ -10,7 +10,7 @@
{ {
"id": "mtlnovel-fr", "id": "mtlnovel-fr",
"sourceSite": "https://fr.mtlnovel.com/", "sourceSite": "https://fr.mtlnovel.com/",
"sourceName": "MTL Novel", "sourceName": "MTL Novel (FR)",
"options": { "options": {
"lang": "French" "lang": "French"
} }
@@ -18,7 +18,7 @@
{ {
"id": "mtlnovel-es", "id": "mtlnovel-es",
"sourceSite": "https://es.mtlnovel.com/", "sourceSite": "https://es.mtlnovel.com/",
"sourceName": "MTL Novel", "sourceName": "MTL Novel (ES)",
"options": { "options": {
"lang": "Spanish" "lang": "Spanish"
} }
@@ -26,7 +26,7 @@
{ {
"id": "mtlnovel-id", "id": "mtlnovel-id",
"sourceSite": "https://id.mtlnovel.com/", "sourceSite": "https://id.mtlnovel.com/",
"sourceName": "MTL Novel", "sourceName": "MTL Novel (ID)",
"options": { "options": {
"lang": "Indonesian" "lang": "Indonesian"
} }
+37 -11
View File
@@ -22,6 +22,7 @@ class MTLNovelPlugin implements Plugin.PluginBase {
name: string; name: string;
icon: string; icon: string;
site: string; site: string;
mainUrl: string;
version: string; version: string;
options?: MTLNovelOptions; options?: MTLNovelOptions;
filters?: Filters; filters?: Filters;
@@ -31,7 +32,8 @@ class MTLNovelPlugin implements Plugin.PluginBase {
this.name = metadata.sourceName; this.name = metadata.sourceName;
this.icon = 'multisrc/mtlnovel/mtlnovel/icon.png'; this.icon = 'multisrc/mtlnovel/mtlnovel/icon.png';
this.site = metadata.sourceSite; this.site = metadata.sourceSite;
this.version = '1.1.0'; this.mainUrl = 'https://www.mtlnovel.com/';
this.version = '1.1.1';
this.options = metadata.options ?? ({} as MTLNovelOptions); this.options = metadata.options ?? ({} as MTLNovelOptions);
this.filters = metadata.filters satisfies Filters; this.filters = metadata.filters satisfies Filters;
} }
@@ -77,9 +79,8 @@ class MTLNovelPlugin implements Plugin.PluginBase {
if ( if (
!novelCover || !novelCover ||
novelCover == 'https://www.mtlnovel.net/no-image.jpg.webp' novelCover == 'https://www.mtlnovel.net/no-image.jpg.webp'
) { )
novelCover = defaultCover; novelCover = defaultCover;
}
const novelUrl = loadedCheerio(el).find('a.list-title').attr('href'); const novelUrl = loadedCheerio(el).find('a.list-title').attr('href');
if (!novelUrl) return; if (!novelUrl) return;
@@ -87,7 +88,7 @@ class MTLNovelPlugin implements Plugin.PluginBase {
const novel = { const novel = {
name: novelName, name: novelName,
cover: novelCover, cover: novelCover,
path: novelUrl.replace(this.site, ''), path: novelUrl.replace(this.mainUrl, '').replace(this.site, ''),
}; };
novels.push(novel); novels.push(novel);
@@ -108,15 +109,38 @@ class MTLNovelPlugin implements Plugin.PluginBase {
const novel: Plugin.SourceNovel = { const novel: Plugin.SourceNovel = {
path: novelPath, path: novelPath,
name: loadedCheerio('h1.entry-title').text() || 'Untitled', name: loadedCheerio('h1.entry-title').text().trim() || 'Untitled',
cover: loadedCheerio('.nov-head > amp-img').attr('src'), cover: loadedCheerio('.nov-head > amp-img').attr('src') || defaultCover,
summary: loadedCheerio('div.desc > h2').next().text().trim(), summary: loadedCheerio('div.desc > h2').next().text().trim(),
author: loadedCheerio('#author').text(),
status: loadedCheerio('#status').text(),
genres: loadedCheerio('#genre').text().replace(/\s+/g, ''),
chapters: [], chapters: [],
}; };
loadedCheerio('.info tr').each((i, el) => {
const infoName = loadedCheerio(el).find('td').eq(0).text().trim();
const infoValue = loadedCheerio(el).find('td').eq(2).text().trim();
switch (infoName) {
case 'Genre':
case 'Tags':
case 'Mots Clés':
case 'Género':
case 'Label':
if (novel.genres) novel.genres += ', ' + infoValue;
else novel.genres = infoValue;
break;
case 'Author':
case 'Auteur':
case 'Autor(a)':
novel.author = infoValue;
break;
case 'Status':
case 'Statut':
case 'Estado':
if (infoValue == 'Hiatus') novel.status = NovelStatus.OnHiatus;
else novel.status = infoValue;
break;
}
});
const chapterListUrl = this.site + novelPath + 'chapter-list/'; const chapterListUrl = this.site + novelPath + 'chapter-list/';
const getChapters = async () => { const getChapters = async () => {
@@ -136,7 +160,7 @@ class MTLNovelPlugin implements Plugin.PluginBase {
const chapterUrl = loadedCheerio(el).attr('href'); const chapterUrl = loadedCheerio(el).attr('href');
if (!chapterUrl) return; if (!chapterUrl) return;
chapter.push({ chapter.push({
path: chapterUrl.replace(this.site, ''), path: chapterUrl.replace(this.mainUrl, '').replace(this.site, ''),
name: chapterName, name: chapterName,
releaseTime: releaseDate, releaseTime: releaseDate,
}); });
@@ -181,7 +205,9 @@ class MTLNovelPlugin implements Plugin.PluginBase {
result.items[0].results.map((item: SearchEntry) => { result.items[0].results.map((item: SearchEntry) => {
const novelName = item.title.replace(/<\/?strong>/g, ''); const novelName = item.title.replace(/<\/?strong>/g, '');
const novelCover = item.thumbnail; const novelCover = item.thumbnail;
const novelUrl = item.permalink.replace(this.site, ''); const novelUrl = item.permalink
.replace(this.mainUrl, '')
.replace(this.site, '');
const novel = { name: novelName, cover: novelCover, path: novelUrl }; const novel = { name: novelName, cover: novelCover, path: novelUrl };