Continue removing Outcome class in favor of Result (search suggestions)

This commit is contained in:
vfsfitvnm
2022-07-01 19:41:52 +02:00
parent 14f46429ef
commit 17cf2454c7
2 changed files with 23 additions and 22 deletions

View File

@@ -420,19 +420,21 @@ object YouTube {
}.recoverIfCancelled()
}
suspend fun getSearchSuggestions(input: String): Outcome<List<String>?> {
return client.postCatching("/youtubei/v1/music/get_search_suggestions") {
contentType(ContentType.Application.Json)
setBody(
GetSearchSuggestionsBody(
context = Context.DefaultWeb,
input = input
suspend fun getSearchSuggestions(input: String): Result<List<String>?>? {
return runCatching {
val body = client.post("/youtubei/v1/music/get_search_suggestions") {
contentType(ContentType.Application.Json)
setBody(
GetSearchSuggestionsBody(
context = Context.DefaultWeb,
input = input
)
)
)
parameter("key", Key)
parameter("prettyPrint", false)
}.bodyCatching<GetSearchSuggestionsResponse>().map { response ->
response
parameter("key", Key)
parameter("prettyPrint", false)
}.body<GetSearchSuggestionsResponse>()
body
.contents
?.flatMap { content ->
content
@@ -445,7 +447,7 @@ object YouTube {
?.query
}
}
}
}.recoverIfCancelled()
}
suspend fun player(videoId: String, playlistId: String? = null): Outcome<PlayerResponse> {