2013-02-12, 22:25
I want to do a small plugin to do this:
1. Ask XBMC for sources (json-rpc)
{"jsonrpc": "2.0", "method": "Files.GetSources", "params" : { "media" : "video" }, "id": 1}
2. Be able to browse those sources and traverse folders like a filetree (getting folders/files via JSON-RPC)
{"jsonrpc" : "2.0", "method" : "Files.GetDirectory", "params":{ "directory": "smb://admin:[email protected]/share/DOCU-SD/" }, "id": 1}
3. Be able to play a file
4. Show a folder in red if the file within has been watched
Is above possible?
Should it be done in xbmcplugin or should I use xbmc.python.script ?
I tried something like this but didn't work to get a list in the window:
class Main:
thisWindow = xbmcgui.Window(xbmcgui.getCurrentWindowId())
def __init__(self):
self.getParams()
self.fetchDB()
self.returnListContent()
def getParams(self):
try:
# parse sys.argv for params
params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
self.controlID = int(params.get("controlid", ""))
except:
# no params passed
params = {}
def fetchDB(self):
self.xbmcListItems = []
movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "thumbnail", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume", "art", "streamdetails"], "limits": {"end": 20}, "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}'))
movieList = movieRecords["result"]["movies"]
for movie in movieList:
movieListItem = xbmcgui.ListItem()
movieListItem.setThumbnailImage(movie["thumbnail"])
self.xbmcListItems.append(movieListItem)
def returnListContent(self):
#self.list = xbmcgui.ControlList(290, 300, 150, 150)
self.thisWindow.getControl(self.controlID).addItems(self.xbmcListItems)
if (__name__ == "__main__"):
Main()
1. Ask XBMC for sources (json-rpc)
{"jsonrpc": "2.0", "method": "Files.GetSources", "params" : { "media" : "video" }, "id": 1}
2. Be able to browse those sources and traverse folders like a filetree (getting folders/files via JSON-RPC)
{"jsonrpc" : "2.0", "method" : "Files.GetDirectory", "params":{ "directory": "smb://admin:[email protected]/share/DOCU-SD/" }, "id": 1}
3. Be able to play a file
4. Show a folder in red if the file within has been watched
Is above possible?
Should it be done in xbmcplugin or should I use xbmc.python.script ?
I tried something like this but didn't work to get a list in the window:
class Main:
thisWindow = xbmcgui.Window(xbmcgui.getCurrentWindowId())
def __init__(self):
self.getParams()
self.fetchDB()
self.returnListContent()
def getParams(self):
try:
# parse sys.argv for params
params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
self.controlID = int(params.get("controlid", ""))
except:
# no params passed
params = {}
def fetchDB(self):
self.xbmcListItems = []
movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "thumbnail", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume", "art", "streamdetails"], "limits": {"end": 20}, "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}'))
movieList = movieRecords["result"]["movies"]
for movie in movieList:
movieListItem = xbmcgui.ListItem()
movieListItem.setThumbnailImage(movie["thumbnail"])
self.xbmcListItems.append(movieListItem)
def returnListContent(self):
#self.list = xbmcgui.ControlList(290, 300, 150, 150)
self.thisWindow.getControl(self.controlID).addItems(self.xbmcListItems)
if (__name__ == "__main__"):
Main()