Created
December 9, 2022 08:01
-
-
Save jordansissel/b25b9f396b8d82687d50d069b4a617d1 to your computer and use it in GitHub Desktop.
Napster URL conversion to Sonos UPnP -- Using node-songs to play music.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { DeviceDiscovery } = require('sonos'); | |
DeviceDiscovery((device) => { | |
//console.log('found device at ' + device.host + " - " + device.friendlyName) | |
device.deviceDescription().then(descr => { | |
// look for a sonos named "Sonos Roam" | |
if (descr.friendlyName.match(/Sonos Roam/)) { | |
console.log(descr); | |
// Coheed - Vaxis II - first track | |
// https://play.napster.com/track/tra.676707759?ocode=social_user&pcode=social_user&cpath=Link&rsrc=track | |
// | |
// I learned the song uri by playing a song and then calling currentTrack() to find the uri | |
// Then I tried to modify this uri to play a known song. | |
// The 'atra.<ID>' seems to be the track name. I'm not entirely sure what the remaining |v1|ALBUM|... bits are | |
// For good measure, the 'alb.<NUMBER>.mp4' I inserted the album ID for the album this track is on | |
device.play("x-sonos-http:ondemand_track%3a%3atra.676707759|v1|ALBUM|alb.676707757.mp4?sid=202&flags=8232&sn=1"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment