fixed nhentai

(cherry picked from commit 02cb2fc4f190e568917b7bbb568e61914794640c)
This commit is contained in:
Rani Sargees 2020-06-09 03:47:01 -04:00 committed by Jobobby04
parent fdc2b37add
commit 34806a2eb6

View File

@ -176,7 +176,7 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
} }
override fun parseIntoMetadata(metadata: NHentaiSearchMetadata, input: Response) { override fun parseIntoMetadata(metadata: NHentaiSearchMetadata, input: Response) {
val json = GALLERY_JSON_REGEX.find(input.body!!.string())!!.groupValues[1] val json = GALLERY_JSON_REGEX.find(input.body!!.string())!!.groupValues[1].replace(UNICODE_ESCAPE_REGEX, { it.groupValues[1].toInt(radix = 16).toString() })
val obj = JsonParser.parseString(json).asJsonObject val obj = JsonParser.parseString(json).asJsonObject
with(metadata) { with(metadata) {
@ -316,7 +316,8 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
} }
companion object { companion object {
private val GALLERY_JSON_REGEX = Regex("new N.gallery\\((.*)\\);") private val GALLERY_JSON_REGEX = Regex(".parse\\(\"(.*)\"\\);")
private val UNICODE_ESCAPE_REGEX = Regex("\\\\u([0-9a-fA-F]{4})")
private const val REVERSE_PARAM = "TEH_REVERSE" private const val REVERSE_PARAM = "TEH_REVERSE"
private fun defaultSortFilterSelection() = Filter.Sort.Selection(0, false) private fun defaultSortFilterSelection() = Filter.Sort.Selection(0, false)