- debug searchYoutube fun (6x)
This commit is contained in:
dalbodeule
2024-08-06 21:05:39 +09:00
parent e8bee6ff23
commit 76ffebc157

View File

@@ -35,12 +35,14 @@ fun searchYoutube(query: String): String? {
val responseBody = response.body?.string()
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 videoUrl = firstItem.get("link").asString
val firstVideo = videos.get(0).asJsonObject
logger.info(firstVideo.toString())
val videoUrl = firstVideo.get("link").asString
return videoUrl
}