Fix mangalib chapter page parse (#3133)

Fix mangalib chapter page parse
This commit is contained in:
Pavka 2020-05-12 17:36:12 +03:00 committed by GitHub
parent d8c07bd399
commit 27252e718f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaLib' appName = 'Tachiyomi: MangaLib'
pkgNameSuffix = 'ru.libmanga' pkgNameSuffix = 'ru.libmanga'
extClass = '.LibManga' extClass = '.LibManga'
extVersionCode = 17 extVersionCode = 18
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -4,7 +4,6 @@ import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.support.v7.preference.ListPreference import android.support.v7.preference.ListPreference
import android.support.v7.preference.PreferenceScreen import android.support.v7.preference.PreferenceScreen
import android.util.Base64.decode as base64Decode
import com.github.salomonbrys.kotson.array import com.github.salomonbrys.kotson.array
import com.github.salomonbrys.kotson.get import com.github.salomonbrys.kotson.get
import com.github.salomonbrys.kotson.int import com.github.salomonbrys.kotson.int
@ -190,7 +189,8 @@ class LibManga : ConfigurableSource, HttpSource() {
rawCategory.isNotBlank() -> rawCategory.toLowerCase() rawCategory.isNotBlank() -> rawCategory.toLowerCase()
else -> "манга" else -> "манга"
} }
val genres = body.select(".info-list__row:has(strong:contains(Жанры)) > a").text()
val genres = body.select(".info-list__row:has(strong:contains(Жанры)) > a").map { it.text() }
manga.title = document.select(".manga-title small").text().substringBefore("/").trim() manga.title = document.select(".manga-title small").text().substringBefore("/").trim()
manga.thumbnail_url = body.select(".manga__cover").attr("src") manga.thumbnail_url = body.select(".manga__cover").attr("src")
manga.author = body.select(".info-list__row:nth-child(2) > a").text() manga.author = body.select(".info-list__row:nth-child(2) > a").text()
@ -204,7 +204,7 @@ class LibManga : ConfigurableSource, HttpSource() {
"завершен" -> SManga.COMPLETED "завершен" -> SManga.COMPLETED
else -> SManga.UNKNOWN else -> SManga.UNKNOWN
} }
manga.genre = genres.split(",").plusElement(category).joinToString { it.trim() } manga.genre = genres.plusElement(category).joinToString { it.trim() }
manga.description = body.select(".info-desc__content").text() manga.description = body.select(".info-desc__content").text()
return manga return manga
} }
@ -255,8 +255,9 @@ class LibManga : ConfigurableSource, HttpSource() {
.select("script:containsData(window.__info)") .select("script:containsData(window.__info)")
.first() .first()
.html() .html()
.replace("window.__info = ", "") .trim()
.replace(";", "") .removePrefix("window.__info = ")
.removeSuffix(";")
val chapInfoJson = jsonParser.parse(chapInfo).obj val chapInfoJson = jsonParser.parse(chapInfo).obj
val servers = chapInfoJson["servers"].asJsonObject val servers = chapInfoJson["servers"].asJsonObject
@ -267,15 +268,15 @@ class LibManga : ConfigurableSource, HttpSource() {
val imageServerUrl: String = servers[serverToUse].string val imageServerUrl: String = servers[serverToUse].string
// Get pages // Get pages
val baseStr = document.select("span.pp") val pagesArr = document
.select("script:containsData(window.__pg)")
.first() .first()
.html() .html()
.replace("<!--", "")
.replace("-->", "")
.trim() .trim()
.removePrefix("window.__pg = ")
.removeSuffix(";")
val decodedArr = base64Decode(baseStr, android.util.Base64.DEFAULT) val pagesJson = jsonParser.parse(pagesArr).array
val pagesJson = jsonParser.parse(String(decodedArr)).array
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
pagesJson.forEach { page -> pagesJson.forEach { page ->