Skip to content

Commit

Permalink
Add MultPorn
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeZeDev committed Jun 29, 2024
1 parent 0a184df commit 2e3f005
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
14 changes: 6 additions & 8 deletions web/src/engine/websites/MultPorn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tags } from '../Tags';
import icon from './AdonisFansub.webp';
import icon from './MultPorn.webp';
import { Chapter, DecoratableMangaScraper, type Manga, type MangaPlugin } from '../providers/MangaPlugin';
import * as Common from './decorators/Common';
import { FetchJSON, FetchWindowScript } from '../platform/FetchProvider';
Expand Down Expand Up @@ -41,7 +41,9 @@ type DrupalResult = {
@Common.PagesSinglePageJS(pageScript, 1500)
@Common.ImageAjax()
export default class extends DecoratableMangaScraper {

private readonly apiUrl = `${this.URI.origin}/views/ajax`;

public constructor() {
super('multporn', 'MultPorn', 'https://multporn.net', Tags.Media.Comic, Tags.Media.Manga, Tags.Language.Multilingual, Tags.Source.Aggregator, Tags.Rating.Pornographic);
}
Expand Down Expand Up @@ -81,12 +83,10 @@ export default class extends DecoratableMangaScraper {
private async GetChaptersFromAjaxPage(manga: Manga, page: number, settings: DrupalSettings): Promise<Chapter[]> {

const view = Object.values(settings.views.ajaxViews).shift();

const params = new URLSearchParams();
for (const key of Object.keys(view)) {
params.append(key, view[key]);
};

params.set('page', `0,${page}`);

const results = await FetchJSON<DrupalResult[]>(new Request(this.apiUrl, {
Expand All @@ -101,11 +101,9 @@ export default class extends DecoratableMangaScraper {
}
}));

const goodcommand = results.find(entry => entry.command == 'insert');
const dom = new DOMParser().parseFromString(goodcommand.data, 'text/html');
const nodes = dom.querySelectorAll < HTMLAnchorElement>('div.view-content table tr td strong.field-content a');
const { data } = results.find(entry => entry.command == 'insert');
const dom = new DOMParser().parseFromString(data, 'text/html');
const nodes = dom.querySelectorAll<HTMLAnchorElement>('div.view-content table tr td strong.field-content a');
return [...nodes]?.map(chapter => new Chapter(this, manga, chapter.pathname, chapter.text.trim())) ?? [];

}

}
Binary file added web/src/engine/websites/MultPorn.webp
Binary file not shown.
27 changes: 27 additions & 0 deletions web/src/engine/websites/MultPorn_e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe } from 'vitest';
import { TestFixture } from '../../../test/WebsitesFixture';

const config = {
plugin: {
id: 'multporn',
title: 'MultPorn'
},
container: {
url: 'https://multporn.net/hentai_manga/azur_lane',
id: '/hentai_manga/azur_lane',
title: 'Azur Lane',
timeout: 15000
},
child: {
id: '/hentai_manga/a_maids_duty',
title: `A Maid's Duty`
},
entry: {
index: 0,
size: 1_504_421,
type: 'image/png'
}
};

const fixture = new TestFixture(config);
describe(fixture.Name, async () => (await fixture.Connect()).AssertWebsite());

0 comments on commit 2e3f005

Please sign in to comment.