Audio-Playlist Enhancer
#1
Hey Guys,

I was trying to get a addon up and running that should do the following:
Add selected Track to playlist and Skip one forward...

Thought about something like this:
Code:
XBMC.Action(Queue)
XBMC.PlayerCommand(Next)

This didn't work for me...
So I tried digging the forum and found this thread:
http://forum.xbmc.org/showthread.php?tid=34198

I tried to follow the commands in there, but no success...
Maybe someone has a hint for me...Would be awesome...

As additional information: This should be realised using a Pre-Eden-Nightly
and later on the addon should later on be mapped to a key

Thanks for your help in advance.

cheers,
mad-max
- - - Tribute to Metallica - - -
If I managed to help you, please click my reputation
Reply
#2
Using JSON-RPC might do it.

There are AudioPlaylist.Add and AudioPlaylist.SkipNext methods. http://wiki.xbmc.org/index.php?title=JSO...ioPlaylist

Not tried them yet myself.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#3
el_Paraguayo Wrote:Not tried them yet myself.

I have now!

So yes, these should do exactly what you want.

Here's an example (although I haven't tested this in XBMC):
Code:
import xbmc

AddToPlaylist = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "id": 1, "params": {"item": {[color=red]"songid": 7[/color]}}}')

if AddToPlaylist["result"] == "OK":
  xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.SkipNext", "id": 1}')

The bit in red is how you add an item to the playlist. According to the wiki, you can pass any of the following:
Code:
[ Playlist.Id playlist ]
    [ Library.Id songid = -1 ]
    [ Library.Id albumid = -1 ]
    [ Library.Id artistid = -1 ]
    [ string file = "" ]
    [ string directory = "" ]
    [ Library.Id genreid = -1 ]
so it depends on what information you're passing to the script.

Happy to help more if I can.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#4
the wiki was very confusing for me too because its not up to date. but i managed it by just reading, reading and reading stuff about JSON RPC. so the first thing would be to understand the syntax of JSON, you can find a simple introduction on wikipedia (or read the JSON reference):

http://en.wikipedia.org/wiki/JSON

the second thing to understand is what JSON RPC is. its an extension of JSON for remote procedure calls (that would be the queries you want to create). Wikipedia is your friend here too:

http://en.wikipedia.org/wiki/JSON-RPC

and finally you simply need a documentation what remote procedure calls are supported by XBMC. i suggest to download the current nightly build as this version has the most recent implementation of JSON RPC. then just send the command JSON.Introspect() whereas you will get a full description of all supported commands and parameters.

and a side note: you should subscribe to the following thread...

http://forum.xbmc.org/showthread.php?tid=98551

...to get a notification when montellese adds new functionality to the JSON RPC interface because its a pain in the ass to read the whole json development thread.

hope this helps.
Reply
#5
Thanks for pointing me in the direction...
currently there is a problem here:

Code:
21:04:09 T:2504  NOTICE: -->Python Interpreter Initialized<--
21:04:09 T:2504   ERROR: Error Type: <type 'exceptions.TypeError'>
21:04:09 T:2504   ERROR: Error Contents: string indices must be integers, not str
21:04:09 T:2504   ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.playlistenhancer\default.py", line 5, in <module>
                                                if AddToPlaylist["result"] == "OK":
                                            TypeError: string indices must be integers, not str

Tried to get the result that will be returned an integer but no success... will report back if I found the solution...

mm
- - - Tribute to Metallica - - -
If I managed to help you, please click my reputation
Reply
#6
Hang on, I've forgotten to parse the output with simplejson...

I'll update in an hour or so.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#7
el_Paraguayo Wrote:Hang on, I've forgotten to parse the output with simplejson...

I'll update in an hour or so.

Ok, try this:
Code:
import xbmc
import simplejson as json

AddToPlaylist = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "id": 1, "params": {"item": {"songid": 7}}}'))

if AddToPlaylist["result"] == "OK":
  xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.SkipNext", "id": 1}')

You'll need to have script.module.simplejson installed and include it in your addon.xml file e.g.
Code:
<requires>
    <import addon="xbmc.python" version="1.0"/>
    <import addon="script.module.simplejson" version="2.0.10"/>
  </requires>
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#8
Also, just to complicate things a bit more, the "AudioPlaylist" method doesn't exist in recent nightlies (see this post).

I think it's just "Playlist" now.

The best way to check what's going on is take a look at the output of the "JSONRPC.Introspect" method.

That, and follow the JSON-RPC thread.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply

Logout Mark Read Team Forum Stats Members Help
Audio-Playlist Enhancer0