fix hbrowse cookie issue (#8555)

* fix hbrowse cookie issue

* Update build.gradle

* remove last two invalid elements from array

* improve selector
This commit is contained in:
Basara-Hatake 2021-08-14 22:08:58 +02:00 committed by GitHub
parent f4a3bdd739
commit 5ce1c4ac8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'HBrowse' extName = 'HBrowse'
pkgNameSuffix = 'en.hbrowse' pkgNameSuffix = 'en.hbrowse'
extClass = '.HBrowse' extClass = '.HBrowse'
extVersionCode = 4 extVersionCode = 5
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true containsNsfw = true
} }

View File

@ -9,12 +9,15 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.CookieJar import okhttp3.CookieJar
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import uy.kohesive.injekt.injectLazy
import java.io.IOException import java.io.IOException
@Nsfw @Nsfw
@ -28,6 +31,8 @@ class HBrowse : ParsedHttpSource() {
override val supportsLatest = true override val supportsLatest = true
private val json: Json by injectLazy()
// Clients // Clients
private lateinit var phpSessId: String private lateinit var phpSessId: String
@ -171,14 +176,14 @@ class HBrowse : ParsedHttpSource() {
// Pages // Pages
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
return document.select("td.pageList a").mapIndexed { i, element -> val script = document.select("script:containsData(imageDir)").first().data()
Page(i, element.attr("abs:href")) val imageDir = Regex("""imageDir\s*=\s*"(.+?)";""").find(script)?.groupValues!!.get(1)
} var images = json.decodeFromString<List<String>>(Regex("""list\s*=\s*(\[.+?]);""").find(script)?.groupValues!!.get(1))
images = images.subList(0, images.size - 2)
return images.mapIndexed { index, element -> Page(index, "", baseUrl + imageDir + element) }
} }
override fun imageUrlParse(document: Document): String { override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
return document.select("img#mangaImage").attr("abs:src")
}
// Filters // Filters