Traverse/browse source as filesystem
#1
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()
Reply
#2
This should be possible, though I don't know how to do the red folder thing. You'll have to do it in a video plugin. Look at xbmcplugin.addDirectoryItems. This lets you create your own entries in the video browser, as directories or clips. You may also want to check out xbmcswift to make your life a little easier, as the video browser entries aren't actual file system directories. You'll probably want to get your source directories, then use something like os.walk to traverse them in the actual file system, then feed that information to the gui using xbmcswift.
Reply
#3
I go this together but missing the scrapinginfo:

http://pastebin.com/jGCpziSA
Reply

Logout Mark Read Team Forum Stats Members Help
Traverse/browse source as filesystem0