From 9f6c7f63d3b5971b7b3f0555bed187238b041d30 Mon Sep 17 00:00:00 2001 From: KagChi <59391215+KagChi@users.noreply.github.com> Date: Wed, 26 Jun 2024 20:09:26 +0700 Subject: [PATCH] fix: add title query pattern only --- .../mirror/DefaultMirroringAudioTrackResolver.java | 13 +++++++++++-- .../lavasrc/mirror/MirroringAudioSourceManager.java | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/com/github/topi314/lavasrc/mirror/DefaultMirroringAudioTrackResolver.java b/main/src/main/java/com/github/topi314/lavasrc/mirror/DefaultMirroringAudioTrackResolver.java index 01fb7da4..9936bdae 100644 --- a/main/src/main/java/com/github/topi314/lavasrc/mirror/DefaultMirroringAudioTrackResolver.java +++ b/main/src/main/java/com/github/topi314/lavasrc/mirror/DefaultMirroringAudioTrackResolver.java @@ -45,7 +45,11 @@ public AudioItem apply(MirroringAudioTrack mirroringAudioTrack) { } } - provider = provider.replace(MirroringAudioSourceManager.QUERY_PATTERN, getTrackTitle(mirroringAudioTrack)); + if (provider.contains(MirroringAudioSourceManager.QUERY_TITLE_PATTERN)) { + provider = provider.replace(MirroringAudioSourceManager.QUERY_TITLE_PATTERN, getTitle(mirroringAudioTrack)); + } + + provider = provider.replace(MirroringAudioSourceManager.QUERY_PATTERN, getQuery(mirroringAudioTrack)); try { track = mirroringAudioTrack.loadItem(provider); } @@ -60,7 +64,7 @@ public AudioItem apply(MirroringAudioTrack mirroringAudioTrack) { return track; } - public String getTrackTitle(MirroringAudioTrack mirroringAudioTrack) { + public String getQuery(MirroringAudioTrack mirroringAudioTrack) { var query = mirroringAudioTrack.getInfo().title; if (!mirroringAudioTrack.getInfo().author.equals("unknown")) { query += " " + mirroringAudioTrack.getInfo().author; @@ -68,4 +72,9 @@ public String getTrackTitle(MirroringAudioTrack mirroringAudioTrack) { return query; } + public String getTitle(MirroringAudioTrack mirroringAudioTrack) { + var query = mirroringAudioTrack.getInfo().title; + return query; + } + } diff --git a/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioSourceManager.java b/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioSourceManager.java index bbbc83df..e2aa3447 100644 --- a/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioSourceManager.java +++ b/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioSourceManager.java @@ -19,6 +19,8 @@ public abstract class MirroringAudioSourceManager extends ExtendedAudioSourceMan public static final String ISRC_PATTERN = "%ISRC%"; public static final String QUERY_PATTERN = "%QUERY%"; + public static final String QUERY_TITLE_PATTERN = "%QUERY_TITLE%"; + private static final Logger log = LoggerFactory.getLogger(MirroringAudioSourceManager.class); protected final Function audioPlayerManager; protected final MirroringAudioTrackResolver resolver;