[BatCave] Small fix for getDetails (#1994)
This commit is contained in:
@@ -106,9 +106,16 @@ internal class BatCave(context: MangaLoaderContext) :
|
||||
val dateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.US)
|
||||
|
||||
val scriptData = doc.selectFirst("script:containsData(__DATA__)")?.data()
|
||||
?.substringAfter("window.__DATA__ = ")
|
||||
?.substringBefore(";")
|
||||
?: doc.parseFailed("Script data not found")
|
||||
?.let { data ->
|
||||
val jsonStart = data.indexOf("window.__DATA__ = ") + "window.__DATA__ = ".length
|
||||
val jsonEnd = data.indexOf("};", startIndex = jsonStart)
|
||||
if (jsonEnd != -1) {
|
||||
// substring, include "}" symbol
|
||||
data.substring(jsonStart, jsonEnd + 1)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} ?: doc.parseFailed("Script data not found")
|
||||
|
||||
val jsonData = JSONObject(scriptData)
|
||||
val newsId = jsonData.getLong("news_id")
|
||||
|
||||
Reference in New Issue
Block a user