Skip to content

Commit

Permalink
FIX: OlympusScanlation - Complete rewrite (manga-download#5521)
Browse files Browse the repository at this point in the history
* OlympusScanlation : Complete rewrite

* Url change
* No more Madara, custom api
* Fixes manga-download#5517

* updates urls
  • Loading branch information
MikeZeDev authored Oct 3, 2023
1 parent f038a53 commit 5aedba5
Showing 1 changed file with 77 additions and 3 deletions.
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);
}

}

0 comments on commit 5aedba5

Please sign in to comment.