Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide artBase URL in config to load album art correctly #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions MMM-Sonos.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
showRoomName: true,
animationSpeed: 1000,
updateInterval: 0.5, // every 0.5 minutes
artBase: '',
apiBase: 'http://localhost',
apiPort: 5005,
apiEndpoint: 'zones',
Expand Down Expand Up @@ -62,23 +63,25 @@
var currentTrack = item.coordinator.state.currentTrack;
var artist = currentTrack.artist;
var track = currentTrack.title;
var cover = currentTrack.absoluteAlbumArtUri;
var cover = currentTrack.albumArtUri;
// var streamInfo = currentTrack.streamInfo;
// var type = currentTrack.type;

// clean data
artist = artist?artist.trim():'';
track = track?track.trim():'';
cover = cover?cover.trim():'';
track = track == currentTrack.uri?'':track;
artist = artist?artist.trim():'';
track = track?track.trim():'';
cover = cover?cover.trim():'';
track = track == currentTrack.uri?'':track;
cover = cover?cover:currentTrack.absoluteAlbumArtUri;
cover = cover.startsWith('/getaa')?this.config.artBase+cover:cover;

roomList.push({
'name': roomName,
'state': this.isInTVMode(artist, track, cover)?'TV':item.coordinator.state.playbackState,
'artist': artist,
'track': track,
'albumArt': cover,
});
roomList.push({
'name': roomName,
'state': this.isInTVMode(artist, track, cover)?'TV':item.coordinator.state.playbackState,
'artist': artist,
'track': track,
'albumArt': cover,
});
}
}.bind(this));
this.loaded = true;
Expand Down