From 89dda9742a59ebaefcac61b85755125119f90314 Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:42:53 +0900 Subject: [PATCH] chisu playlist fix - if youtube video limited 10-min - add youtube music regex. --- .../space/mori/chzzk_bot/chatbot/chzzk/MessageHandler.kt | 8 ++++++-- .../space/mori/chzzk_bot/common/utils/getYoutube.kt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/MessageHandler.kt b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/MessageHandler.kt index fddc64d..28fc278 100644 --- a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/MessageHandler.kt +++ b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/MessageHandler.kt @@ -16,7 +16,6 @@ import xyz.r2turntrue.chzzk4j.chat.ChzzkChat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.time.temporal.ChronoUnit -import java.util.UUID class MessageHandler( @@ -246,6 +245,11 @@ class MessageHandler( return } + if (video.length > 600) { + listener.sendChat("10분이 넘는 노래는 신청할 수 없습니다.") + return + } + SongListService.saveSong( user, msg.userId, @@ -270,7 +274,7 @@ class MessageHandler( ) } - listener.sendChat("노래가 추가되었습니다.") + listener.sendChat("노래가 추가되었습니다. ${video.name} - ${video.author}") } catch(e: Exception) { listener.sendChat("유튜브 영상 주소로 다시 신청해주세요!") logger.info(e.stackTraceToString()) diff --git a/common/src/main/kotlin/space/mori/chzzk_bot/common/utils/getYoutube.kt b/common/src/main/kotlin/space/mori/chzzk_bot/common/utils/getYoutube.kt index c94120a..01db71e 100644 --- a/common/src/main/kotlin/space/mori/chzzk_bot/common/utils/getYoutube.kt +++ b/common/src/main/kotlin/space/mori/chzzk_bot/common/utils/getYoutube.kt @@ -15,7 +15,7 @@ data class YoutubeVideo( val length: Int ) -val regex = ".*(?:youtu.be/|v/|u/\\w/|embed/|watch\\?v=|&v=)([^#&?]*).*".toRegex() +val regex = ".*(?:youtu.be/|v/|u/\\w/|embed/|watch\\?v=|&v=|music\\.youtube\\.com/.*?\\?v=)([^#&?]*).*".toRegex() val durationRegex = """PT(\d+H)?(\d+M)?(\d+S)?""".toRegex() val dotenv = dotenv {