- debug searchYoutube fun (6x)
This commit is contained in:
dalbodeule 2024-08-06 21:05:39 +09:00
parent e8bee6ff23
commit 76ffebc157
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65

View File

@ -35,12 +35,14 @@ fun searchYoutube(query: String): String? {
val responseBody = response.body?.string() val responseBody = response.body?.string()
val json = gson.fromJson(responseBody, JsonObject::class.java) val json = gson.fromJson(responseBody, JsonObject::class.java)
val items = json.getAsJsonArray("videos")
if (items.size() == 0) return null val videos = json.getAsJsonArray("videos")
val firstItem = items[0].asJsonObject val firstVideo = videos.get(0).asJsonObject
val videoUrl = firstItem.get("link").asString
logger.info(firstVideo.toString())
val videoUrl = firstVideo.get("link").asString
return videoUrl return videoUrl
} }