Skip to content

Commit

Permalink
Fix nhentai homepage sections not working (TheNetsky#45)
Browse files Browse the repository at this point in the history
* Fix sections not working

* Update NHentai version
  • Loading branch information
Ivanmatthew authored Apr 26, 2024
1 parent 8dd9c90 commit 47575b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/NHentai/NHentai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TagSection
} from '@paperback/types'

import { NHSortOrders } from './NHentaiHelper'
import { hasNoResults, NHSortOrders } from './NHentaiHelper'

import {
parseMangaDetails,
Expand All @@ -43,7 +43,7 @@ import { popularTags } from './tags.json'
const NHENTAI_URL = 'https://nhentai.net'

export const NHentaiInfo: SourceInfo = {
version: '4.0.6',
version: '4.0.7',
name: 'nhentai',
icon: 'icon.png',
author: 'NotMarek & Netsky',
Expand Down Expand Up @@ -236,20 +236,7 @@ export class NHentai implements SearchResultsProviding, MangaProviding, ChapterP
containsMoreItems: true,
type: HomeSectionType.singleRowNormal
})
},
{
request: App.createRequest({
url: `${NHENTAI_URL}/api/galleries/search?query=${await this.generateQuery()}&sort=popular`,
method: 'GET'
}),
sectionID: App.createHomeSection({
id: 'popular',
title: 'Popular All-Time',
containsMoreItems: true,
type: HomeSectionType.singleRowNormal
})
}

]

const promises: Promise<void>[] = []
Expand All @@ -261,7 +248,11 @@ export class NHentai implements SearchResultsProviding, MangaProviding, ChapterP
.then(response => {
this.CloudFlareError(response.status)
const jsonData = this.parseJson(response)
if (hasNoResults(jsonData)) {
return
}
section.sectionID.items = parseSearch(jsonData)

sectionCallback(section.sectionID)
})
)
Expand Down
10 changes: 10 additions & 0 deletions src/NHentai/NHentaiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,13 @@ class NHSortOrderClass {
}

export const NHSortOrders = new NHSortOrderClass()

export function hasNoResults(data: any): boolean {
console.log(data)
if (data.error) {
console.error(data.error)
return true
}

return false
}

0 comments on commit 47575b2

Please sign in to comment.