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

FIX: OlympusScanlation - Complete rewrite #5521

Merged
merged 2 commits into from
Oct 3, 2023
Merged
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
80 changes: 77 additions & 3 deletions src/web/mjs/connectors/OlympusScanlation.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,86 @@
import WordPressMadara from './templates/WordPressMadara.mjs';
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class OlympusScanlation extends WordPressMadara {
export default class OlympusScanlation extends Connector {

constructor() {
super();
super.id = 'olympusscanlation';
super.label = 'Olympus Scanlation';
this.tags = [ 'webtoon', 'spanish' ];
this.url = 'https://olympusscanlation.com';
this.url = 'https://olympusv2.gg';
this.apiUrl = 'https://dashboard.olympusv2.gg';
}

async _getMangaFromURI(uri) {
const jsonObject= await this.getNuxt(uri);
const objkey = new URL(uri).pathname;
const slug = jsonObject.data[objkey].data.slug;
const mangatype = jsonObject.data[objkey].data.type;
const title = jsonObject.data[objkey].data.name.trim();
const id = JSON.stringify({ slug: slug, type : mangatype});
return new Manga(this, id, title);
}

async _getMangas() {
let mangaList = [];
for (let page = 1, run = true; run; page++) {
const mangas = await this._getMangasFromPage(page);
mangas.length > 0 ? mangaList.push(...mangas) : run = false;
}
return mangaList;
}

async _getMangasFromPage(page) {
const uri = new URL(`/api/series?page=${page}&direction=asc`, this.apiUrl);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchJSON(request);
return data.data.series.data.map(element => {
return {
id: JSON.stringify( { slug : element.slug, type : element.type} ),
title: element.name.trim()
};
});
}

async _getChapters(manga) {
let chapterList = [];
for (let page = 1, run = true; run; page++) {
const chapters = await this._getChaptersFromPage(manga, page);
chapters.length > 0 ? chapterList.push(...chapters) : run = false;
}
return chapterList;
}

async _getChaptersFromPage(manga, page) {
const mangaData = JSON.parse(manga.id);
const uri = new URL(`/api/series/${mangaData.slug}/chapters?page=${page}&direction=desc&type=${mangaData.type}`, this.apiUrl);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchJSON(request);
return data.data.map(element => {
return {
id: element.id,
title: element.name.trim()
};
});
}

async _getPages(chapter) {
const mangaData = JSON.parse(chapter.manga.id);
const uri = new URL(`/api/series/${mangaData.slug}/chapters/${chapter.id}?type=${mangaData.type}`, this.apiUrl);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchJSON(request);
return data.chapter.pages;
}

async getNuxt(uri) {
const request = new Request(uri, this.requestOptions);
const script = `
new Promise(resolve => {
resolve(__NUXT__);
});
`;
return await Engine.Request.fetchUI(request, script);
}

}
Loading