Skip to content

Commit

Permalink
ComicRyu : add support for unicorn subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeZeDev committed Dec 23, 2024
1 parent b53fff6 commit 5d0cd72
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
32 changes: 22 additions & 10 deletions web/src/engine/websites/ComicRyu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLHeadingElement>('h1.sakuhin-article-title').textContent.trim()
};
}
function ChapterInfoExtractor(anchor: HTMLAnchorElement) {
return {
id: anchor.href,
title: anchor.querySelector<HTMLHeadingElement>('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 {
Expand All @@ -18,13 +31,12 @@ export default class extends DecoratableMangaScraper {
return icon;
}

public override async FetchMangas(provider: MangaPlugin): Promise<Manga[]> {
const categories = ['シリーズ一覧-連載中', '完結作品'];
const mangasList: Manga[] = [];
for (const category of categories) {
const data = await FetchCSS<HTMLAnchorElement>(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<Manga> {
const title = (await FetchCSS<HTMLHeadingElement>(new Request(new URL(url)), 'article.sakuhin-article h1.sakuhin-article-title')).shift().textContent.trim();
return new Manga(this, provider, url, title);
}
}
32 changes: 25 additions & 7 deletions web/src/engine/websites/ComicRyu_e2e.ts
Original file line number Diff line number Diff line change
@@ -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();
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();

0 comments on commit 5d0cd72

Please sign in to comment.