@@ -22,7 +22,7 @@ class PlayerController(
2222 val botProps : BotProps
2323) {
2424
25-
25+ private val log = org.slf4j. LoggerFactory .getLogger( PlayerController :: class .java)
2626
2727 @GetMapping(" /guilds" )
2828 fun getGuilds (): List <GuildDto > {
@@ -97,7 +97,7 @@ class PlayerController(
9797 }
9898
9999 var identifiers = (body[" url" ] ? : " " ).split(" |" )
100- // ... (rest of play method logic)
100+ // ... (rest of play method logic)
101101 if (identifiers.isNotEmpty() && identifiers.first().isEmpty()) {
102102 identifiers = botProps.playlist.split(" |" )
103103 }
@@ -106,35 +106,43 @@ class PlayerController(
106106
107107 identifiers.forEach { identifier ->
108108 val matcher = pattern.matcher(identifier)
109+ var source = identifier
110+ var queueLabel = " "
109111 if (matcher.find() && matcher.groupCount() == 2 ) {
110- // val queueLabel = if (matcher.group(1) != null) matcher.group(1) else ""
111- val source = if (matcher.group(2 ) != null ) matcher.group(2 ) else " "
112-
113- if (source.isNotEmpty()) {
114- apm.loadItemOrdered(player, source, object : AudioLoadResultHandler {
115- override fun trackLoaded (track : AudioTrack ) {
116- if (botProps.prependQueueLabelToTitle && matcher.group(1 ) != null ) {
117- track.info.title = " ${matcher.group(1 )} - ${track.info.title} "
118- }
119- player.add(track)
112+ if (matcher.group(1 ) != null ) queueLabel = matcher.group(1 )
113+ if (matcher.group(2 ) != null ) source = matcher.group(2 )
114+ } else {
115+ log.warn(" Pattern match failed for identifier: '{}', attempting to load as raw URL" , identifier)
116+ }
117+
118+ if (source.isNotEmpty()) {
119+ apm.loadItemOrdered(player, source, object : AudioLoadResultHandler {
120+ override fun trackLoaded (track : AudioTrack ) {
121+ if (botProps.prependQueueLabelToTitle && queueLabel.isNotEmpty()) {
122+ track.info.title = " $queueLabel - ${track.info.title} "
120123 }
121-
122- override fun playlistLoaded (playlist : AudioPlaylist ) {
123- if (playlist.isSearchResult) {
124- val track = playlist.tracks.first()
125- if (botProps.prependQueueLabelToTitle && matcher.group(1 ) != null ) {
126- track.info.title = " ${matcher.group(1 )} - ${track.info.title} "
127- }
128- player.add(track)
129- } else {
130- player.add(* playlist.tracks.toTypedArray())
124+ player.add(track)
125+ }
126+
127+ override fun playlistLoaded (playlist : AudioPlaylist ) {
128+ if (playlist.isSearchResult) {
129+ val track = playlist.tracks.first()
130+ if (botProps.prependQueueLabelToTitle && queueLabel.isNotEmpty()) {
131+ track.info.title = " $queueLabel - ${track.info.title} "
131132 }
133+ player.add(track)
134+ } else {
135+ player.add(* playlist.tracks.toTypedArray())
132136 }
133-
134- override fun noMatches () {}
135- override fun loadFailed (exception : FriendlyException ) {}
136- })
137- }
137+ }
138+
139+ override fun noMatches () {
140+ log.warn(" No matches found for source: {}" , source)
141+ }
142+ override fun loadFailed (exception : FriendlyException ) {
143+ log.error(" Load failed for source: {}" , source, exception)
144+ }
145+ })
138146 }
139147 }
140148 }
0 commit comments