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

View File

@ -42,16 +42,20 @@ fun searchYoutube(query: String): String? {
logger.info(firstVideo.toString())
val videoUrl = firstVideo.get("link").asString
val videoId = firstVideo.get("id").asString
return videoUrl
return videoId
}
}
fun getYoutubeVideoId(query: String): String? {
val matchResult = regex.find(query)
return matchResult?.groups?.get(1)?.value ?: searchYoutube(query)
return if(matchResult == null) {
searchYoutube(query)
} else {
matchResult.groups[1]?.value
}
}
fun parseDuration(duration: String): Int {