-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update asura url, fix manhwa club too many requests, fix reaperscans
- Loading branch information
Showing
24 changed files
with
208 additions
and
102 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
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,5 +1,5 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<widget id="org.cordova.manga.reader" version="2.20.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> | ||
<widget id="org.cordova.manga.reader" version="2.20.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> | ||
<name>Manga Reader</name> | ||
<description>Manga reader that scrapes manga sites for updates</description> | ||
<author email="[email protected]" href="http://cordova.io"> | ||
|
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
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
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,118 @@ | ||
import { Manga } from 'src/classes/manga' | ||
import { SiteType } from 'src/enums/siteEnum' | ||
import HttpRequest from 'src/interfaces/httpRequest' | ||
import { requestHandler } from 'src/services/requestService' | ||
import * as SiteUtils from 'src/utils/siteUtils' | ||
import { BaseData, BaseSite } from './baseSite' | ||
|
||
class ReaperScansData extends BaseData { | ||
chapterUrl?: Element | null | ||
} | ||
|
||
export class ReaperScans extends BaseSite { | ||
siteType = SiteType.ReaperScans | ||
|
||
protected getChapterUrl (data: ReaperScansData): string { | ||
const url = data.chapterUrl?.getAttribute('href') || '' | ||
if (url.startsWith('/')) return `${this.getUrl()}${url}` | ||
|
||
return url | ||
} | ||
|
||
protected getChapterNum (data: ReaperScansData): number { | ||
const chapter = this.getChapter(data) | ||
if (!chapter) return 0 | ||
|
||
const pattern = /[\d\\.,]+\b/gm | ||
let num = 0 | ||
let match: RegExpExecArray | null | ||
|
||
while ((match = pattern.exec(chapter)) !== null) { | ||
const matchedValue = match[0] | ||
if (!matchedValue) continue | ||
|
||
const parsedMatch = parseFloat(matchedValue) | ||
if (!isNaN(parsedMatch)) { | ||
num = parsedMatch | ||
break | ||
} | ||
} | ||
|
||
return num | ||
} | ||
|
||
protected getChapterDate (data: BaseData): string { | ||
return SiteUtils.getDateFromNow( | ||
data.chapterDate?.textContent?.toLowerCase().replace(/released/m, '') | ||
) | ||
} | ||
|
||
protected async readUrlImpl (url: string): Promise<Error | Manga> { | ||
const request: HttpRequest = { method: 'GET', url } | ||
const response = await requestHandler.sendRequest(request) | ||
|
||
const doc = await SiteUtils.parseHtmlFromString(response.data) | ||
const data = new ReaperScansData(url) | ||
|
||
const titleContainer = doc.querySelectorAll('main>div:nth-child(2)>div>div')[0] | ||
const chapterContainer = doc.querySelectorAll('div>div>div>ul li')[0] | ||
const [chapter, date] = chapterContainer?.querySelectorAll('p') ?? [] | ||
|
||
data.title = titleContainer?.querySelectorAll('h1')[0] | ||
data.image = titleContainer?.querySelectorAll('img')[0] | ||
data.chapter = chapter | ||
data.chapterUrl = chapterContainer?.querySelectorAll('a')[0] | ||
data.chapterDate = date | ||
|
||
return this.buildManga(data) | ||
} | ||
|
||
protected async searchImpl (query: string): Promise<Error | Manga[]> { | ||
let page = 1 | ||
let count = 30 | ||
const mangaList: Manga[] = [] | ||
|
||
while (count >= 30) { | ||
const result = await this.searchPage(query, page) | ||
count = result.count | ||
mangaList.push(...result.manga) | ||
|
||
page++ | ||
} | ||
|
||
return mangaList | ||
} | ||
|
||
private async searchPage (query: string, page: number): Promise<{ manga: Manga[], count: number }> { | ||
const request: HttpRequest = { method: 'GET', url: `${this.getUrl()}/comics?page=${page}` } | ||
const response = await requestHandler.sendRequest(request) | ||
|
||
const doc = await SiteUtils.parseHtmlFromString(response.data) | ||
const comics = doc.querySelectorAll('li') | ||
const mangaList: Manga[] = [] | ||
|
||
comics.forEach((element) => { | ||
const [imageElem, titleElem] = element.querySelectorAll('a') | ||
|
||
const title = titleElem?.textContent?.trim() | ||
if (!SiteUtils.titleContainsQuery(query, title)) return | ||
|
||
const url = imageElem?.getAttribute('href') | ||
if (!url) return | ||
|
||
const chapterCount = element.querySelectorAll('dl')[0]?.textContent?.trim() | ||
const manga = new Manga(url, this.siteType) | ||
manga.title = title ?? 'Unknown' | ||
manga.image = imageElem?.querySelectorAll('img')[0]?.getAttribute('src') ?? '' | ||
manga.chapter = chapterCount ?? 'Unknown' | ||
|
||
mangaList.push(manga) | ||
}) | ||
|
||
return { manga: mangaList, count: comics.length } | ||
} | ||
|
||
getTestUrl (): string { | ||
return `${this.getUrl()}/comics/7946-aire` | ||
} | ||
} |
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -18,12 +18,12 @@ export async function testBiliBiliComics (): Promise<void> { | |
async function readUrl (site: BaseSite): Promise<void> { | ||
const manga = await getMangaInfo(site.getTestUrl(), SITE_TYPE) | ||
const desired = new Manga(site.getTestUrl(), SITE_TYPE) | ||
desired.chapter = '654 Shopping at the Heavenly Treasures Pavilion (2)' | ||
desired.chapter = '660 Despicable! (2)' | ||
desired.image = 'https://i0.hdslb.com/bfs/comic-static/[email protected]' | ||
desired.title = 'Tales of Demons and Gods' | ||
desired.chapterUrl = 'https://www.bilibilicomics.com/mc215/271808' | ||
desired.chapterNum = 654 | ||
desired.chapterDate = '16 hours ago' | ||
desired.chapterUrl = 'https://www.bilibilicomics.com/mc215/308329' | ||
desired.chapterNum = 660 | ||
desired.chapterDate = '7 days ago' | ||
|
||
mangaEqual(manga, desired, false) | ||
} | ||
|
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
Oops, something went wrong.