Skip to content

Commit

Permalink
Bato: Fix chapter details parsing (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seyden authored Feb 1, 2024
1 parent 86d0113 commit 77866bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/BatoTo/BatoTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
const BATO_DOMAIN = 'https://bato.to'

export const BatoToInfo: SourceInfo = {
version: '3.0.3',
version: '3.0.4',
name: 'BatoTo',
icon: 'icon.png',
author: 'Nicholas',
Expand Down
5 changes: 1 addition & 4 deletions src/BatoTo/BatoToParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const parseChapterList = ($: CheerioStatic, mangaId: string): Chapter[] =
}

export const parseChapterDetails = ($: CheerioStatic, mangaId: string, chapterId: string): ChapterDetails => {
const pages: string[] = []
// Get all of the pages
const scriptObj = $('script').toArray().find((obj: CheerioElement) => {
const data = obj.children[0]?.data ?? ''
Expand All @@ -142,9 +141,7 @@ export const parseChapterDetails = ($: CheerioStatic, mangaId: string, chapterId
const imgList = JSON.parse(script.match(/const\s+imgHttps\s*=\s*(.*?);/)?.[1] ?? '')
const tknList = JSON.parse(CryptoJS.AES.decrypt(batoWord, batoPass).toString(CryptoJS.enc.Utf8))

for (let i = 0; i < Math.min(imgList.length, tknList.length); i++) {
pages.push(`${imgList[i]}?${tknList[i]}`)
}
const pages = imgList.map((value: string, index: number) => `${value}?${tknList[index]}`)

const chapterDetails = App.createChapterDetails({
id: chapterId,
Expand Down

0 comments on commit 77866bf

Please sign in to comment.