JSON-RPC - Get/Set addon settings & Playlist.insert file label
#1
I have two issues bugging me at the moment, I am pretty sure they aren't part of the API but just throwing them out there in hope someone has solutions.

1. Can you Get and Set addon settings via the API
I was thinking this might be achieved via "Addon.ExecuteAddon" but can't find a way to do it. I was then thinking that maybe I could add a route in addon.py to do the getting and setting, but that doesn't feel very elagent. Also looked at "Settings.GetSettings" but it seems to only provide Kodi settings. Having this would be great as a web interface addon could have persistent settings saved to disk rather than relying on a 'per browser' local settings which get lost between browsers. It would also allow configuration for the web interface via the kodi UI.

2. Using Playlist.insert with a file object and the resulting playlist label
It seems when playlist insert is called with a file, the resulting label for that item in the playlist is the last part of the uri. So for something like an addon that might have a play uri like "addon://plugin.audio.soundcloud/play?track_id=12345" the resulting label in the playlist is "play" if it was "addon://plugin.audio.soundcloud/play/mysongname?track_id=12345" then would get "mysongname" as the playlist item label. I have a patch for radio to get around this, but patching addons seems like the wrong way of attacking the issue. Ideally Kodi would get the correct label for the URI but can understand why that isn't reliable (a file url can be anything) however "Player.getItem" seems to not only get the label but the thumbnail, the other option which would be nice would be extending "playlist.insert" so it accepts a "label" parameter so it could be set when adding the file.

Image

Any help would be great!
Reply
#2
1. Can you Get and Set addon settings via the API

The only way i know to do this is if the addon fully supports the settings via its directory structure, then you can use Files.GetDirectory to transcend down the tree to the setting entry.
Ive found in doing this, sometimes the setting might launch the keyboard or similar input to which a notification would be available, and the Input.SendText method could be used to set it.
But otherwise you only option might then be using the GUI ns or info labels to finish the job.
Point is its really up to the addon developer as they are primarily writing these addons for the consumers use in the built in UI, not often via a remote interface they might not even have considered

2. Using Playlist.insert with a file object and the resulting playlist label

Streams are often tagged with ID3 metadata or whatever the format of the stream might be, so that info often is received by the player upon opening and playing the file, so that info isn't afaik available prior when your in the act of queuing a stream to your playlist...
Ya perhaps adding a label parameter is an option, but it seems to me your going to have to solve the problem of extracting some kind of usable label from each different stream provider if they dont provide the info prior.
Seems a better way would be to run a service that updates your playlilst entry with the meta after playback begins...
Reply
#3
Thanks for your reply axa88

The addon settings were really so the web interface could set and get its own settings (ie web interface settings) so they would be stored in Kodi rather than the browser. I have tinkered with what you mentioned (Files.GetDirectory) but it really feels like a dirty way of doing it so I thought I should stop and ask the question Smile Sounds like it is probably a no-go for now though.

With the playlist insert, I have done some more testing and noticed that if you queue a file item via the Kodi UI (skin) that it correctly populates the playlist with the correct title, thumb, and depending on the add-on, maybe the artist and other metadata, but adding that same file via the api doesn't. So it feels like something is missing with what Playlist.Add is doing when it hands that request over to Kodi's internals. I have poked around in the code to see what the JSON RPC is actually doing vs what the skin does, but my C knowledge is pretty lacking so progress is slow.
Author of Chorus
Reply
#4
PM me the add-on. If be curious to explore this too
Reply
#5
axa88 it is for https://github.com/xbmc/chorus2
Author of Chorus
Reply
#6
(2016-12-20, 23:36)jez500 Wrote: axa88 it is for https://github.com/xbmc/chorus2

I understand this is your client, so are you saying every source from any addon is being added to the playlist how you describe in this thread?
I though you were going to say it was only particular add-on(s)
Reply
#7
(2016-12-21, 11:04)axa88 Wrote: I understand this is your client, so are you saying every source from any addon is being added to the playlist how you describe in this thread?
I though you were going to say it was only particular add-on(s)

Sorry - problem with adding 2 issues to the one thread Wink

With the playlist.insert, the 2 addons I know of specifically are 'radio' and 'soundcloud' but there are definitely more. See this patch I did for radio to get it to use the station name rather than "station" for the playlist item label - https://github.com/dersphere/plugin.audi...ll/7/files

soundcloud uses a route "/play" so all tracks get added with the label of "play"
Author of Chorus
Reply
#8
(2016-12-16, 19:45)axa88 Wrote: 2. Using Playlist.insert with a file object and the resulting playlist label

Streams are often tagged with ID3 metadata or whatever the format of the stream might be, so that info often is received by the player upon opening and playing the file, so that info isn't afaik available prior when your in the act of queuing a stream to your playlist...
Ya perhaps adding a label parameter is an option, but it seems to me your going to have to solve the problem of extracting some kind of usable label from each different stream provider if they dont provide the info prior.
Seems a better way would be to run a service that updates your playlilst entry with the meta after playback begins...

I have been waiting for this JSON API improvement for some time as well, to set the label for items being added to the playlist.

Use case: I have a simple ad-hoc http server written in python that runs in my kodi box and receives URLs to podcasts that I send from my android phone, it then parses the URL, finds the media (and can find the media title/label too), and then uses JSON to get kodi to play/queue the podcast.

Podcasts are almost never tagged properly, hence the kodi playlist displays "id" (weird) song names, not very user friendly, even if it works.
Reply
#9
Hello. playlist.insert and URI in label also happens for Youtube plugin. When I remotly queue few videos to playlist and browse it I have lists of "play" labels
Reply
#10
Looks like not many people need the "set playlist label via JSON" feature 

FWIW, the JSON API could be customized by creating a mini addon that inserts items in the playlist and accepts a label as a parameter. It's a bit cludgy but it gets the job done.

Found this example out there:

https://github.com/farwarx/json-stream-player
 { "jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": { "addonid": "plugin.video.stream.player", "params": { "url":"URL", "title": "TITLE", "thumb": "THUMB", "lang": "LANG", "subtitle": "SUBTITLE" } }, "id": 1 }
I'll use this as a base for my audio-only use-case (adding podcast streams to Kodi's playlist from an external python script) and create a simple addon. After a few years of use without stream titles, it's overdue Smile
Reply
#11
(2017-11-17, 21:08)htpcero Wrote: Looks like not many people need the "set playlist label via JSON" feature
Problems with playlists when non-library items are added to playlist via JSON  is something mentioned in a number of places, how many people want a solution has nothing to do with one being found.

That said I have been looking at this issue, and it is non-trivial. The playlist behaviour can seem quite chaotic, with both skin used and UI navigation by the user effecting what calls to Playlist.GetItems subsequently returns. The UI triggers background loading of art and tag scanning. With addons the Kodi UI is in use at the same time, with remote JSON calls the user may not be looking at the UI at all.
Hence
Quote:With the playlist insert, I have done some more testing and noticed that if you queue a file item via the Kodi UI (skin) that it correctly populates the playlist with the correct title, thumb, and depending on the add-on, maybe the artist and other metadata, but adding that same file via the api doesn't. So it feels like something is missing with what Playlist.Add is doing when it hands that request over to Kodi's internals.
The Radio and Soundcloud addon examples quoted both handle Shoutcasts, an mp3 format stream but with it's own special metadata format. The PAplayer does not read that metadata, the addon does and sets the item tags/properties accordingly.

Setting the item label from JSON seems easy enough, but if the item is local and has embedded data e.g. music files then the background loader may replace that label. The player will also scan tags and use that in preference to any given label. This won't happen with video or streamed music, but it does mean that a label setting feature will appear not to work in certain situations.

TBH I am unsure how far I will get with this, really a fundamental redesign is needed that uses that same method of adding items to the playlist via UI, addons or JSON and I am not able to do that.
Reply
#12
(2017-11-24, 18:38)DaveBlake Wrote:
(2017-11-17, 21:08)htpcero Wrote: Looks like not many people need the "set playlist label via JSON" feature
Problems with playlists when non-library items are added to playlist via JSON  is something mentioned in a number of places, how many people want a solution has nothing to do with one being found.

That said I have been looking at this issue, and it is non-trivial. The playlist behaviour can seem quite chaotic, with both skin used and UI navigation by the user effecting what calls to Playlist.GetItems subsequently returns. The UI triggers background loading of art and tag scanning. With addons the Kodi UI is in use at the same time, with remote JSON calls the user may not be looking at the UI at all.
Hence
Quote:With the playlist insert, I have done some more testing and noticed that if you queue a file item via the Kodi UI (skin) that it correctly populates the playlist with the correct title, thumb, and depending on the add-on, maybe the artist and other metadata, but adding that same file via the api doesn't. So it feels like something is missing with what Playlist.Add is doing when it hands that request over to Kodi's internals.
The Radio and Soundcloud addon examples quoted both handle Shoutcasts, an mp3 format stream but with it's own special metadata format. The PAplayer does not read that metadata, the addon does and sets the item tags/properties accordingly.

Setting the item label from JSON seems easy enough, but if the item is local and has embedded data e.g. music files then the background loader may replace that label. The player will also scan tags and use that in preference to any given label. This won't happen with video or streamed music, but it does mean that a label setting feature will appear not to work in certain situations.

TBH I am unsure how far I will get with this, really a fundamental redesign is needed that uses that same method of adding items to the playlist via UI, addons or JSON and I am not able to do that.   
 
For the record, I ended up writing a mini helper add-on that I call via JSON's addon.execute where I pass the podcast URL and the title, instead of using JSON to add to the playlist directly without a title. It's a bit clunky but it works nicely. 

This is the key function in the addon,
python:

def queueOrPlay(mediaURL, title): playList=xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
  indexForNewItem=len(playList)
  playListItem=xbmcgui.ListItem(title, thumbnailImage=rssIconFile)playListItem.setInfo('music', {'title': title, 'album': 'Audio Podcast'})
  playListItem.setContentLookup(False)
  playList.add(url=mediaURL, listitem=playListItem, index=indexForNewItem)
  if not xbmc.Player().isPlaying(): # play the new entry
    xbmc.Player().play(item=playList,startpos=indexForNewItem)
Reply

Logout Mark Read Team Forum Stats Members Help
JSON-RPC - Get/Set addon settings & Playlist.insert file label0