From 5d0cd721b8b26d353fa5a5ada10cdddde8468da9 Mon Sep 17 00:00:00 2001 From: MikeZeDev Date: Mon, 23 Dec 2024 22:04:42 +0100 Subject: [PATCH] ComicRyu : add support for unicorn subdomain https://github.com/manga-download/hakuneko/issues/7624 --- web/src/engine/websites/ComicRyu.ts | 32 +++++++++++++++++-------- web/src/engine/websites/ComicRyu_e2e.ts | 32 +++++++++++++++++++------ 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/web/src/engine/websites/ComicRyu.ts b/web/src/engine/websites/ComicRyu.ts index 978283b3c3..bc821b02db 100644 --- a/web/src/engine/websites/ComicRyu.ts +++ b/web/src/engine/websites/ComicRyu.ts @@ -4,8 +4,21 @@ import { DecoratableMangaScraper, type MangaPlugin, Manga } from '../providers/M import * as Common from './decorators/Common'; import { FetchCSS } from '../platform/FetchProvider'; -@Common.MangaCSS(/^{origin}\/series\/[^/]+\/$/, 'article.sakuhin-article h1.sakuhin-article-title') -@Common.ChaptersSinglePageCSS('a.sakuhin-episode-link') +function MangaInfoExtractor(anchor: HTMLAnchorElement) { + return { + id: anchor.href, + title: anchor.querySelector('h1.sakuhin-article-title').textContent.trim() + }; +} +function ChapterInfoExtractor(anchor: HTMLAnchorElement) { + return { + id: anchor.href, + title: anchor.querySelector('h1.sakuhin-episode-title').textContent.trim() + }; +} + +@Common.MangasSinglePagesCSS(['シリーズ一覧-連載中', '完結作品', 'https://unicorn.comic-ryu.jp/シリーズ一覧-連載中/'], 'ul.m-series-list li a.m-list-sakuhin-list-item-link', MangaInfoExtractor) +@Common.ChaptersSinglePageCSS('a.sakuhin-episode-link', ChapterInfoExtractor) @Common.PagesSinglePageCSS('figure.wp-block-image img') @Common.ImageAjax() export default class extends DecoratableMangaScraper { @@ -18,13 +31,12 @@ export default class extends DecoratableMangaScraper { return icon; } - public override async FetchMangas(provider: MangaPlugin): Promise { - const categories = ['シリーズ一覧-連載中', '完結作品']; - const mangasList: Manga[] = []; - for (const category of categories) { - const data = await FetchCSS(new Request(new URL(category, this.URI)), 'ul.m-series-list li a.m-list-sakuhin-list-item-link'); - mangasList.push(...data.map(element => new Manga(this, provider, element.pathname, element.querySelector('h1.sakuhin-article-title').textContent.trim()))); - } - return mangasList.distinct(); + public override ValidateMangaURL(url: string): boolean { + return /^https:\/\/(www|unicorn)\.comic-ryu\.jp\/series\/[^/]+\/$/.test(url); + } + + public override async FetchManga(provider: MangaPlugin, url: string): Promise { + const title = (await FetchCSS(new Request(new URL(url)), 'article.sakuhin-article h1.sakuhin-article-title')).shift().textContent.trim(); + return new Manga(this, provider, url, title); } } \ No newline at end of file diff --git a/web/src/engine/websites/ComicRyu_e2e.ts b/web/src/engine/websites/ComicRyu_e2e.ts index 322e5a4ddd..1fc0c14676 100644 --- a/web/src/engine/websites/ComicRyu_e2e.ts +++ b/web/src/engine/websites/ComicRyu_e2e.ts @@ -1,25 +1,43 @@ -import { TestFixture, type Config } from '../../../test/WebsitesFixture'; +import { TestFixture } from '../../../test/WebsitesFixture'; -const config: Config = { +new TestFixture({ plugin: { id: 'comicryu', title: 'COMICリュウ' }, container: { url: 'https://www.comic-ryu.jp/series/zingnize/', - id: '/series/zingnize/', + id: 'https://www.comic-ryu.jp/series/zingnize/', title: 'ZINGNIZE' }, child: { - id: '/2167/', + id: 'https://www.comic-ryu.jp/2167/', title: '第一話「高坂甚内①」' }, entry: { index: 0, size: 3_619_874, type: 'image/jpeg', - timeout: 25000 } -}; +}).AssertWebsite(); -new TestFixture(config).AssertWebsite(); \ No newline at end of file +new TestFixture({ + plugin: { + id: 'comicryu', + title: 'COMICリュウ' + }, + container: { + url: 'https://unicorn.comic-ryu.jp/series/isekaichikyuukan/', + id: 'https://unicorn.comic-ryu.jp/series/isekaichikyuukan/', + title: '異世界⇔地球間で個人貿易してみた' + }, + child: { + id: 'https://unicorn.comic-ryu.jp/145/', + title: '第1話' + }, + entry: { + index: 0, + size: 172_714, + type: 'image/jpeg', + } +}).AssertWebsite(); \ No newline at end of file