From 9814028e34fff3f3b8eeb1706c61ede9ced7b974 Mon Sep 17 00:00:00 2001 From: MikeZeDev Date: Wed, 1 Mar 2023 13:16:33 +0000 Subject: [PATCH 1/2] OlympusScanlation : Complete rewrite * Url change * No more Madara, custom api * Fixes https://github.com/manga-download/hakuneko/issues/5517 --- src/web/mjs/connectors/OlympusScanlation.mjs | 80 +++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/src/web/mjs/connectors/OlympusScanlation.mjs b/src/web/mjs/connectors/OlympusScanlation.mjs index e74503e419f..d4adb071e25 100644 --- a/src/web/mjs/connectors/OlympusScanlation.mjs +++ b/src/web/mjs/connectors/OlympusScanlation.mjs @@ -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://olympusscans.com'; + this.apiUrl = 'https://dashboard.olympusscans.com'; } + + 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); + } + } From b922fd9b0ffecab8b27c62690bccedf66d6f5a9f Mon Sep 17 00:00:00 2001 From: MikeZeDev Date: Fri, 18 Aug 2023 13:07:25 +0000 Subject: [PATCH 2/2] updates urls --- src/web/mjs/connectors/OlympusScanlation.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/mjs/connectors/OlympusScanlation.mjs b/src/web/mjs/connectors/OlympusScanlation.mjs index d4adb071e25..f7116f36cb6 100644 --- a/src/web/mjs/connectors/OlympusScanlation.mjs +++ b/src/web/mjs/connectors/OlympusScanlation.mjs @@ -8,8 +8,8 @@ export default class OlympusScanlation extends Connector { super.id = 'olympusscanlation'; super.label = 'Olympus Scanlation'; this.tags = [ 'webtoon', 'spanish' ]; - this.url = 'https://olympusscans.com'; - this.apiUrl = 'https://dashboard.olympusscans.com'; + this.url = 'https://olympusv2.gg'; + this.apiUrl = 'https://dashboard.olympusv2.gg'; } async _getMangaFromURI(uri) {