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

Question : How can easily play a song from Google Play Music #398

Closed
Dark5ide opened this issue May 25, 2016 · 10 comments
Closed

Question : How can easily play a song from Google Play Music #398

Dark5ide opened this issue May 25, 2016 · 10 comments

Comments

@Dark5ide
Copy link

Hi folks,

I recently installed the SoCo repo and tried some python command to understand how SoCo works. But I did not succeed to play a song from my Google Play Music account (already paired with my Sonos).

My goal is to use SoCo in an open-source project called Mycroft (Website, GitHub). I'd like to implement a plugin (called Skill) to control Sonos speakers. This Skill will allow to control Sonos speakers by the voice.
My first step is to make a python script that plays song (by author, album, ...) and playlist from a Google Play Music account but I need a little help to understand how to use SoCo properly.

May you introduce me the way ? :-)

@Dark5ide
Copy link
Author

Dark5ide commented May 26, 2016

Here is some errors I got :

>>> play = MusicService('Google Play Music')
>>> print(play.available_search_categories)
dict_keys(['albums', 'tracks', 'stations', 'podcasts', 'artists'])
>>> result = play.search(category='artists', term='miles')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 714, in search
    ('count', count)])
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 145, in call
    soap_header=self.get_soap_header(),
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 112, in get_soap_header
    ('Username', music_service.account.username)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 181, in _dispatcher
    return self.send_command(action, *args, **kwargs)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 408, in send_command
    self.handle_upnp_error(response.text)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 469, in handle_upnp_error
    error_xml=xml_error
soco.exceptions.SoCoUPnPException: UPnP Error 8009 received:  from 192.168.1.35
>>>

@lawrenceakka
Copy link
Contributor

Hi @Dark5ide

Sorry for the delay.

You seem to be using SoCo correctly, but there have been some recent changes to the music services code. Google Play in particular can be quite fussy, so it may be that you are getting some sort of authentication error. I am currently working on code to make this ore robust.

In the meantime, what version of SoCo are you using? Have to tried installing the development version direct from GitHub?

@Dark5ide
Copy link
Author

Thanks @lawrenceakka for your response.

I had cloned the SoCo repo. I just do the update from the last commits. I have not yet tested the new code.

I run SoCo in a vertualenv and I used some pip install to install the dependencies.

If you want, I can help you and make some tests for Google Play Music and Spotify account.

@Dark5ide
Copy link
Author

Dark5ide commented May 31, 2016

I have some weird error. It seems not to find my services :

>>> my_zone = SoCo('192.168.1.65')
>>> print(MusicService.get_all_music_services_names())
['SOUNDMACHINE', 'Daytrotter', 'Mixcloud', 'Mood Mix', 'Google Play Music', 'Calm Radio', 'Apple Music', 'SoundCloud', 'Saavn', 'Qobuz', 'Tribe of Noise', 'focus@will', 'TIDAL', 'Gaana', 'FIT Radio Workout Music', 'Napster (BETA)', 'Tunify for Business', 'Concert Vault', 'MLB.com Gameday Audio', 'Spreaker', 'DAR.fm Record Radio', 'Hype Machine', 'Stitcher SmartRadio', 'radioPup', 'Anghami', 'iHeartRadio', 'Murfie', '22tracks', 'TuneIn', 'Bandcamp', 'Radionomy', 'Spotify', 'Deezer', 'Groove', 'Hearts of Space', 'RUSC', 'hotelradio.fm', '7digital']
>>> print(MusicService.get_subscribed_services_names())
[]
>>> print(MusicService.get_subscribed_services_names())
[]
>>> play = MusicService('Google Play Music')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 351, in __init__
    "No account found for service: '%s'" % service_name)
soco.exceptions.MusicServiceException: No account found for service: 'Google Play Music'
>>>

@lawrenceakka
Copy link
Contributor

Hi @Dark5ide

I have fixed the "No account found" problem - please update from github.

Are you still having other problems?

@Dark5ide
Copy link
Author

Dark5ide commented Jun 3, 2016

Hi @lawrenceakka

I just updated and tested. Here is what I have :

>>> play = MusicService('Google Play Music')
>>> print(play.available_search_categories)
dict_keys(['podcasts', 'stations', 'artists', 'tracks', 'albums'])
>>> result = play.search(category='artists', term='in flames')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 715, in search
    ('count', count)])
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 146, in call
    soap_header=self.get_soap_header(),
  File "/home/martinus/Bureau/SoCo-master/soco/music_services/music_service.py", line 111, in get_soap_header
    ('Username', music_service.account.username)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 181, in _dispatcher
    return self.send_command(action, *args, **kwargs)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 408, in send_command
    self.handle_upnp_error(response.text)
  File "/home/martinus/Bureau/SoCo-master/soco/services.py", line 469, in handle_upnp_error
    error_xml=xml_error
soco.exceptions.SoCoUPnPException: UPnP Error 8009 received:  from 192.168.1.35
>>>

It seems I have the same probleme as before.

@benlm54
Copy link

benlm54 commented Jun 9, 2016

Not sure if I should open a new issue or not, but I am also having trouble with music services. I am unable to play any URI from a music service (at least not from TuneIn or Slacker). Here is basically what I'm doing and the error I get:

slacker = MusicService('Slacker')
slacker.get_metadata(id) #I'll do this to browse through music collections until I find a station where canPlay=True
uri = slacker.sonos_uri_from_id(id)
soco.play_uri(uri)

Results in this:
Traceback (most recent call last):
File "", line 1, in
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/core.py", line 101, in inner_function
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/core.py", line 477, in play_uri
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 181, in _dispatcher
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 408, in send_command
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 469, in handle_upnp_error
soco.exceptions.SoCoUPnPException: UPnP Error 714 received: Illegal MIME-Type from 192.168.1.20

I've tried doing this on TuneIn as well. I've also tried a few different methods like providing metadata or using add_uri_to_queue(uri) instead of play_uri(uri). Same error every time.

Am I doing it wrong or is there a legit issue?

@benlm54
Copy link

benlm54 commented Jun 9, 2016

FWIW I also tried the method described here

Resulted in the following error:Traceback (most recent call last):
File "", line 1, in
File "", line 12, in add_from_service
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/core.py", line 101, in inner_function
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/core.py", line 1266, in add_to_queue
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 181, in _dispatcher
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 408, in send_command
File "/Users/bmeakin/py34_env/lib/python3.4/site-packages/soco-0.11.1-py3.4.egg/soco/services.py", line 469, in handle_upnp_error
soco.exceptions.SoCoUPnPException: UPnP Error 802 received: from 192.168.1.20

@lawrenceakka
Copy link
Contributor

@benlm54 Please can you open a separate issue for this, and please can you post some code which generates the error using TuneIn? I do not have access to Slacker to test. Thanks

@KennethNielsen
Copy link
Member

Closing due to lack of feedback. Feel free to re-open if the need arises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants