Skip to content

Commit

Permalink
[squeezebox] Fix for Spotify and Tidal favorites (openhab#10244)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Hilbush <mark@hilbush.com>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
  • Loading branch information
mhilbush authored and themillhousegroup committed May 10, 2021
1 parent f68272f commit 4cc576f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -961,25 +961,30 @@ private void handleFavorites(String message) {

List<Favorite> favorites = new ArrayList<>();
Favorite f = null;
boolean isTypePlaylist = false;
for (String part : messageParts) {
// Favorite ID (in form xxxxxxxxx.n)
if (part.startsWith("id%3A")) {
String id = part.substring("id%3A".length());
f = new Favorite(id);
favorites.add(f);
isTypePlaylist = false;
}
// Favorite name
else if (part.startsWith("name%3A")) {
String name = decode(part.substring("name%3A".length()));
if (f != null) {
f.name = name;
}
} else if (part.equals("type%3Aplaylist")) {
isTypePlaylist = true;
}
// When "1", favorite is a submenu with additional favorites
else if (part.startsWith("hasitems%3A")) {
boolean hasitems = "1".matches(part.substring("hasitems%3A".length()));
if (f != null) {
if (hasitems) {
// Except for some favorites (e.g. Spotify) use hasitems:1 and type:playlist
if (hasitems && isTypePlaylist == false) {
// Skip subfolders
favorites.remove(f);
f = null;
Expand Down

0 comments on commit 4cc576f

Please sign in to comment.