Fixed not able to load from hiyobi

This commit is contained in:
Pupil
2020-02-17 16:46:51 +09:00
parent 98d1f88579
commit 1dbfc64f37
2 changed files with 7 additions and 4 deletions

View File

@@ -155,9 +155,11 @@ class Cache(context: Context) : ContextWrapper(context) {
var retval: Reader? = null
for (source in sources) {
retval = kotlin.runCatching {
retval = try {
source.value.invoke()
}.getOrNull()
} catch (e: Exception) {
null
}
if (retval != null)
break

View File

@@ -16,6 +16,7 @@
package xyz.quaver.hiyobi
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.Json
import kotlinx.serialization.list
import org.jsoup.Jsoup
@@ -58,14 +59,14 @@ fun renewCookie() : String {
}
}
@UseExperimental(UnstableDefault::class)
fun getReader(galleryID: Int) : Reader {
val reader = "https://$hiyobi/reader/$galleryID"
val url = "https://$hiyobi/data/json/${galleryID}_list.json"
val title = Jsoup.connect(reader).get().title()
@Suppress("EXPERIMENTAL_API_USAGE")
val galleryInfo = Json.parse(
val galleryInfo = Json.nonstrict.parse(
GalleryInfo.serializer().list,
with(URL(url).openConnection() as HttpsURLConnection) {
setRequestProperty("User-Agent", user_agent)