Skip to content

Commit

Permalink
fix: add title query pattern only
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi authored Jun 26, 2024
1 parent 6af620a commit 9f6c7f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -60,12 +64,17 @@ 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;
}
return query;
}

public String getTitle(MirroringAudioTrack mirroringAudioTrack) {
var query = mirroringAudioTrack.getInfo().title;
return query;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void, AudioPlayerManager> audioPlayerManager;
protected final MirroringAudioTrackResolver resolver;
Expand Down

0 comments on commit 9f6c7f6

Please sign in to comment.