Skip to content

Instantly share code, notes, and snippets.

@coenraadhuman
Last active April 29, 2020 03:31
Show Gist options
  • Save coenraadhuman/ff10adccf1d7c43d8d0298dbd1c5916f to your computer and use it in GitHub Desktop.
Save coenraadhuman/ff10adccf1d7c43d8d0298dbd1c5916f to your computer and use it in GitHub Desktop.
Install Tizonia on RPi with working Google Music
#! /bin/bash
echo "Adding required repositories."
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list
curl 'https://bintray.com/user/downloadSubjectPublicKey?username=tizonia' | sudo apt-key add -
echo deb https://dl.bintray.com/tizonia/raspbian buster main | sudo tee -a /etc/apt/sources.list
echo "Updating repositories."
sudo apt update
echo "Installing Tizonia and dependencies."
sudo apt install libspotify12
sudo apt install libtizspotifysrc0
sudo apt install tizonia-all
sudo apt install python3-pip
pip3 install gmusicapi
pip3 install fuzzywuzzy
pip3 install python-Levenshtein
echo "CHANGE LOGIN CREDENTIALS (Use Google App Password) : "
echo "nano $HOME/.config/tizonia/tizonia.conf"
echo ""
echo "# Google Play Music configuration"
echo "# -------------------------------------------------------------------------"
echo "# To avoid passing this information on the command line, uncomment and"
echo "# configure here."
echo "#"
echo "gmusic.user = YOUR_GMAIL_EMAIL"
echo "gmusic.password = YOUR_APP_PASSWORD"
echo "gmusic.device_id = 1234567890abcdef"
echo "# gmusic.buffer_seconds = size of the audio buffer (in seconds) to use while"
echo "# downloading streams. Default: 720. Increase in"
echo "# case of cuts."
echo ""
echo "*Please take note that on first login the gmusic.device_id is given in the error message.*"
echo ""
echo "CHANGE AUDIO RENDERER FOR RPI : "
echo "nano $HOME/.config/tizonia/tizonia.conf"
echo ""
echo "# Tizonia player section"
echo "# The default audio renderer used by the tizonia player"
echo "# -------------------------------------------------------------------------"
echo "# Valid values are:"
echo "# - OMX.Aratelia.audio_renderer.pulseaudio.pcm"
echo "# - OMX.Aratelia.audio_renderer.alsa.pcm"
echo "#default-audio-renderer = OMX.Aratelia.audio_renderer.pulseaudio.pcm"
echo "default-audio-renderer = OMX.Aratelia.audio_renderer.alsa.pcm"
@evilblade666
Copy link

evilblade666 commented Apr 27, 2020

Yes, it's paid. Have a subscription for some 5 years.
BTW, had a strange idea just now - what if I should log into my account from this RPi at least once?.. So, I installed all that GUI, VNC, Chromium, but sadly - it was all in vain :( Even generated a new password from this RPi - nothing changed :(

UPD: Just ran it on a PC and on a RPi after "export TIZONIA_GMUSICPROXY_DEBUG=1"
and looking through this logs I noticed that on PC it says
https://android.clients.google.com:443 "POST /auth HTTP/1.1" 200 None
and on a RPi it's
https://android.clients.google.com:443 "POST /auth HTTP/1.1" 403 None
..so on a PC it gets "OK" while on RPi it gets "Forbidden"... any idea why could it be?

@coenraadhuman
Copy link
Author

I have a feeling this is because of gmusic.device_id it is the only thing that makes sense to me that would cause it to be forbidden.

I am finding this issue extremely odd. Maybe we should start your setup from scratch?

I guess another option is that I dd my RPi image for you (I have a RPi 2B with an I2S DAC).

@evilblade666
Copy link

Well, on a PC when a device_id was wrong it said so and told me to correct ones with wich everything works. So, on RPi I tried to put the device_id the same, I tried to put completely random one there - nothing changes, I still get this "NotLoggedIn" thing :(

I thought about making a completely fresh install of Raspbian on another microsd card.. maybe I'll do that when the stars are aligned :)

@evilblade666
Copy link

evilblade666 commented Apr 28, 2020

Allright, I did a fresh install.. now it doesn't say "NotLoggedIN" it says:

tizonia --gmusic-library 
tizonia 0.21.0. Copyright (C) 2020 Juan A. Rubio and contributors
This software is part of the Tizonia project <https://tizonia.org>

[Google Play Music] [Connecting] : 'evilblade666@gmail.com'.
[Google Play Music] [Authenticating] : 'with cached auth token'
[Google Play Music] [Tracks in queue] '18466'.

...and that's it. It does not start to play.. Man am I frustrated :(

UPD: YES YES YES!!!!
I uninstalled tizonia-* and ran your script again! IT F$%^ING WORKS NOW!! :)

Oh, btw, your new script has some errors:
./rpi-tizonia-buster.sh: line 12: Echo: command not found

and then in the end:

./rpi-tizonia-buster.sh: line 32: syntax error near unexpected token `('
./rpi-tizonia-buster.sh: line 32: `echo "# gmusic.buffer_seconds = size of the audio buffer (in seconds) to use while'

@coenraadhuman
Copy link
Author

coenraadhuman commented Apr 28, 2020

Cool thanks about the errors, I just did the install manually and quickly compiled the script as a reference for the future. Can confirm all the echo commands are fixed.

Okay that is good, at least your authenticated and it is only just an audio problem.

Are you using internal audio (HDMI / AUX) or an I2S DAC?

I had to uncomment this line default-audio-renderer = OMX.Aratelia.audio_renderer.alsa.pcm in my config and comment the default-audio-renderer = OMX.Aratelia.audio_renderer.pulseaudio.pcm one.

It might be the inverse for you. If you are using a I2S DAC it could be that isn't configured properly.

@evilblade666
Copy link

Internal. 3.5 audio-jack.
I always changed pulseaudio to alsa in the first place as it's stated.. somewhere, I don't remember allready what's where anymore :)

@coenraadhuman
Copy link
Author

I suggest you force it to output just to the 3.5 audio jack:

https://www.raspberrypi.org/documentation/configuration/audio-config.md

Then this is the section for the alsa or pulseaudio (from what I just read this needs to be alsa):

echo "CHANGE AUDIO RENDERER FOR RPI : "
echo "nano $HOME/.config/tizonia/tizonia.conf"
echo ""
echo "# Tizonia player section"
echo "# The default audio renderer used by the tizonia player"
echo "# -------------------------------------------------------------------------"
echo "# Valid values are:"
echo "# - OMX.Aratelia.audio_renderer.pulseaudio.pcm"
echo "# - OMX.Aratelia.audio_renderer.alsa.pcm"
echo "#default-audio-renderer = OMX.Aratelia.audio_renderer.pulseaudio.pcm"
echo "default-audio-renderer = OMX.Aratelia.audio_renderer.alsa.pcm"

Some extra resources:

@evilblade666
Copy link

I suggest you force it to output just to the 3.5 audio jack:

I did. Years ago in fact :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment