Utilizing Glide
Fixed Reader FAB icon Changed to use gallery id instead of galleryblock to open Reader
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package xyz.quaver.hiyobi
|
||||
|
||||
import kotlinx.io.IOException
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.json.content
|
||||
import org.jsoup.Jsoup
|
||||
import xyz.quaver.hitomi.Reader
|
||||
import xyz.quaver.hitomi.ReaderItem
|
||||
import java.net.URL
|
||||
@@ -12,13 +12,15 @@ import javax.net.ssl.HttpsURLConnection
|
||||
const val hiyobi = "xn--9w3b15m8vo.asia"
|
||||
const val user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
|
||||
|
||||
var cookie: String = ""
|
||||
get() {
|
||||
if (field.isEmpty())
|
||||
field = renewCookie()
|
||||
class HiyobiReader(title: String, readerItems: List<ReaderItem>) : Reader(title, readerItems)
|
||||
|
||||
return field
|
||||
}
|
||||
var cookie: String = ""
|
||||
get() {
|
||||
if (field.isEmpty())
|
||||
field = renewCookie()
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
fun renewCookie() : String {
|
||||
val url = "https://$hiyobi/"
|
||||
@@ -35,26 +37,25 @@ fun renewCookie() : String {
|
||||
}
|
||||
}
|
||||
|
||||
fun getReader(galleryId: Int) : Reader {
|
||||
val url = "https://$hiyobi/data/json/${galleryId}_list.json"
|
||||
fun getReader(galleryID: Int) : Reader {
|
||||
val reader = "https://$hiyobi/reader/$galleryID"
|
||||
val url = "https://$hiyobi/data/json/${galleryID}_list.json"
|
||||
|
||||
try {
|
||||
val json = Json(JsonConfiguration.Stable).parseJson(
|
||||
with(URL(url).openConnection() as HttpsURLConnection) {
|
||||
setRequestProperty("User-Agent", user_agent)
|
||||
setRequestProperty("Cookie", cookie)
|
||||
connectTimeout = 2000
|
||||
connect()
|
||||
val title = Jsoup.connect(reader).get().title()
|
||||
|
||||
inputStream.bufferedReader().use { it.readText() }
|
||||
}
|
||||
)
|
||||
val json = Json(JsonConfiguration.Stable).parseJson(
|
||||
with(URL(url).openConnection() as HttpsURLConnection) {
|
||||
setRequestProperty("User-Agent", user_agent)
|
||||
setRequestProperty("Cookie", cookie)
|
||||
connectTimeout = 2000
|
||||
connect()
|
||||
|
||||
return json.jsonArray.map {
|
||||
val name = it.jsonObject["name"]!!.content
|
||||
ReaderItem("https://$hiyobi/data/$galleryId/$name", null)
|
||||
inputStream.bufferedReader().use { it.readText() }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
)
|
||||
|
||||
return Reader(title, json.jsonArray.map {
|
||||
val name = it.jsonObject["name"]!!.content
|
||||
ReaderItem("https://$hiyobi/data/$galleryID/$name", null)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user