WIP New add-on: ListenBrainz
#1
Music 
Hi all!

The last few days I've been tinkering with making an add-on for submitting listening data to ListenBrainz. The add-on was based on the Last.fm add-on.

I tagged version 0.0.1 yesterday and it's working for me; I'd love to get some more people to test it and give feedback though, before I submit it for inclusion in the official Kodi repository.

Source code: https://gitlab.com/Freso/service.listenbrainz
Download (Kodi 18/Leia): service.listenbrainz-v0.2.1.zip (latest snapshot)
Download (Kodi 19/Matrix): service.listenbrainz-v0.3.1.zip (latest snapshot)
Changelogs: Leia / Matrix

Features:
  • Submit listens to ListenBrainz
  • Submit "playing now" information to ListenBrainz

Setup:
  • Download the .zip file above somewhere and install in Kodi
  • Go to the add-on settings and enter your ListenBrainz token from https://listenbrainz.org/profile/ (it would be great to have a better way to get this token into Kodi, esp. considering that you can't copy/paste…)
  • Listen to music and watch your listening history on your ListenBrainz user page update in real time! Smile

Please report any issues and feature requests to the issue tracker on GitLab if you're able. Alternatively, you can post here… but I'd prefer GitLab. Nerd

Enjoy, and let me know your thoughts!

(Also, any recommendations for code style/best practices for Kodi add-ons would be greatly appreciated. This is my first Kodi add-on, so I'm a bit uncertain regards how to best do some things. Also if you can spot anything that would prevent this from adoption into the official repository!)
If any of my comments or contributions have been helpful to you, consider checking out my Patreon. 🙇
Reply
#2
Awesome!

I tested but get a dependency error on the script.module.future

I had a quick google but couldn't find that 0.17.1 version online.
Code:
2019-03-29 14:09:06.207 T:7504   DEBUG: ------ Window Deinit (FileBrowser.xml) ------
2019-03-29 14:09:06.222 T:7504   DEBUG: CAddonInstaller: installing from zip 'C:\Users\gareth\Desktop\service.listenbrainz-v0.0.1.zip'
2019-03-29 14:09:06.226 T:19740   DEBUG: CAddonInstallJob[service.listenbrainz]: requires script.module.future version 0.17.1 which is not available
2019-03-29 14:09:06.226 T:19740   ERROR: CAddonInstallJob[service.listenbrainz]: The dependency on script.module.future version 0.17.1 could not be satisfied.
2019-03-29 14:09:06.240 T:7504   DEBUG: CGUIMediaWindow::GetDirectory (addons://)
2019-03-29 14:09:06.240 T:7504   DEBUG:   ParentPath = [addons://]
2019-03-29 14:09:06.241 T:18296   DEBUG: Thread waiting start, auto delete: false
2019-03-29 14:09:06.246 T:18296   DEBUG: CAddonMgr::GetAvailableUpdates took 5 ms
2019-03-29 14:09:06.249 T:18296   DEBUG: Thread waiting 18296 terminating
2019-03-29 14:09:06.250 T:7504   DEBUG: ------ Window Init (DialogNotification.xml) ------

Testing with the latest 18.1 Kodi.
Reply
#3
(2019-03-29, 16:14)docwra Wrote: Awesome!
I tested but get a dependency error on the script.module.future

I had a quick google but couldn't find that 0.17.1 version online. 

Ah, yeah. I've had a bit of trouble figuring out where to find what versions were available of the various Python libraries. I just pushed a fix for this. Can you try with https://gitlab.com/Freso/service.listenb...master.zip and see if that works for you?
Reply
#4
Great, seems to work as expected!

The only thing I noticed was the Listenbrainz token is crazy long, no way I could be bothered to type that in on my Android setup without a keyboard Smile

For info I did something similar on TheAudioDB with user tokens and got it down to 5 capital letters with some MD5 shortening and a little algorithm on the username. I think Trakt does the same for their user tokens as well to make them easy to type in.

Anyway its working great!

Image
Reply
#5
(2019-03-29, 16:51)docwra Wrote: The only thing I noticed was the Listenbrainz token is crazy long, no way I could be bothered to type that in on my Android setup without a keyboard Smile

Yeah. I'm really not happy with that either (see also my comment in the OP), but I'm not sure what to do about it. It's not in my power to change the ListenBrainz side of things (I could request it, sure, but…). Is there no other way to get a token (or password as it may also be in some other add-on cases) into Kodi?

Oh, and thanks for testing and reporting back that it's not just for me it's working! And thanks for the screenshot too! Would you mind if I maybe included that with the add-on as a, well, screenshot? Smile
Reply
#6
Sure go for it, but can blank out my username and name Wink
Reply
#7
regarding https://gitlab.com/Freso/service.listenbrainz/issues/6
you should be able to retrieve musicbrainzartistid and musicbrainztrackid (and other info) using json-rpc.

it's a bit of a workaround as you would first need to retrieve the library id from InfoTagMusic using the getDbId()
(https://codedocs.xyz/xbmc/xbmc/group__py...e91b2b691b)
then use this id in a AudioLibrary.GetSongDetails json query
(https://kodi.wiki/view/JSON-RPC_API/v9#A...ongDetails)
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
(2019-03-29, 23:37)ronie Wrote: regarding https://gitlab.com/Freso/service.listenbrainz/issues/6

Thanks! I hadn't even considered the JSON-RPC, but yeah, that's definitely also a venue that needs exploration. Thank you for pointing it out! Smile

Do you know if there are any plans of having the Python API be fully-featured compared to the C one? What repository would I want to poke at if I want to submit PRs for adding more of the C class methods to the Python library? I'm thinking I may want to make the logic so it first tries to get as much as possible straight from the (Python) API, then it'll check the JSON-RPC to fill in blanks, and I'll probably still want to pull in mutagen to directly check file tags — as this also lets me include information that Kodi doesn't consider at all, like MusicBrainz Track IDs and MusicBrainz Work IDs.
Reply
#9
(2019-03-30, 07:25)Freso Wrote: Do you know if there are any plans of having the Python API be fully-featured compared to the C one? What repository would I want to poke at if I want to submit PRs for adding more of the C class methods to the Python library?

i don't think anyone is actively working on it. if you're interested, Kodi improvements are always welcome!
PR's can be submitted to the Kodi repo.

the python code lives here: https://github.com/xbmc/xbmc/tree/master...ces/legacy

(2019-03-30, 07:25)Freso Wrote: I'm thinking I may want to make the logic so it first tries to get as much as possible straight from the (Python) API, then it'll check the JSON-RPC to fill in blanks, and I'll probably still want to pull in mutagen to directly check file tags — as this also lets me include information that Kodi doesn't consider at all, like MusicBrainz Track IDs and MusicBrainz Work IDs. 

that will work fine for local files, but you'll likely run into issues when your files are on a network share (smb/nfs).
...at least i did when trying to use the mutagen library to grep embedded lyrics from the file tags.
i ended up patching mutagen to handle file objects created with our xbmcvfs module.
there may be other/better workarounds though...
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#10
Version 0.1.0 has been released. Download from https://gitlab.com/Freso/service.listenbrainz/-/archive/v0.1.0/service.listenbrainz-v0.1.0.zip.

This should submit all information that can be gotten directly from Kodi’s internal API. Next step is making the addon use the JSON-RPC interface (and maybe fiddle with mutagen or some such) to get additional information, including MusicBrainz identifiers.

As always, please let me know any issues you have and either report here or on GitLab.
If any of my comments or contributions have been helpful to you, consider checking out my Patreon. 🙇
Reply
#11
Awesome, thanks signed up on Patreon as a show of appreciation for this. Open Data FTW!
Reply
#12
im getting this error lately
Quote:ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.SyntaxError'>
                                            Error Contents: invalid syntax (<string>, line 1)
                                            Traceback (most recent call last):
                                              File "/home/osmc/.kodi/addons/service.listenbrainz/listener.py", line 356, in <module>
                                                Main()
                                              File "/home/osmc/.kodi/addons/service.listenbrainz/listener.py", line 41, in __init__
                                                data = read_file(self.file)
                                              File "/home/osmc/.kodi/addons/service.listenbrainz/utils.py", line 76, in read_file
                                                data = eval(data)
                                              File "<string>", line 1
                                                [<utils.Listen object at 0xda6d8290>]
                                                 ^
                                            SyntaxError: invalid syntax
           https://pastebin.com/iGvmSQ1D
Reply
#13
I get the same error:
Quote:2021-02-17 19:07:14.296 T:140352308618816 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.SyntaxError'>
Error Contents: invalid syntax (<string>, line 1)
Traceback (most recent call last):
File "/home/steelbas/.kodi/addons/service.listenbrainz/listener.py", line 361, in <module>
Main()
File "/home/steelbas/.kodi/addons/service.listenbrainz/listener.py", line 41, in __init__
data = read_file(self.file)
File "/home/steelbas/.kodi/addons/service.listenbrainz/utils.py", line 76, in read_file
data = eval(data)
File "<string>", line 1
[<utils.Listen object at 0x7f33604118d0>]
^
SyntaxError: invalid syntax
-->End of Python script error report<--
 
I suppose development on this plugin has ceased, a shame.
Reply
#14
(2021-02-17, 23:22)STEELBAS Wrote: I get the same error:
Quote:2021-02-17 19:07:14.296 T:140352308618816 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.SyntaxError'>
Error Contents: invalid syntax (<string>, line 1)
Traceback (most recent call last):
File "/home/steelbas/.kodi/addons/service.listenbrainz/listener.py", line 361, in <module>
Main()
File "/home/steelbas/.kodi/addons/service.listenbrainz/listener.py", line 41, in __init__
data = read_file(self.file)
File "/home/steelbas/.kodi/addons/service.listenbrainz/utils.py", line 76, in read_file
data = eval(data)
File "<string>", line 1
[<utils.Listen object at 0x7f33604118d0>]
^
SyntaxError: invalid syntax
-->End of Python script error report<--
I suppose development on this plugin has ceased, a shame.
I saw this hadn't been submitted to the Gitlab issues yet, though, that probably doesn't help. Did so now.
Reply
#15
I get some errors kodi 19 matrix

2021-04-11 12:55:43.889 T:8352    DEBUG <general>: service.listenbrainz - listener: "tag_overrides" set to: {}
2021-04-11 12:55:43.889 T:8352    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: 'dict' object has no attribute 'iteritems'
                                                   Traceback (most recent call last):
                                                     File "C:\Users\ZERO TAKIMI\AppData\Roaming\Kodi\addons\service.listenbrainz\listener.py", line 224, in onPlayBackStarted
                                                       listen = self._get_listen()
                                                     File "C:\Users\ZERO TAKIMI\AppData\Roaming\Kodi\addons\service.listenbrainz\listener.py", line 266, in _get_listen
                                                       listen = Listen(tags, timestamp=timestamp, **tag_overrides)
                                                     File "C:\Users\ZERO TAKIMI\AppData\Roaming\Kodi\addons\service.listenbrainz\utils.py", line 188, in __init__
                                                       self.metadata = self.get_metadata_from_kodi_tags(tags)
                                                     File "C:\Users\ZERO TAKIMI\AppData\Roaming\Kodi\addons\service.listenbrainz\utils.py", line 277, in get_metadata_from_kodi_tags
                                                       for k, v in kodi_mapping.iteritems():
                                                   AttributeError: 'dict' object has no attribute 'iteritems'
                                                   -->End of Python script error report<--
Reply



Logout Mark Read Team Forum Stats Members Help
New add-on: ListenBrainz0
This forum uses Lukasz Tkacz MyBB addons.