Skip to content

Commit

Permalink
Fix img parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNetsky committed Sep 24, 2024
1 parent c5dcf38 commit 930c44b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/AsuraScans/AsuraScans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ASURASCANS_DOMAIN = 'https://asuracomic.net'
const ASURASCANS_API_DOMAIN = 'https://gg.asuracomic.net'

export const AsuraScansInfo: SourceInfo = {
version: '4.2.0',
version: '4.2.1',
name: 'AsuraScans',
description: 'Extension that pulls manga from AsuraScans',
author: 'Seyden',
Expand Down Expand Up @@ -343,7 +343,9 @@ export class AsuraScans implements ChapterProviding, HomePageSectionsProviding,
const chapterLink: string = await this.getChapterSlug(mangaId, chapterId)
const url: string = await this.getBaseUrl()
const data = await this.loadRequestData(`${url}/${chapterLink}/`)
return this.parser.parseChapterDetails(data, mangaId, chapterId)
const $ = this.cheerio.load(data)

return this.parser.parseChapterDetails($, mangaId, chapterId)
}

async getSearchTags(): Promise<TagSection[]> {
Expand Down
14 changes: 7 additions & 7 deletions src/AsuraScans/AsuraScansParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ export class AsuraScansParser {
})
}

parseChapterDetails(data: string, mangaId: string, chapterId: string): ChapterDetails {
const pages = new Set<string>()
parseChapterDetails($: CheerioStatic, mangaId: string, chapterId: string): ChapterDetails {
const pages: string[] = []

const matches = data.matchAll(/(https:\/\/gg\.asuracomic\.net\/storage\/comics\/[^"\\]+)/gi)
for (const match of Array.from(matches)) {
const url = (match[1] ?? '').replace(' ', '%20')
pages.add(url)
for (const img of $('img', 'div.py-8.-mx-5').toArray()) {
const image = $(img).attr('src') ?? ''
if (!image) continue
pages.push(image.trim())
}

return App.createChapterDetails({
id: chapterId,
mangaId,
pages: [...pages]
pages: pages
})
}

Expand Down

0 comments on commit 930c44b

Please sign in to comment.