forked from manga-download/hakuneko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: OlympusScanlation - Complete rewrite (manga-download#5521)
* OlympusScanlation : Complete rewrite * Url change * No more Madara, custom api * Fixes manga-download#5517 * updates urls
- Loading branch information
Showing
1 changed file
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |