Kodi Community Forum

Full Version: Google Play Music - From scratch
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Description
First and foremost, this is NOT a fork! I wrote I from scratch with maintainable code in mind.
Other than that there is not a whole lot to say right? So go on and checkout the features Wink

- Restrictions
  • Most importantly, only All-Access is supported right now and I'm not sure if I'll make it compatible with non All-Access Accounts
  • No Android / iOS support
  • No Raspberry PI support (due to a dependency pycryptodome)
  • No OSX support (due to a dependency pycryptodome)

- Features
  • Setup assistant to guide you through the login process
  • I'm feeling lucky radio¹
  • Situations (e.g. It's Friday evening)
  • Recommended Albums, Stations¹ Playlists
  • Top Charts (Songs and Albums)
  • New Releases
  • My Library: Playlists, Stations¹, Artists, Albums, Songs and Genres
  • Browse Stations by Genres, Activities, Moods and Decades
  • Search Artists, Albums and Songs (including a search history)
  • Add to My Library
  • Add to Playlist (and create new ones)
  • Remove from My Library
  • Remove from Playlists
  • Delete Playlists
  • Go to Artist/Album
  • Start radio stations for songs, albums, playlists and artists
  • Rate songs (Thumbs up/down or No Thumbs)
  • Context-menu integration into Kodis music playlist to add a song to your Library / Playlist, go to the current songs Artist / Album or rate it
    (Hit "n" when in full-screen to access the current playlist)
  • Auto-update My Library every n hours

¹ INFINITE Stations!!!
There is only one important thing to mention here. The playlist will start with 25 items, when reaching one of the last 5 items, the add-on will fetch another
25 new songs. However, this only works if at least one of the last 5 songs originates from a station.
So if you happen to have queued 5 none station songs, the playlist will end.

- Installation
  1. Install the linuxwhatelse repository
  2. Install Google Play Music
  3. Enjoy!


Credits
A very big thanks goes to Simon Weber for creating the gmusicapi
Without him all this wouldn't have been possible Smile
So Simon, thank you very very much!

Also a huge thanks to thebigmunch who not only contributes a lot to gmusicapi
but also helped me out more than once by now.
Thanks a lot Smile


Contribute
This project is licensed under GPLv3 and the source can be found on github.


Donate
Only because you can, doesn't mean you have to donate.
As long as you like and enjoy my work I'm happy Smile

If you still want to donate, here's something to click: Donate
FAQ (probably)

How can I update My Library
Go into the plugin, hover over My Library, open the context menu and hit Update Library

Why does only My Library require updating?
This was a design choice I had to make.
In general I have to consider the users Library (excluding Playlists) to be the biggest chunk of data. As it stands, Googles API doesn't implement a
way to only fetch parts of a users library (as far as we know). To keep things speedy I just had to implement some form of caching.

How does Overwrite Views work and why does it exist?
The problem:
Kodi doesn't know when to display a specific view-mode (List, Big list etc.) for addons.
If you change the view-mod of e.g. My Library -> Albums, Kodi will remember that HOWEVER when you go to
e.g. Listen Now -> Albums you'd expect to get the same view-mode as in My Library -> Albums (because both display albums) right?
WRONG! It is a different path and therefor Kodi falls back to the default view-mode.
Most path's are dynamic (because for example the album-id changes) therefore Kodi keeps falling back to the default view.

The solution:
As a add-on however I know what "type" currently get's displayed and therefore I can (if the user so wishes) overwrite the active view-mode.
However, the internal view-mode ID's differ from Skin to Skin. That's why you have the ability to set them individually.

How do I acquire said view-mode ID's?
  1. Open your skins addon.xml
  2. Find the line starting with <extension point="xbmc.gui.skin" and add (or change if already exist) debugging="true"
    After restarting Kodi you'll see a debugging view on the top left. The number after Focused: is what we are looking for
  3. Now navigate to some place in the add-on, change the view-mode and note down all the view-mode IDs you'r interested in
  4. Now you can remove debugging="true" from the addon.xml again (or set it back to "false")
News

2016-11-25
Much time has passed since the last update, hasn't it.
Basically I took.. lets call it "a break" for a few month but I'm kinda back now, yay! Smile

I hate writing changelogs etc. so if you're interested in what happend you can try
and make sense of my commits on github. Good luck!!!

I basically just wanted everyone to know that I have (and further will) invest some time again
in fixing bugs and improve the overall quality of the add-on.
Lets hope I actually improve and not break stuff Nod


2016-03-31
Lots of changes and nothing new

I did quite a lot of restructuring/refactoring and tried to test everything as good as I could.
If I missed something, I'm sorry and let me know.
I'll try and fix it ASAP.

Other than that:
- added german translation
- added lib2to3 (addon should work on OpenElec now)
- Clear search history from "Search" context menu

2016-03-07
Update time!!!
If you haven't been able to login, this should now be resolved Smile

There are some more goodies like:
- You can now start a radio from a playlist
- You can now sort the listing by more than just asc and desc
- You can update your library automatically now
- A tracks playcount will only be increased after you listened to it for 1/3 of its total length

2016-01-25
I added a setup assistant which everyone will have to go through once (even if you already configured the add-on).
Sorry for the inconvenience but at least everyone should be able to use the add-on now.

The assistant covers all cases (at least all I could think of) which includes:
- 2-Factor authentication
- Mac address instead of android-id (in case you don't have a android device)

Hope it works for everyone Smile

2015-12-26
Just want to let you all know that I'm super busy working on a Visualization for Kodi and that I'll get back to work on this add-on
as soon as the Vis is done. Smile

2015-11-06
Update time!!!
The add-on now supports Situations which are basically Stations categorized under e.g. It's Friday evening.
You can find it in Listen now right below I'm feeling lucky

2015-11-04
Yesterday I upgraded my HTPC from ubuntu 15.04 to 15.10 and it seems like the addon crashes on 15.10.
This is probably due to a bug in the cryptography module. I updated it to the latest version and will test it
once I'm back home.

2015-11-02
REPOSITORY RE-INSTALLATION REQUIRED!!!
Due to a change of mind I switch from uncompressed to compressed packages in the repository.
Therefore you have to reinstall the repository.
You can download it from here
Not working on Windows 8.1 (Kodi 15.2). Popup to choose the device ID does not appear - probably because I have several Windows Computers in my device list?




ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.KeyError'>
Error Contents: ('carrier',)
Traceback (most recent call last):
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\default.py", line 41, in <module>
mapper.call(url)
File "D:\Users\user\AppData\Roaming\Kodi\addons\script.module.linuxwhatelse.mapper\lib\mapper.py", line 149, in call
function(**args)
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\browse.py", line 314, in my_library_playlists
gmusic.login()
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\gmusic.py", line 56, in login
android_id = self._get_android_id()
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\gmusic.py", line 44, in _get_android_id
dev_list.append('%s %s (%s)' % (dev['carrier'], dev['model'], dev['name']))
KeyError: ('carrier',)
-->End of Python script error report<--
(2015-11-07, 00:12)cicero22 Wrote: [ -> ]Not working on Windows 8.1 (Kodi 15.2). Popup to choose the device ID does not appear - probably because I have several Windows Computers in my device list?




ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.KeyError'>
Error Contents: ('carrier',)
Traceback (most recent call last):
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\default.py", line 41, in <module>
mapper.call(url)
File "D:\Users\user\AppData\Roaming\Kodi\addons\script.module.linuxwhatelse.mapper\lib\mapper.py", line 149, in call
function(**args)
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\browse.py", line 314, in my_library_playlists
gmusic.login()
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\gmusic.py", line 56, in login
android_id = self._get_android_id()
File "D:\Users\user\AppData\Roaming\Kodi\addons\plugin.audio.linuxwhatelse.gmusic\gmusic.py", line 44, in _get_android_id
dev_list.append('%s %s (%s)' % (dev['carrier'], dev['model'], dev['name']))
KeyError: ('carrier',)
-->End of Python script error report<--

Should be fixed now Smile
Yep, it works now - thank for fixing it!
(2015-11-17, 12:23)cicero22 Wrote: [ -> ]Yep, it works now - thank for fixing it!

Sure thing Wink
Hope you like it Smile
Does this addon: add all the music from google libray into the music library of kodi?
Or only library through the addon?
(2015-11-17, 12:35)Skank Wrote: [ -> ]Does this addon: add all the music from google libray into the music library of kodi?
Or only library through the addon?

Sadly you can browse googles library only through the addon.
Kodi is not built in such a way to extend the "normal" library (at least as far as I know)

Personally I'd like that too and you can be sure that once there is a way to achieve that, I'll be on it!
But as of now you'd have to use the addon to browse your google music library
oh pity
thx anyway
Maybe try the other way around. Integrate the local library into your addon. This way the local library and the songs from the addon are united too. I'm using an addon for music videos that searches various online sources (vevo, youtube, muzu etc.) AND the local database. The result is really good, a unified view for online and local files.

The only thing to overcome are duplicate entries (same song is found on google and the local database). Local entries should have priority over online entries in that case in my opinion.
(2015-11-17, 17:14)DarkHelmet Wrote: [ -> ]Maybe try the other way around. Integrate the local library into your addon. This way the local library and the songs from the addon are united too. I'm using an addon for music videos that searches various online sources (vevo, youtube, muzu etc.) AND the local database. The result is really good, a unified view for online and local files.

The only thing to overcome are duplicate entries (same song is found on google and the local database). Local entries should have priority over online entries in that case in my opinion.

That would be an idea. But I'm not sure if it's worth the effort to be honest...

I for myself migrated everything to google and therefore don't need a local library anymore.
And with skins, refocus in my case, that allow you to add your own shortcuts to the homescreen, I just
replaced everything music related with a link to my addon, making it a almost native experience.

Further, you can upload up to 50000 song to gmusic meaning you can "merge" your library there.

That's how I see it anyway

Everything is a sort of "hacky" way of doing things and I really hate doing hacky implementations.
As I said, as soon as there is an official way of "scanning addon-content to kodis library" I'm happy to implement
it
I see your point and yes, it's all hacky now for sure. A unified interface for addons to populate the library in kodi would be the solution on the long run. I just wanted to contribute another possible approach for the meantime.

What makes me hesitant to replace my local music files to Google completely are connection speed issues and availabilty. Also think of countries where broadband connections are not as widespread and cloud solutions are not feasible now.
Pretty cool to see a new addon for gmusic. Really hoped for something like this.
Is arm not supported or could the cause of the problem be something else?
Using OpenElec Jarvis und RPi2.


PHP Code:
19:18:36 647659.437500 T:1198519200   ERROREXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - 
NOTEIGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            
Error Type: <type 'exceptions.ImportError'>
                                            
Error ContentsNo module named unittest
                                            Traceback 
(most recent call last):
                                              
File "/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/default.py"line 21in <module>
                                                
import browse
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/browse.py"line 14in <module>
                                                
from gmusic import GMusic
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/gmusic.py"line 10in <module>
                                                
from gmusicapi import MobileclientWebclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/__init__.py"line 4in <module>
                                                
from gmusicapi.clients import WebclientMusicmanagerMobileclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/__init__.py"line 1in <module>
                                                
from gmusicapi.clients.webclient import Webclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/webclient.py"line 6in <module>
                                                
from gmusicapi.clients.shared import _Base
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/shared.py"line 3in <module>
                                                
from gmusicapi.utils import utils
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/utils/utils.py"line 22in <module>
                                                
from gmusicapi.compat import my_appdirs
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/compat.py"line 18in <module>
                                                
import unittest  # noqa
                                            
ImportErrorNo module named unittest
                                            
-->End of Python script error report<--
19:18:36 647659.500000 T:1963479040   ERRORGetDirectory Error getting plugin://plugin.audio.linuxwhatelse.gmusic/
19:18:36 647659.500000 T:1963479040   ERRORCGUIMediaWindow::GetDirectory(plugin://plugin.audio.linuxwhatelse.gmusic/) failed 
(2015-11-17, 20:25)CorePoint Wrote: [ -> ]Pretty cool to see a new addon for gmusic. Really hoped for something like this.
Is arm not supported or could the cause of the problem be something else?
Using OpenElec Jarvis und RPi2.


PHP Code:
19:18:36 647659.437500 T:1198519200   ERROREXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - 
NOTEIGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            
Error Type: <type 'exceptions.ImportError'>
                                            
Error ContentsNo module named unittest
                                            Traceback 
(most recent call last):
                                              
File "/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/default.py"line 21in <module>
                                                
import browse
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/browse.py"line 14in <module>
                                                
from gmusic import GMusic
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/gmusic.py"line 10in <module>
                                                
from gmusicapi import MobileclientWebclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/__init__.py"line 4in <module>
                                                
from gmusicapi.clients import WebclientMusicmanagerMobileclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/__init__.py"line 1in <module>
                                                
from gmusicapi.clients.webclient import Webclient
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/webclient.py"line 6in <module>
                                                
from gmusicapi.clients.shared import _Base
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/clients/shared.py"line 3in <module>
                                                
from gmusicapi.utils import utils
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/utils/utils.py"line 22in <module>
                                                
from gmusicapi.compat import my_appdirs
                                              File 
"/storage/.kodi/addons/plugin.audio.linuxwhatelse.gmusic/lib/gmusicapi/compat.py"line 18in <module>
                                                
import unittest  # noqa
                                            
ImportErrorNo module named unittest
                                            
-->End of Python script error report<--
19:18:36 647659.500000 T:1963479040   ERRORGetDirectory Error getting plugin://plugin.audio.linuxwhatelse.gmusic/
19:18:36 647659.500000 T:1963479040   ERRORCGUIMediaWindow::GetDirectory(plugin://plugin.audio.linuxwhatelse.gmusic/) failed 

Actually, in your case there is a python module missing (which seems to be default in the python framework but somehow missing with kodi/openelec *confused face*)
But if it will work with ARM is another, good question (there is one dependency that makes me a little skeptic about it)

Give me a bit to see if I can sort out that missing unittest problem.
You might end up getting some more errors so it will end up beeing a back-and-forth between us two to sort everything out (if you don't mind)
If you have a github-account let me know. Than I'll make an issue real quick so we can keep discussion over there (keeps the thread more clean and makes
life a little easier in general ^^)

Thanks for reporting though Smile

Update 20:22
Okay, unittest is something pretty much every distribution (apart from openelec) has and the only solution seems to be to install the old pyunit
module.
I'm not willing to add this one to the add-on itself as it is sort of deprecated BUT you should be able to easily install it via:
Code:
easy_install pyunit
Let me know how that did go and I'll add it to the installation instructions above so everyone can benefit from it Smile

Update 20:34
Just realized that easy_install isn't part of openelec either *sigh*

I found this guide to install easy_install on openelec
https://gist.github.com/danielfm/f62686f488ad2e5df8bb

Hope that works for you
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13