chisu playlist fix

- if youtube video limited 10-min
- add youtube music regex.
This commit is contained in:
dalbodeule 2024-08-16 08:42:53 +09:00
parent 35d8759ee3
commit 89dda9742a
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
2 changed files with 7 additions and 3 deletions

View File

@ -16,7 +16,6 @@ import xyz.r2turntrue.chzzk4j.chat.ChzzkChat
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit import java.time.temporal.ChronoUnit
import java.util.UUID
class MessageHandler( class MessageHandler(
@ -246,6 +245,11 @@ class MessageHandler(
return return
} }
if (video.length > 600) {
listener.sendChat("10분이 넘는 노래는 신청할 수 없습니다.")
return
}
SongListService.saveSong( SongListService.saveSong(
user, user,
msg.userId, msg.userId,
@ -270,7 +274,7 @@ class MessageHandler(
) )
} }
listener.sendChat("노래가 추가되었습니다.") listener.sendChat("노래가 추가되었습니다. ${video.name} - ${video.author}")
} catch(e: Exception) { } catch(e: Exception) {
listener.sendChat("유튜브 영상 주소로 다시 신청해주세요!") listener.sendChat("유튜브 영상 주소로 다시 신청해주세요!")
logger.info(e.stackTraceToString()) logger.info(e.stackTraceToString())

View File

@ -15,7 +15,7 @@ data class YoutubeVideo(
val length: Int 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 durationRegex = """PT(\d+H)?(\d+M)?(\d+S)?""".toRegex()
val dotenv = dotenv { val dotenv = dotenv {