@@ -73,10 +73,8 @@ class PlayerController(
7373 val guild = shardManager.getGuildById(guildId) ? : throw RuntimeException (" Guild not found" )
7474 val properties = guildPropertiesService.getAwait(guildId)
7575 val player = playerRegistry.get(guild, properties)
76- val identifier = body[" url" ] ? : throw RuntimeException (" No URL provided" )
77- val channelId = body[" channelId" ]
78-
7976 // Ensure connected to voice
77+ val channelId = body[" channelId" ]
8078 if (! guild.audioManager.isConnected) {
8179 val channel = if (channelId != null ) {
8280 guild.getVoiceChannelById(channelId)
@@ -90,22 +88,46 @@ class PlayerController(
9088 }
9189 }
9290
93- apm.loadItemOrdered(player, identifier, object : AudioLoadResultHandler {
94- override fun trackLoaded ( track : AudioTrack ) {
95- player.add(track )
96- }
91+ var identifiers = (body[ " url " ] ? : " " ).split( " | " )
92+ if (identifiers.isNotEmpty() && identifiers.first().isEmpty() ) {
93+ identifiers = botProps.playlist.split( " | " )
94+ }
9795
98- override fun playlistLoaded (playlist : AudioPlaylist ) {
99- if (playlist.isSearchResult) {
100- player.add(playlist.tracks.first())
101- } else {
102- player.add(* playlist.tracks.toTypedArray())
96+ val pattern = java.util.regex.Pattern .compile(" ^\\ s*(\\ [.*])?\\ s*(\\ S+.*)$" )
97+
98+ identifiers.forEach { identifier ->
99+ val matcher = pattern.matcher(identifier)
100+ if (matcher.find() && matcher.groupCount() == 2 ) {
101+ // val queueLabel = if (matcher.group(1) != null) matcher.group(1) else ""
102+ val source = if (matcher.group(2 ) != null ) matcher.group(2 ) else " "
103+
104+ if (source.isNotEmpty()) {
105+ apm.loadItemOrdered(player, source, object : AudioLoadResultHandler {
106+ override fun trackLoaded (track : AudioTrack ) {
107+ if (botProps.prependQueueLabelToTitle && matcher.group(1 ) != null ) {
108+ track.info.title = " ${matcher.group(1 )} - ${track.info.title} "
109+ }
110+ player.add(track)
111+ }
112+
113+ override fun playlistLoaded (playlist : AudioPlaylist ) {
114+ if (playlist.isSearchResult) {
115+ val track = playlist.tracks.first()
116+ if (botProps.prependQueueLabelToTitle && matcher.group(1 ) != null ) {
117+ track.info.title = " ${matcher.group(1 )} - ${track.info.title} "
118+ }
119+ player.add(track)
120+ } else {
121+ player.add(* playlist.tracks.toTypedArray())
122+ }
123+ }
124+
125+ override fun noMatches () {}
126+ override fun loadFailed (exception : FriendlyException ) {}
127+ })
103128 }
104129 }
105-
106- override fun noMatches () {}
107- override fun loadFailed (exception : FriendlyException ) {}
108- })
130+ }
109131 }
110132
111133 @PostMapping(" /player/{guildId}/pause" )
0 commit comments