mirror of
https://github.com/yuzono/anime-extensions.git
synced 2026-06-13 13:39:44 +00:00
refactor(RouVideo): use 'use' for resource management in network calls
This commit is contained in:
@@ -108,7 +108,7 @@ class RouVideo(
|
||||
async {
|
||||
client.newCall(relatedAnimeListRequest(anime))
|
||||
.execute()
|
||||
.let { response ->
|
||||
.use { response ->
|
||||
relatedAnimeListParse(response)
|
||||
}
|
||||
},
|
||||
@@ -324,11 +324,13 @@ class RouVideo(
|
||||
runCatching {
|
||||
client.newCall(tagsListRequest())
|
||||
.execute()
|
||||
.asJsoup()
|
||||
.let(::tagsListParse)
|
||||
.let { tags ->
|
||||
if (tags.isNotEmpty()) {
|
||||
tagsArray = tags
|
||||
.use {
|
||||
it.asJsoup()
|
||||
.let(::tagsListParse)
|
||||
.let { tags ->
|
||||
if (tags.isNotEmpty()) {
|
||||
tagsArray = tags
|
||||
}
|
||||
}
|
||||
}
|
||||
}.onFailure { it.printStackTrace() }
|
||||
@@ -367,13 +369,15 @@ class RouVideo(
|
||||
runCatching {
|
||||
client.newCall(hotSearchRequest())
|
||||
.execute()
|
||||
.asJsoup()
|
||||
.let(::hotSearchParse)
|
||||
.let {
|
||||
hotSearch = if (!this::hotSearch.isInitialized) {
|
||||
it
|
||||
} else {
|
||||
hotSearch.plus(it)
|
||||
.use {
|
||||
it.asJsoup()
|
||||
.let(::hotSearchParse)
|
||||
.let {
|
||||
hotSearch = if (!this::hotSearch.isInitialized) {
|
||||
it
|
||||
} else {
|
||||
hotSearch.plus(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.onFailure { it.printStackTrace() }
|
||||
@@ -397,7 +401,7 @@ class RouVideo(
|
||||
?.groupValues?.get(1)
|
||||
return client.newCall(animeDetailsRequest(anime))
|
||||
.execute()
|
||||
.let { response ->
|
||||
.use { response ->
|
||||
parseAnimeDetails(response, resolution)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user