Skip to content

Commit

Permalink
use matcher.find instead if matcher.matches for spotify urls
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Nov 13, 2021
1 parent 580139e commit 286acbb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/de/kittybot/kittybot/modules/MusicModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class MusicModule extends Module implements Serializable{

public static final Pattern URL_PATTERN = Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]?");
public static final Pattern SPOTIFY_URL_PATTERN = Pattern.compile("^(https?://)?(www\\.)?open\\.spotify\\.com/(user/[a-zA-Z0-9-_]+/)?(?<type>track|album|playlist)/(?<identifier>[a-zA-Z0-9-_]+)");
public static final Pattern SPOTIFY_URL_PATTERN = Pattern.compile("(https?://)?(www\\.)?open\\.spotify\\.com/(user/[a-zA-Z0-9-_]+/)?(?<type>track|album|playlist)/(?<identifier>[a-zA-Z0-9-_]+)");

private Map<Long, MusicManager> musicPlayers;

Expand Down Expand Up @@ -203,7 +203,7 @@ public void play(GuildInteraction ia, String query, SearchProvider searchProvide
var manager = this.musicPlayers.computeIfAbsent(ia.getGuildId(), guildId -> new MusicManager(this.modules, guildId, ia.getChannelId()));

var matcher = SPOTIFY_URL_PATTERN.matcher(query);
if(matcher.matches()){
if(matcher.find()){
this.modules.get(SpotifyModule.class).load(ia, manager, matcher);
return;
}
Expand Down

0 comments on commit 286acbb

Please sign in to comment.