Skip to content

Commit

Permalink
Avoid trying to match tracks on empty URI or UID
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Dec 22, 2020
1 parent 07dc74d commit abde6b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/src/main/java/xyz/gianlu/librespot/common/ProtoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static boolean isQueued(@NotNull ContextTrack track) {
}

public static void enrichTrack(@NotNull ContextTrack.Builder subject, @NotNull ContextTrack track) {
if (subject.hasUri() && track.hasUri() && !Objects.equals(subject.getUri(), track.getUri()))
if (subject.hasUri() && track.hasUri() && !subject.getUri().isEmpty() && !track.getUri().isEmpty() && !Objects.equals(subject.getUri(), track.getUri()))
throw new IllegalArgumentException(subject.getUri() + " is not " + track.getUri());

if (subject.hasGid() && track.hasGid() && !Objects.equals(subject.getGid(), track.getGid()))
Expand All @@ -272,7 +272,7 @@ public static void enrichTrack(@NotNull ContextTrack.Builder subject, @NotNull C
}

public static void enrichTrack(@NotNull Player.ProvidedTrack.Builder subject, @NotNull ContextTrack track) {
if (track.hasUri() && !Objects.equals(subject.getUri(), track.getUri()))
if (track.hasUri() && !track.getUri().isEmpty() && !Objects.equals(subject.getUri(), track.getUri()))
throw new IllegalArgumentException(subject.getUri() + " is not " + track.getUri());

subject.putAllMetadata(track.getMetadataMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ String load(@NotNull JsonObject obj) throws AbsSpotifyContext.UnsupportedContext
Integer trackIndex = PlayCommandHelper.getSkipToIndex(obj);

try {
if (trackUri != null) {
if (trackUri != null && !trackUri.isEmpty()) {
tracksKeeper.initializeFrom(tracks -> ProtoUtils.indexOfTrackByUri(tracks, trackUri), null, null);
} else if (trackUid != null) {
} else if (trackUid != null && !trackUid.isEmpty()) {
tracksKeeper.initializeFrom(tracks -> ProtoUtils.indexOfTrackByUid(tracks, trackUid), null, null);
} else if (trackIndex != null) {
tracksKeeper.initializeFrom(tracks -> {
Expand Down

0 comments on commit abde6b6

Please sign in to comment.