Changed galleryblock retrieve url

This commit is contained in:
Pupil
2020-02-14 20:31:10 +09:00
parent 066d73b217
commit 85d01f60f1

View File

@@ -22,28 +22,24 @@ import xyz.quaver.hitomi.GalleryBlock
import xyz.quaver.hitomi.protocol import xyz.quaver.hitomi.protocol
fun getGalleryBlock(galleryID: Int) : GalleryBlock? { fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
val url = "$protocol//$hiyobi/search/$galleryID" val url = "$protocol//$hiyobi/info/$galleryID"
try { val doc = Jsoup.connect(url).get()
val doc = Jsoup.connect(url).get()
val galleryBlock = doc.selectFirst(".gallery-content") val galleryBlock = doc.selectFirst(".gallery-content")
val galleryUrl = galleryBlock.selectFirst("a").attr("href") val galleryUrl = galleryBlock.selectFirst("a").attr("href")
val thumbnails = listOf(galleryBlock.selectFirst("img").attr("abs:src")) val thumbnails = listOf(galleryBlock.selectFirst("img").attr("abs:src"))
val title = galleryBlock.selectFirst("b").text() val title = galleryBlock.selectFirst("b").text()
val artists = galleryBlock.select("tr:matches(작가) a[href~=artist]").map { it.text() } val artists = galleryBlock.select("tr:matches(작가) a[href~=artist]").map { it.text() }
val series = galleryBlock.select("tr:matches(원작) a").map { it.attr("href").substringAfter("series:").replace('_', ' ') } val series = galleryBlock.select("tr:matches(원작) a").map { it.attr("href").substringAfter("series:").replace('_', ' ') }
val type = galleryBlock.selectFirst("tr:matches(종류) a").attr("href").substringAfter("type:").replace('_', ' ') val type = galleryBlock.selectFirst("tr:matches(종류) a").attr("href").substringAfter("type:").replace('_', ' ')
val language = "korean" val language = "korean"
val relatedTags = galleryBlock.select("tr:matches(태그) a").map { it.attr("href").substringAfterLast('/').replace('_', ' ') } val relatedTags = galleryBlock.select("tr:matches(태그) a").map { it.attr("href").substringAfterLast('/').replace('_', ' ') }
return GalleryBlock(Code.HIYOBI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags) return GalleryBlock(Code.HIYOBI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
} catch (e: Exception) {
return null
}
} }