bencevans / node-sonos

🔈 Sonos Media Player Interface/Client

Home Page:https://www.npmjs.com/package/sonos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getMusicLibrary returns nothing

OrionTheGiant opened this issue · comments

Calls to getMusicLibrary() return 0 items regardless of the search type (playlist, artists, sonos_playlists, etc.) I've verified through node-red-contrib-sonos-plus that there are playlists available from the speaker(s) in my setup. Other function calls like currentTrack() work correctly when using the same IP address.

Expected Behavior

Should return the list of playlists, artists, etc. available for the speaker.

Current Behavior

No search that I've tried has returned any results.

Sample code or executed example

const Sonos = require('sonos').Sonos
const sonos = new Sonos('172.16.4.129')

sonos.getMusicLibrary('sonos_playlists', { start: 0, total: 25 }).then(playlists => {
  console.log('Got current sonos playlists %j', playlists)
}).catch(err => { console.log('Error occurred %j', err) })

Versions (and Environment)

Node version: 12.17.0
node-sonos version: 1.14.0
OS: MacOS

I've tried this locally, and at my PC it just works.
Do you have VSCode?

Can you

  1. checkout the repository
  2. change your sonos IP in .vscode/launch.json
  3. navigate to examples/getplaylists.js
  4. press F5

This will launch the debugger. You can even set breakpoints to see exactly what is going on. Since this just works on my pc with playlists and sonos_playlists I'm closing this issue. Can you re-open if you've tested this is indeed not working in your environment?

Thank you for the help!

It seems that the issue I was having was not using the correct function for the information I was after.getplaylists.js returns 0 results for me, however getsonosfavorties.js and getsonosplaylists.js do give me the information I was expecting. Do you happen to know where in the Sonos app I can find the playlists that getMusicLibrary() is supposed to return?

No I have no idea where you can find those. Maybe one is the playlists you have on your nas (local library). Personally I only use Spotify playlists.

They are named "imported playlists". In the Sonos App, use tab "Browse", select Music Library, select imported playlists.
You can add them to My Sonos (in total with new swim lane imported playlist) or playlist by playlist and then they show up in the swim lane playlists.

Great! Thank you!