User avatar
zag
Site Admin
Posts: 151
Joined: Tue Oct 11, 2016 9:43 am

TheAudioDBSync Support Thread

Fri Dec 16, 2016 1:12 pm

EDIT:
Image

Description
Supplies various options to synchronise artist data between theaudiodb.com and your Kodi library

Download: http://www.urepo.org/addon/15564
Source Code: https://github.com/robwebset/script.theaudiodb.sync

Hi all,

Would anyone be interested in writing a program Add-on to sync user "scores" from TheAudioDB.com website to the kodi music library? I've put a £50 bounty on it payable to anyone who gets an initial Add-on working.

Basically theaudiodb site allows any user to rate a track with a score from 1-10 and provides an API to access these.

Example track with a rating: http://www.theaudiodb.com/track/34675922

It would be cool to sync those with your local Kodi database just like the current Trakt.tv Add-on does with watched statuses. This allows you to backup your song ratings or maybe sync with your friends.

API example:
http://www.theaudiodb.com/api/v1/json/1 ... =Arturo007

Example JSON data returned

Code: Select all

{
id: "5398",
username: "Arturo007",
artistscore: null,
albumscore: "7",
trackscore: "10",
artistid: "112510",
albumid: "2118857",
trackid: "32830472",
strArtist: "38 Special",
strAlbum: "Resolution",
strTrack: "Fade to Blue",
mbidArtist: "0330a83d-f61e-4989-adb3-afce3943c3ba",
mbidAlbum: "7e92dda4-e88a-3383-a8a9-215ccabb7c7b",
mbidTrack: "250b953c-43f6-4269-b3c0-22d849113cf0",
rateddate: "2016-01-25 16:05:32"
},


Just change username to your own or someone else's to get all their user scores returned in JSON format.

It returns the artist, album and track names as well as their musicbrainz id's so should be pretty easy to sync.

I would envisage an Add-on having a simple configuration to enter the username, then just run looping through all tracks in a users database and updating the rating for each track that matches the JSON data returned from TheAudioDB. Initially I am just looking for track ratings, but i'm sure it could be extended for albums too.

NOTE: You will need latest Jarvis releases because the scoring was changed into a 1-10 scale.

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Fri Dec 23, 2016 2:41 pm

Hi Zag,

I thought I'd have a little mess about with this :)

I've put together some starter code:

https://github.com/robwebset/script.theaudiodb

There are actually several limitations for updating the ratings - at the moment there is no way to select a given track in the Kodi library using the musicbrainz id's - so at the moment it just gets every track - which is a bit nasty, I'm sure I'll think of a better way.

There are loads of TODOs still there at the moment. Did you have any images you wanted used for this addon?

Took me a while to realise that my test system was on v16.0 - where the rating is upto 5 (and not 10) - was this changed for v16.1 then? - shame it's only possible to limit an addon to the major kodi version and not a minor:

http://kodi.wiki/view/addon.xml#version_attribute_2

At the moment it's also only set to run as a Program - I guess it would also be useful to run as a service (configurable via the settings) to update things in the background. (Not hard to do).

It's not upto my normal standard/quality yet - but thought I'd post something before the Christmas period started.

I could imagine we could make this addon sync up a lot more data - did you fancy putting together your wish-list - then it'll give me a TODO list to go off of whenever I get a minute here and there.

Thanks
Rob

User avatar
zag
Site Admin
Posts: 151
Joined: Tue Oct 11, 2016 9:43 am

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Fri Dec 23, 2016 4:40 pm

THANKS! This is a huge feature for me as I use ratings every day to choose music and have lost them so many times while updating Kodi over the years :)

And it works (kinda)!

Image

I am using Krypton and as you can see the ratings have synced for the songs but it has updated the overall track "rating" (rather than the "userrating" db field). I would prefer user rating as then it shows up in Kodi Krypton like this :

Image

This probably works fine in Older kodi versions as I seem to remember version 16 only had a single rating field. Maybe an option to update userrating in the settings?

Some little todo's that I thought of quickly

- Visual progress bar
- Summary results popup at end (maybe just total tracks matched or something)
- Sync both overall rating(rating) and user rating(userrating) fields. You can get the overall rating from the track api method I think. Not sure how floats work though?
- Album userratings and rating as above

And a mildly optimistic but not essential request ;)
- One day I would hope to sync ratings back to theaudiodb site. There is an submission API method for that with a api token needed which can be found on the TADB user page for each user.

Oh and here is an icon
Image

Thanks again, i'll donate the bounty when its published properly.

I like that its a program and can be run manually, this is something I would maybe use once a month so its nice how it is. We also have to think about api usage if it turns into a service that is run multiple times.

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Sat Dec 24, 2016 4:55 pm

Hi Zag,

Wow! I didn't realise you were going to run this so soon ... it's far from finished! (I hope it wasn't on your live system!). :lol:

Some great information in your post - I'll try and update the addon to include all of your suggestions. I didn't realise that the ratings were different in v17 - is there any docs on the new JSon api for v17 anywhere? - I think I'll see if there is a way to get it to work with both v16 and v17 - some people (myself included) don't always update to the latest straight away.

I'll rename the addon to script,theaudiodb.sync as I think that meets the behaviour better. (Thanks for the icon)

I'm sure you can imagine, things are going to be very busy over the next week or so with family - so there may not be any updates for a little while :)

Will keep you posted with any progress ;)

Thanks
Rob

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Fri Jan 06, 2017 2:08 pm

Hi Zag,

Just to let you know that I have not forgotten this, I've only had a chance to do a couple more tweaks.

- Checks the version of Kodi to do range 1-5 if less than 16.1 otherwise user 1-10
- If running on v17 will update the "userrating", on earlier versions "rating" will be updated
- Only update kodi rating if it has changed

https://github.com/robwebset/script.theaudiodb.sync

So still lots to do - will hopefully get more time over the next few weeks.

Thanks
Rob

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Sat Jan 07, 2017 8:08 am

Hi Zag,

Just a quick one - I was looking at your suggestion:

- Sync both overall rating(rating) and user rating(userrating) fields. You can get the overall rating from the track api method I think. Not sure how floats work though?

And I'm a little concerned about adding this at the moment - if I add it it will generate "A LOT" of traffic to theaudiodb.com - as I'd be making a single request for every track in some-one library.

Do you think this would be OK? - Or is there a way to make one request to get all the values - maybe as part of the call for:

http://www.theaudiodb.com/api/v1/json/1 ... =Arturo007

could it also return the global value?

I'm not 100% clear on how things work with having an theaudiodb.com account - but is it something that a user could do a single call from kodi to "Update the on-line account with all the tracks/albums a user has" and then when we make a call to get the ratings, it only returns those tracks?

Just some thoughts
Rob

User avatar
zag
Site Admin
Posts: 151
Joined: Tue Oct 11, 2016 9:43 am

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Sat Jan 07, 2017 2:47 pm

Thanks, and yep agreed on the api call thing.

I will investigate returning the overall rating in the current single api call. It should be pretty easy to do.

EDIT: Done, see new tracktotal field :)

{
"id": "8952",
"username": "zag",
"artistscore": null,
"albumscore": null,
"trackscore": "10",
"artisttotal": null,
"albumtotal": null,
"tracktotal": "10",
"artistid": "111674",
"albumid": "2129847",
"trackid": "32967399",
"strArtist": "Bruno Mars",
"strAlbum": "Unorthodox Jukebox",
"strTrack": "Young Girls",
"mbidArtist": "afb680f2-b6eb-4cd7-a70b-a63b25c763d5",
"mbidAlbum": "978d88db-60ec-41d9-ade7-beea020941b0",
"mbidTrack": "98cb0c9f-ea14-44df-8886-a811367b6252",
"rateddate": "2017-01-07 16:37:23"
}

For now this only works for new ratings added. I'll look into updating the old ratings with a script sometime.

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Mon Jan 09, 2017 8:10 am

Hi Zag,

I think I've managed to put together all of the features to pull data from theaudiodb.com and update the Kodi Music Library, the latest version

https://github.com/robwebset/script.theaudiodb.sync

adds:

  • Added album support
  • Support matching based on artist and track name (If no Music Brainz Id)
  • For Kodi v17 set track/album rating to track/album total
  • Progress notification
  • Added settings to configure what is updated (Albums, Tracks etc)
  • Basic Summary screen when sync complete (Could improve in the future if we wanted to display more details)

One bit that is missing is some images - logo.png and banner.jpg (Also no screenshots at the moment). Are you able to put the logo and banner together - or maybe make the "base graphics" available and I can put a couple together.

I think if you are happy with where it is so far I can look at publishing it as a first issue - then we should look at what additional features can be added. At the moment it just reads what is on theaudiodb.com and updates the Kodi Library, so I think the next things to look at are possibly:

1) Is there any other data on theaudiodb.com that we want to pull down to Kodi? (Maybe this one first so we have a complete set of features for retrieving data)
2) Is there anything that we want to push from Kodi to theaudiodb.com?

I have to admit that I don't use Kodi for Music (I have a Sonos System for that), so I'm not really experienced with what features it offers.

Please can you give the current version a go and see if it starts to cover some of the things you were looking for?

Thanks
Rob

User avatar
zag
Site Admin
Posts: 151
Joined: Tue Oct 11, 2016 9:43 am

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Mon Jan 09, 2017 12:07 pm

Lovely! Will give it a test tonight.

But for now here is some artwork:

Image

Image

User avatar
robwebset
Site Mod
Posts: 255
Joined: Fri Dec 02, 2016 12:39 pm

Re: [£50 Bounty] Sync user ratings from TheAudioDB.com

Mon Jan 09, 2017 1:01 pm

Thanks Zag - added them - if you have a better fan art image than I'm using at the moment then I'm happy to swap it (Maybe something like the full image from the left hand side of the banner?

Thanks
Rob

Return to “Add-ons”