Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yuramanga : no more madara #794

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions web/src/engine/websites/YuraManga.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
import { Tags } from '../Tags';
import icon from './YuraManga.webp';
import { DecoratableMangaScraper } from '../providers/MangaPlugin';
import * as Madara from './decorators/WordPressMadara';
import { DecoratableMangaScraper, Manga, type MangaPlugin } from '../providers/MangaPlugin';
import * as Common from './decorators/Common';
import { FetchJSON } from '../platform/FetchProvider';

@Madara.MangaCSS(/^{origin}\/manga\/[^/]+\/$/, 'meta[property="og:title"]:not([content*="YuraManga"])')
@Madara.MangasMultiPageAJAX()
@Madara.ChaptersSinglePageAJAXv2()
@Madara.PagesSinglePageCSS()
type RSS = {
feed: {
entry: {
title: {
$t: string
},
link: {
rel: string
title: string,
href: string
}[]
}[]
}
}

const chapterScript = `
new Promise ( resolve =>
resolve (clwd.arr.filter(chapter => chapter.link != window.location.href)
.map(chapter => {
return {
id: new URL(chapter.link).pathname,
title : chapter.title.trim()
};
})
)
);
`;

const pagesScript = `[...document.querySelectorAll('div.isi_chapter div.bx_dl img')].map(img => img.dataset.src ?? img.src);`;

@Common.MangaCSS(/^{origin}\/\d+\/\d+\/[^/]+\.html$/, 'meta[name="description"]')
@Common.ChaptersSinglePageJS(chapterScript, 500)
@Common.PagesSinglePageJS(pagesScript, 1500)
@Common.ImageAjax()
export default class extends DecoratableMangaScraper {

Expand All @@ -18,4 +47,13 @@ export default class extends DecoratableMangaScraper {
public override get Icon() {
return icon;
}
}

public override async FetchMangas(provider: MangaPlugin): Promise<Manga[]> {
const { feed: { entry } } = await FetchJSON<RSS>(new Request(new URL('/feeds/posts/default/-/Series?orderby=published&alt=json&max-results=999', this.URI)));
return entry.map(manga => {
const goodLink = manga.link.find(link => link.rel === 'alternate');
return new Manga(this, provider, new URL(goodLink.href).pathname, goodLink.title);
});
}

}
6 changes: 3 additions & 3 deletions web/src/engine/websites/YuraManga_e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const config: Config = {
},
container: {
url: 'https://www.yuramanga.my.id/2023/08/district-12.html',
id: JSON.stringify({ post: '2130', slug: '/manga/district-12/' }),
id: '/2023/08/district-12.html',
title: 'District 12'
},
child: {
Expand All @@ -17,8 +17,8 @@ const config: Config = {
},
entry: {
index: 1,
size: 1_637_152,
type: 'image/jpeg'
size: 755_988,
type: 'image/webp'
}
};

Expand Down