Not so long ago, the Google Play Music service
became available in Russia. For 169 rubles a month you can get full access. The problem is that Google provides the ability to listen to music only from mobile devices or through a browser.
However, this is not suitable for many, for example me. Therefore, in this article we consider the possible "unofficial" ways to listen to music from Google Play Music.
So, we have Raspberry Pi with MPD server installed. We want to be able to play remotely any music from our library in Google Play Music on this Raspberry Pi.
The option of starting a vnc server with a running browser is not considered. I tried to run chromium and midori without an X-server and a window manager, anyway, this business is very slow. The web application music.google.com is still quite “heavy”.
There is no official API for Google Play Music, but github has a great
Unofficial-Google-Music-API written in Python. Simon Weber, the author of this API, advises several projects that use its API. Consider interested me:
In addition to these projects, you can also find:
It is worth noting that all projects are written in Python. Below I will describe my experience with each of these projects.
')
Curses client. Runs music through mplayer. It sounds great, but does not work. To begin with, I had to switch to the branch where changes were made to work with the latest version of the API, the version from master is not functional. But the music still plays only a second, then switches to the next song. Actually, we can observe the following unresolved problem of
All-Access Songs Not Playing , which means that this is not just me.

FUSE file system. When we mount, we get the hierarchy of directories of our music library from Google Play Music in the format
artists / <name of artist> / <albums> / <tracks>
plus is loading cover.jpg. Well, the ability to have the entire music library in mp3 format in the directory is just fine, but there are a number of sad limitations.
As the author writes, this solution is only suitable for copying files to your computer or for playing with a simple player, such as mplayer. When trying to play in more advanced players, problems may arise. And indeed, when trying to open a collection even in a simple mocp, it begins to freeze, it is impossible to listen to music. When I try to specify a directory as a library for MPD, we get the opportunity to listen to music, but the tags did not load in me, and listening to songs with the same name “Unknown” is certainly not an option. Another author notes the lack of ability to play the song from a certain position.
You can install GMusicFS using pip, after installing the dependencies:
pip install github.com/terencehonles/fusepy/tarball/master
pip install github.com/simon-weber/Unofficial-Google-Music-API/tarball/develop
pip install github.com/EnigmaCurry/GMusicFS/tarball/master
Then you need to create a configuration file ~ / .gmusicfs with the following contents:
[credentials]
username = your_username@gmail.com
password = your_password
And you can mount:
mkdir -p $HOME/google_music
gmusicfs $HOME/google_music
To unmount:
fusermount -u $HOME/google_music
When copying music to your computer, all tags are correctly loaded. Playing with mplayer also works fine. After updating the library you need to remount the file system.
The project description says: "Let's stream Google Play Music using any media-player."
This script allows you to receive m3u playlists or mp3 files by sending specially crafted GET requests.
You can install the following command:
pip install github.com/diraimondo/gmusicproxy/tarball/master
A device-id of one of the registered devices is required for operation. Get a list of these devices as follows:
GMusicProxy --email <> --password <> --list-devices
Create a config ~ / .config / gmusicproxy.cfg:
email = my.email@gmail.com
password = my-secret-password
device-id = 54bbd32a309a34ef
Run:
GMusicProxy
Examples of use with the mpc console clientcurl -s 'http://localhost:9999/get_by_search?type=album&artist=Queen&title=Greatest%20Hits' >
/var/lib/mpd/playlists/queen.m3u
mpc load queen
mpc play
mpc clear
curl -s 'http://localhost:9999/get_new_station_by_search?type=artist&artist=Queen&num_tracks=100' |
grep -v ^# | while read url; do mpc add "$url"; done
mpc play
Examples of use with VLCvlc 'http://localhost:9999/get_by_search?type=album&artist=Rolling%20Stones&title=tattoo&exact=no'
curl -s 'http://localhost:9999/get_all_stations?format=text&only_url=yes' | sort -R | head -n1 | vlc -
A variety of requests are supported: getting songs, radio stations, playlists, ...
Of the minuses, it is worth noting that all these requests must be made by yourself, and also that tags are loaded only when playing a particular song.
Web-frontend on Django for access to the music library with integration into MPD. Let me just say that I had the same problem as with thunner - only a second is playing.
Mopidy is a music server that can pretend MPD. But the most interesting - for him there is an extension
Mopidy-GMusic .
You can install Mopidy using the package manager, and the extension with the following command:
pip install mopidy-gmusic
To work, you will need again device-id, which can be obtained either by typing * # * # 8255 # * # *, or installing the
application .
In the Mopidy config, you need to add:
[gmusic]
username = alice
password = secret
deviceid = 0123456789abcdef
After further configuration (documentation
here ), we get an MPD-compatible server with music from Google Play Music, as well as a local collection. Of the MPD clients,
GMPC ,
Ario and
pympd earned no problem. My favorite
Cantata unfortunately does not connect.
findings
GMusicFS is perfect for copying music from Google Play Music in mp3 format. For playback, you can use
Mopidy with a plugin.
I stopped at the fact that I launch both MPD and Mopidy on different ports and connect with different clients (Cantata and GMPC). MPD for local collection, Mopidy for Google Play Music.
Do not forget that when using two-factor authentication, you need to create application passwords in your Google account settings.