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

EarlyManga: fix website #7267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
51 changes: 34 additions & 17 deletions src/web/mjs/connectors/EarlyManga.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class EarlyManga extends Connector {

constructor() {
super();
super.id = 'earlymanga';
Expand All @@ -17,46 +19,61 @@ export default class EarlyManga extends Connector {
return mangaList;
}
async _getMangasFromPage(page) {
const uri = new URL('/api/search/advanced?page='+page, this.url);
const request = new Request(uri, this.requestOptions);
let data = await this.fetchJSON(request);
const uri = new URL('/api/search/advanced/post?page='+page, this.url);
const body = {
'list_order': 'desc'
};
const request = new Request(uri, {
method: 'POST', body: JSON.stringify(body), headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json'
}
});

const data = await this.fetchJSON(request);
return data.data.map(item => {
const id = { id: item.id, slug: item.slug };
return {
id: '/manga/' + item.slug.trim(),
title: item.title.trim()
id : JSON.stringify(id),
title : item.title.trim()
};
});
}

async _getChapters(manga) {
const mangaid = manga.id.match(/\/manga\/(\S+)/)[1];
const uri = new URL('/api/manga/'+mangaid+'/chapterlist', this.url);
const mangaid = JSON.parse(manga.id);
const uri = new URL(`/api/manga/${mangaid.id}/${mangaid.slug}/chapterlist`, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchJSON(request);
return data.map(item => {
const id = { id: item.id, slug: item.slug };
return {
id: '/manga/' + mangaid + '/chapter-'+item.slug,
title: 'Chapter '+item.chapter_number
id : JSON.stringify(id),
title : 'Chapter ' + item.chapter_number
};
});
}

async _getPages(chapter) {
const uri = new URL('/api'+chapter.id, this.url);
const mangaid = JSON.parse(chapter.manga.id);
const chapterid = JSON.parse(chapter.id);
const uri = new URL(`/api/manga/${mangaid.id}/${mangaid.slug}/${chapterid.id}/chapter-${chapterid.slug}`, this.url);

const request = new Request(uri, this.requestOptions);
let data = await this.fetchJSON(request);
let manga_id = data.chapter.manga_id;
return data.chapter.images.map(item => {
return this.url+'/storage/uploads/manga/manga_'+manga_id+'/chapter_'+data.chapter.slug+'/'+item;
const data = await this.fetchJSON(request);
return data.chapter.images.map(page => {
const path = !data.chapter.on_disk ? 'https://images.earlym.org/manga' : '/storage/uploads/manga';
return new URL(`${path}/manga_${data.chapter.manga_id}/chapter_${data.chapter.slug}/${page}`, this.url).href;
});
}

async _getMangaFromURI(uri) {
const mangaid = uri.href.match(/\/manga\/(\S+)/)[1];
const apicallurl = new URL('/api/manga/'+mangaid, this.url);
const request = new Request(apicallurl, this.requestOptions);
let data = await this.fetchJSON(request);
const id = uri.pathname;
const data = await this.fetchJSON(request);
const id = { id: data.main_manga.id, slug: data.main_manga.slug };
const title = data.main_manga.title.trim();
return new Manga(this, id, title);
return new Manga(this, JSON.stringify(id), title);
}
}
Loading