Migrate to coroutine

This commit is contained in:
tom5079
2022-01-02 20:32:00 +09:00
parent a17b7355f5
commit 1b441f6aea
7 changed files with 72 additions and 87 deletions

View File

@@ -75,7 +75,7 @@ data class GalleryBlock(
val relatedTags: List<String>
)
fun getGalleryBlock(galleryID: Int) : GalleryBlock {
suspend fun getGalleryBlock(galleryID: Int) : GalleryBlock {
val url = "$protocol//$domain/$galleryblockdir/$galleryID$extension"
val doc = Jsoup.parse(rewriteTnPaths(URL(url).readText()))
@@ -102,4 +102,4 @@ fun getGalleryBlock(galleryID: Int) : GalleryBlock {
return GalleryBlock(galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
}
fun getGalleryBlockOrNull(galleryID: Int) = runCatching { getGalleryBlock(galleryID) }.getOrNull()
suspend fun getGalleryBlockOrNull(galleryID: Int) = runCatching { getGalleryBlock(galleryID) }.getOrNull()