EnigmaCurry / GMusicFS

A FUSE filesystem for Google Music
153 stars 36 forks source link

Switch to mobileclient gmusicapi interface + musicmanager #24

Open ghost opened 10 years ago

ghost commented 10 years ago

This pull request switch from webclient to mobileclient.

The main reason behind this rewrite is the bug #23 (basically, gmusicapi is broken atm and an update isn't coming soon). This migration trigger a few changes:

  1. Song metadata dicts changed so the code is adapted.
  2. With the new metadata, there are no more normalized version of the data, an internal normalize function has been written for that.
  3. Mobileclient interface requires a valid device id to login. I choosed to use the MusicManager to generate a device id based on the MAC address. This has 2 benefits: a. With the music manager it'll be possible to upload songs, later on b. WIth an id linked to GMusicFS, you'r sure the app works for everyone (no need to have an Android Smartphone or desktop app already registered). Side note: MusicManager interface needs oauth, so the first time gmusicfs is run, a perform_oauth is triggered and the user has to follow the prompt.
  4. In Mobileclient, no more multi-part url so the multi-part specific code has been removed
DelusionalLogic commented 10 years ago

Crash on startup, correct credentials has been provided, and the key has been provided to the program

INFO:gmusicapi.Musicmanager2:!-- begin debug log --! INFO:gmusicapi.Musicmanager2:version: 3.1.1-dev INFO:gmusicapi.Musicmanager2:logging to: /home/delusional/.cache/gmusicapi/log/gmusicapi.log INFO:gmusicapi.Musicmanager2:initialized INFO:gmusicapi.Musicmanager2:logged out INFO:oauth2client.client:Refreshing access_token INFO:gmusicapi.Musicmanager2:oauth successful Traceback (most recent call last): File "/usr/bin/gmusicfs", line 9, in <module> load_entry_point('GMusicFS==0.1', 'console_scripts', 'gmusicfs')() File "/usr/lib/python2.7/site-packages/gmusicfs/gmusicfs.py", line 432, in main fs = GMusicFS(mountpoint, true_file_size=args.true_file_size, verbose=verbosity) File "/usr/lib/python2.7/site-packages/gmusicfs/gmusicfs.py", line 253, in __init__ true_file_size=true_file_size, verbose=verbose) File "/usr/lib/python2.7/site-packages/gmusicfs/gmusicfs.py", line 140, in __init__ self.__register_music_manager() File "/usr/lib/python2.7/site-packages/gmusicfs/gmusicfs.py", line 191, in __register_music_manager self.manager.login(cred_path, self.manager_id, 'GMusicFS') File "/usr/lib/python2.7/site-packages/gmusicapi/clients/musicmanager.py", line 160, in login self._perform_upauth(uploader_id, uploader_name)) File "/usr/lib/python2.7/site-packages/gmusicapi/clients/musicmanager.py", line 210, in _perform_upauth ' (eg "00:11:22:33:AA:BB")') ValueError: ('uploader_id is not in a valid form.\nProvide 6 pairs of hex digits with capital letters', ' (eg "00:11:22:33:AA:BB")')

ghost commented 10 years ago

Hi Jesper,

Thx for the feedback. Apparently it's unhappy with the self.manager_id variable at the login step (was OK on my side with a Linux box). From what I'v read, this device_id (here called manager_id) is usually based on the MAC addr of the box, so I don't know why this didn't worked.

Could you please print the value of that variable just before the call to the login function (just before line 191)?

DelusionalLogic commented 10 years ago

I fixed it on my machine. You need to capitalize the mac address.

I can confirm that after this fix the script ran fine, and it mounted (Now if just all access worked)

ghost commented 10 years ago

Amazing ! Thanks for the report, I'll fix that this evening then do another pull request.

Gr, Henry-Nicolas Tourneur

Le 26/03/2014 13:41, Jesper Jensen a écrit :

I fixed it on my machine. You need to capitalize the mac address.

Reply to this email directly or view it on GitHub [1].

Links:

[1] https://github.com/EnigmaCurry/GMusicFS/pull/24#issuecomment-38678420

ghost commented 10 years ago

Recent commit make sure the mac address is set to upper case. You can test the code and merge it at your convenience.

DelusionalLogic commented 10 years ago

Did you check that this actually plays music? Reading the gmusicfs documentation it seems like you can't play music with a registered mac address

"a registered Android device id, as a 16 digit string. If you have already used Google Music on a mobile device, Webclient.get_registered_devices will provide at least one working id. Omit '0x' from the start of the string.

Note that this id must be from a mobile device; a registered computer id (as a MAC address) will not be accepted.

Providing an invalid id will result in an http 403." -From http://unofficial-google-music-api.readthedocs.org/en/latest/reference/mobileclient.html#gmusicapi.clients.Mobileclient.get_stream_url

ghost commented 10 years ago

Hello Jensen,

Of course, the code has been tested and I'm using GMusicFS to sync my music to my NAS, it's working for me with this code. I'm not sure how GMusicFS is going to be seen by Google, but I got no HTTP 403 error.

Did you get any error while testing?

Le 09/04/2014 00:06, Jesper Jensen a écrit :

Did you check that this actually plays music? Reading the gmusicfs documentation it seems like you can't play music with a registered mac address

"a registered Android device id, as a 16 digit string. If you have already used Google Music on a mobile device, Webclient.get_registered_devices will provide at least one working id. Omit '0x' from the start of the string.

Note that this id must be from a mobile device; a registered computer id (as a MAC address) will not be accepted.

Providing an invalid id will result in an http 403." -From

http://unofficial-google-music-api.readthedocs.org/en/latest/reference/mobileclient.html#gmusicapi.clients.Mobileclient.get_stream_url [1]

Reply to this email directly or view it on GitHub [2].

Links:

[1]

http://unofficial-google-music-api.readthedocs.org/en/latest/reference/mobileclient.html#gmusicapi.clients.Mobileclient.get_stream_url [2] https://github.com/EnigmaCurry/GMusicFS/pull/24#issuecomment-39907717

DelusionalLogic commented 10 years ago

The reason i looked into the documentation is that i got a 403 error when i tried to play a file from the file system.

the exception is thrown by get_stream_url

ghost commented 10 years ago

That's strange, it didn't with a Synology NAS. If you try to cp the music, does it work?

Le 09/04/2014 13:11, Jesper Jensen a écrit :

The reason i looked into the documentation is that i got a 403 error when i tried to play a file from the file system.

Reply to this email directly or view it on GitHub [1].

Links:

[1] https://github.com/EnigmaCurry/GMusicFS/pull/24#issuecomment-39952230

DelusionalLogic commented 10 years ago

Nope, same error.

qark commented 10 years ago

I observe the same 403 error. When I hard coded my phone device id into Mobileclient.get_stream_url call (instead of manager_id), I was able to get cp to work.

DelusionalLogic commented 10 years ago

Confirmed. Setting the manager_id to my phone ID and removing the whole music manager auth fixes the issue. This is due to googles seperation of features between the different client types.

ghost commented 10 years ago

Thx for the feedback guys, it must be related to the Mac Address vendor then, since it works on a synology nas. My original idea was to avoid the requirement to have an already registered mobile device (not every one uses Google music on a smartphone). I'll try to adapt the code to always get a valid device Id, if you have any idea, feel free to share.

Jesper Jensen notifications@github.com a écrit :

Confirmed. Setting the manager_id to my phone ID and removing the whole music manager auth fixes the issue.

— Reply to this email directly or view it on GitHub.

EnigmaCurry commented 10 years ago

Thanks for your work on this, but is there any functionality here that is not contained in #8 ?

ghost commented 10 years ago

Well, yes and no.

The idea of the code behind this pull was to auto-generate a working manager_id so that the user doesn't have to specify one. However, this never worked correctly as you cann see in the messages, so the feature is pointless. I don't think I'll be able to make it working correctly: either I would like to discover registered devices -> goes through the WebAPI currently broken or I want to register a new one (what this code tries to do) -> does not work.

You can discard this pull, thus.

Gr, Henry-Nicolas

Le 19/05/2014 21:17, Ryan McGuire a écrit :

Thanks for your work on this, but is there any functionality here that is not contained in #8 [1] ?

Reply to this email directly or view it on GitHub [2].

Links:

[1] https://github.com/EnigmaCurry/GMusicFS/pull/8 [2] https://github.com/EnigmaCurry/GMusicFS/pull/24#issuecomment-43544447

rjbell4 commented 10 years ago

Maybe this pull isn't valid, but I'm wondering if there's any benefit to supporting the music manager interface. For example, it seems like that allows downloading of songs with metadata. Might there be a benefit there? I haven't fully compared the offerings of mobile client vs. music manager.

DelusionalLogic commented 10 years ago

Music manager does not seem to allow playing of music, or downloading. It simply allows for music upload, which is fine, but uploading is not supported by this FS.