-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cartoonmad resolves #166 iconv decoding not currently working properly, no idea how to fix * lint * working fetchDOM is still functional without encoding having a value * fixes * lint * +1 Co-authored-by: 09morbab <30987265+09morbab@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Connector from '../engine/Connector.mjs'; | ||
import Manga from '../engine/Manga.mjs'; | ||
|
||
export default class CarToonMad extends Connector { | ||
|
||
constructor() { | ||
super(); | ||
super.id = 'cartoonmad'; | ||
super.label = 'CarToonMad'; | ||
this.tags = ['manga', 'chinese']; | ||
this.url = 'https://www.cartoonmad.com'; | ||
this.requestOptions.headers.set('x-referer', this.url); | ||
} | ||
|
||
async _getMangas() { | ||
let mangaList = []; | ||
const request = new Request(new URL('/comic99.html', this.url), this.requestOptions); | ||
const data = await this.fetchDOM(request, 'td[align] > a:last-child.pages'); | ||
const pageCount = parseInt(data[0].href.match(/(\d+)\.html/)[1]); | ||
for(let page = 1; page <= pageCount; page++) { | ||
let mangas = await this._getMangasFromPage(page); | ||
mangaList.push(...mangas); | ||
} | ||
return mangaList; | ||
} | ||
|
||
async _getMangasFromPage(page) { | ||
const request = new Request(new URL('/comic99.'+String(page).padStart(2, '0')+'.html', this.url), this.requestOptions); | ||
const data = await this.fetchDOM(request, 'a.a1', 0, 'big5'); | ||
return data.map(element => { | ||
return { | ||
id: this.getRootRelativeOrAbsoluteLink(element, this.url), | ||
title: element.textContent.trim() | ||
}; | ||
}); | ||
} | ||
|
||
async _getMangaFromURI(uri) { | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchDOM(request, 'td:nth-child(2) tr:nth-child(3) > td:nth-child(2) > a:last-child', 0, 'big5'); | ||
const id = uri.pathname + uri.search; | ||
const title = data[0].textContent.trim(); | ||
return new Manga(this, id, title); | ||
} | ||
|
||
async _getChapters(manga) { | ||
const request = new Request(new URL(manga.id, this.url), this.requestOptions); | ||
const data = await this.fetchDOM(request, '#info td > a', 0, 'big5'); | ||
return data.map(element => { | ||
return { | ||
id: this.getRootRelativeOrAbsoluteLink(element, this.url), | ||
title: element.textContent.trim() | ||
}; | ||
}); | ||
} | ||
|
||
async _getPages(chapter) { | ||
const request = new Request(new URL(chapter.id, this.url), this.requestOptions); | ||
const data = await this.fetchDOM(request, 'body'); | ||
const maxpage = parseInt(data[0].querySelector('a:nth-last-of-type(2).pages').textContent); | ||
const pageone = data[0].querySelector('a > source[oncontextmenu]').src; | ||
return [...new Array(maxpage)].map((_, int) => pageone.replace(/(\d+)$/, String(int+1).padStart(3, '0'))); | ||
} | ||
} |
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