Home » Python » python – Attribute error from SoCo class MusicLibrary that documentation appears to say is not an error-Exceptionshub

python – Attribute error from SoCo class MusicLibrary that documentation appears to say is not an error-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I am doing initial exploration in the SoCo module which is a Python API for Sonos. Following the tutorial I do

>>> speakers = soco.discover()
>>> speaker = speakers.pop()
>>> speaker.player_name
'Portable'
>>> speaker.ip_address
'192.168.0.11'
>>> speaker.get_current_transport_info()['current_transport_state']
'STOPPED'

So far, so good. Now, still following the documentation, I do

>>> speaker.music_library.list_library_shares()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'MusicLibrary' object has no attribute 'list_library_shares'

and, sure enough, dir(speaker.music_library) confirms there is no such method.

But the documentation for this class says:

Listing and deleting music library shares

Music library shares are the local network drive shares connected to Sonos, which host the
audio content in the Sonos Music Library.

To list the shares connected to Sonos, use the list_library_shares()
method as follows:

››› device.music_library.list_library_shares()

['//share_host_01/music', '//share_host_02/music']

The result is a
list of network share locations.

Now either the documentation is badly out of step with the version I just downloaded (0.18.1; it says not), or I need another pair of eyes to point out what I am doing wrong.

How to&Answers: