DanNixon / PlayMusicCL

A command line client for Google Play Music
Apache License 2.0
135 stars 21 forks source link

Python 3 support #10

Open Zisilius opened 10 years ago

Zisilius commented 10 years ago

Hey, thanks for making the script, but I'm having trouble finding a way to make it work. Every time I run it I get the following error message:

File "PlayMusicCL.py", line 122 print "Gave a Thumbs Up to {0} by {1} on Google Play.".format(song["title"].encode("utf-8"), song["artist"].encode("utf-8")) ^ SyntaxError: invalid syntax

my python version is 3.3.4 and I running this on an Arch Linux install.

I'm getting issue running the GetDevice.ph

File "GetDeviceID.py", line 11 print "Username: ", ^ SyntaxError: invalid syntax

Hope you can fix it, or help me understand why it's failing to work on my system. Thanks for your effort!

DanNixon commented 10 years ago

Assuming an issue with your Python version, I use 2.7 and have no issues. Will look in to fixing this.

DanNixon commented 10 years ago

Could you checkout the python3-fix branch and try again, this should fix the syntax error. The issue is the difference in the print functions in Python versions less than 3.0 and greater then 3.0

Zisilius commented 10 years ago

I tried your fix, but there is still some compatibility issues regarding some missing modules or something like that. Module Thread became obsolete in python 3 apparently and now they use something else for that functionality.

I reality, I would advise you, if at all possible, to actually try to port the script to python 3 fully, because attempting to merge it might just break something that works perfectly for a lot of people. So having two version might be annoying at first, but the language continues to evolve and you can't stick around with python 2 forever. It will be a good move towards the future to port it, so that people that are currently happy continue to be so, and your script is not left in the past and continues to follow the latest developments. But it's just a suggestion, I understand that it might be a pretty difficult task.

Any way, here are the errors I was seeing:

python PlayMusicCL.py Traceback (most recent call last): File "PlayMusicCL.py", line 10, in import thread, time, shlex, random, sys ImportError: No module named 'thread'

python GetDeviceID.py Traceback (most recent call last): File "GetDeviceID.py", line 8, in import gmusicapi, sys ImportError: No module named 'gmusicapi'

Thank you for the effort you put into this, we all appreciate it and are thankful.

DanNixon commented 10 years ago

Seems as though Python >3 will have to wait as GoogleMusicAPI does not support version 3 yet (https://github.com/simon-weber/Unofficial-Google-Music-API/issues/247).

belak commented 8 years ago

It looks like gmuisicapi added support for python3 in a recent release.

On a side note, python3 did not remove print, only the print statement.

print 'hello world'
print('hello world')

In that code snippet, the first line will only work with python2 and the second line will work with both python2 and python3.