Skip to content

Commit

Permalink
AsuraScans | Fix Detail page parsing and try to fix fuzzy search for …
Browse files Browse the repository at this point in the history
…titles with non word characters like apostrophes
  • Loading branch information
Seyden committed Jul 26, 2024
1 parent a28d0ae commit 8b45d24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/AsuraScans/AsuraScans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ASURASCANS_DOMAIN = 'https://asuracomic.net'
const ASURASCANS_API_DOMAIN = 'https://gg.asuracomic.net'

export const AsuraScansInfo: SourceInfo = {
version: '4.0.9',
version: '4.0.10',
name: 'AsuraScans',
description: 'Extension that pulls manga from AsuraScans',
author: 'Seyden',
Expand Down Expand Up @@ -374,7 +374,7 @@ export class AsuraScans implements ChapterProviding, HomePageSectionsProviding,
.addQueryParameter('page', page.toString())

if (query?.title) {
urlBuilder = urlBuilder.addQueryParameter('name', encodeURIComponent(query?.title.replace(/[’][a-z]*/g, '') ?? ''))
urlBuilder = urlBuilder.addQueryParameter('name', encodeURIComponent(query?.title.replace(/[’‘´`'\-][a-z]*/g, '%') ?? ''))
}

urlBuilder = urlBuilder
Expand Down
14 changes: 2 additions & 12 deletions src/AsuraScans/AsuraScansParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import entities = require('entities')

export class AsuraScansParser {
parseMangaDetails(data: string, mangaId: string, source: any): SourceManga {
let obj = /self.__next_f.push\(\[1,"9:\[\\"\$\\",\\"div\\",null,(.*?)(]\\n"]\))/gm.exec(data)?.[1] ?? '';
if (obj == '') {
throw new Error(`Failed to find page details script for manga ${mangaId}`) // If null, throw error, else parse data to json.
}

obj = extractMangaData(obj.replace(/\\"/g, '"').replace(/\\\\"/g, '\\"'), "comic") ?? ''
const obj = extractMangaData(data.replace(/\\"/g, '"').replace(/\\\\"/g, '\\"'), "comic") ?? ''
if (obj == '') {
throw new Error(`Failed to parse comic object for manga ${mangaId}`) // If null, throw error, else parse data to json.
}
Expand Down Expand Up @@ -89,12 +84,7 @@ export class AsuraScansParser {
}

async parseChapterList(data: string, mangaId: string, source: any): Promise<Chapter[]> {
let obj = /self.__next_f.push\(\[1,"9:\[\\"\$\\",\\"div\\",null,(.*?)(]\\n"]\))/gm.exec(data)?.[1] ?? '';
if (obj == '') {
throw new Error(`Failed to find page details script for manga ${mangaId}`) // If null, throw error, else parse data to json.
}

obj = extractMangaData(obj.replace(/\\"/g, '"').replace(/\\\\"/g, '\\"'), "chapters") ?? ''
const obj = extractMangaData(data.replace(/\\"/g, '"').replace(/\\\\"/g, '\\"'), "chapters") ?? ''
if (obj == '') {
throw new Error(`Failed to parse chapters object for manga ${mangaId}`) // If null, throw error, else parse data to json.
}
Expand Down

0 comments on commit 8b45d24

Please sign in to comment.