parent
399540fda3
commit
243f4529c6
@ -3,7 +3,7 @@ ext {
|
|||||||
extClass = '.BarManga'
|
extClass = '.BarManga'
|
||||||
themePkg = 'madara'
|
themePkg = 'madara'
|
||||||
baseUrl = 'https://libribar.com'
|
baseUrl = 'https://libribar.com'
|
||||||
overrideVersionCode = 5
|
overrideVersionCode = 6
|
||||||
isNsfw = false
|
isNsfw = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,31 +17,30 @@ class BarManga : Madara(
|
|||||||
|
|
||||||
override val mangaDetailsSelectorDescription = "div.flamesummary > div.manga-excerpt"
|
override val mangaDetailsSelectorDescription = "div.flamesummary > div.manga-excerpt"
|
||||||
|
|
||||||
private val newImageUrlRegex = """var u1 = '([A-Za-z0-9+/=]+)';\s*var u2 = '([A-Za-z0-9+/=]+)';""".toRegex()
|
|
||||||
override val pageListParseSelector = "div.page-break"
|
override val pageListParseSelector = "div.page-break"
|
||||||
|
|
||||||
|
private val imageSegmentsRegex = """var\s+imageSegments\s*=\s*\[\s*(['"][A-Za-z0-9+/=]+['"](?:\s*,\s*['"][A-Za-z0-9+/=]+['"])*)\s*];""".toRegex()
|
||||||
|
private val base64ItemRegex = """['"]([A-Za-z0-9+/=]+)['"]""".toRegex()
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
launchIO { countViews(document) }
|
launchIO { countViews(document) }
|
||||||
|
|
||||||
return document.select(pageListParseSelector).mapIndexedNotNull { index, element ->
|
return document.select(pageListParseSelector).mapIndexedNotNull { index, element ->
|
||||||
val scripts = element.select("script")
|
val scriptData = element.select("script").firstNotNullOfOrNull { script ->
|
||||||
|
|
||||||
val scriptData = scripts.firstNotNullOfOrNull { script ->
|
|
||||||
val data = script.data()
|
val data = script.data()
|
||||||
if (data.contains("var u1") && data.contains("var u2")) {
|
if (data.contains("var imageSegments")) data else null
|
||||||
data
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
} ?: return@mapIndexedNotNull null
|
} ?: return@mapIndexedNotNull null
|
||||||
|
|
||||||
val match = newImageUrlRegex.find(scriptData) ?: return@mapIndexedNotNull null
|
val match = imageSegmentsRegex.find(scriptData) ?: return@mapIndexedNotNull null
|
||||||
val (b64part1, b64part2) = match.destructured
|
val arrayContent = match.groupValues[1]
|
||||||
|
|
||||||
val part1 = String(Base64.decode(b64part1, Base64.DEFAULT))
|
val segments = base64ItemRegex.findAll(arrayContent).map { it.groupValues[1] }.toList()
|
||||||
val part2 = String(Base64.decode(b64part2, Base64.DEFAULT))
|
if (segments.isEmpty()) return@mapIndexedNotNull null
|
||||||
|
|
||||||
Page(index, document.location(), part1 + part2)
|
val joinedBase64 = segments.joinToString("")
|
||||||
|
val imageUrl = String(Base64.decode(joinedBase64, Base64.DEFAULT))
|
||||||
|
|
||||||
|
Page(index, document.location(), imageUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user