Advertisement
Guest User

xayide

a guest
Feb 15th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.95 KB | None | 0 0
  1. import os          
  2. import os.path
  3. import xbmcplugin  
  4. import xbmcgui      
  5. import urllib      
  6. import urllib2
  7. import re
  8. import simplejson
  9. import xbmcvfs
  10.  
  11. def listFolderContent(rootFolder):
  12.     movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc" : "2.0", "method" : "Files.GetDirectory", "params":{ "directory": "'+rootFolder+'" }, "id": 1}'))
  13.     movieList = movieRecords["result"]["files"]
  14.     if not movieList:
  15.         liz=xbmcgui.ListItem('-- EMPTY --','')
  16.         url = '-- EMPTY --'
  17.         xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  18.     else:
  19.         for movie in movieList:            
  20.             if movie["filetype"] == 'directory' and movie["label"].lower() <> "subs" and movie["label"].lower() <> "proof" and movie["label"].lower() <> "sample" and movie["label"].lower() <> ".ds_store" and movie["label"].lower() <> "$recycle.bin" and movie["label"].lower() <> "system volume information":    
  21.                 if xbmcvfs.exists(movie["file"]+'desktop.ini') :
  22.                     liz=xbmcgui.ListItem("[COLOR=FFFF0000]"+movie["label"]+"[/COLOR]")
  23.                 else:
  24.                     liz=xbmcgui.ListItem(movie["label"],'')
  25.                 url = sys.argv[0] + "?path=" + urllib.quote_plus(movie["file"])
  26.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,1)
  27.             elif movie["filetype"] == 'file' and os.path.splitext(movie["file"])[1].lower() in xbmc.getSupportedMedia('video'):
  28.                 liz=xbmcgui.ListItem(movie["label"],'')
  29.                 url = movie["file"]
  30.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  31.                 url = sys.argv[0] + "?a=" + urllib.quote_plus(rootFolder)
  32.                 liz=xbmcgui.ListItem("--  Archive",'')
  33.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  34.                 url = sys.argv[0] + "?m=" + urllib.quote_plus(rootFolder)
  35.                 liz=xbmcgui.ListItem("--  Mark",'')
  36.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  37.                 url = sys.argv[0] + "?u=" + urllib.quote_plus(rootFolder)
  38.                 liz=xbmcgui.ListItem("--  Unmark",'')
  39.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  40.                 url = sys.argv[0] + "?w=" + urllib.quote_plus(rootFolder)
  41.                 liz=xbmcgui.ListItem("--  Watched",'')
  42.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  43.             elif movie["filetype"] == 'file' and (os.path.splitext(movie["file"])[1].lower() in xbmc.getSupportedMedia('music') or os.path.splitext(movie["file"])[1].lower() in xbmc.getSupportedMedia('picture')):
  44.                 liz=xbmcgui.ListItem(movie["label"],'')
  45.                 url = movie["file"]
  46.                 xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
  47.     xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)
  48.     return (0)
  49.  
  50.  
  51. if cmp (sys.argv[2][0:6],"?path=") == 0:
  52.     listFolderContent(urllib2.unquote(sys.argv[2][6:]))
  53. elif cmp (sys.argv[2][0:3],"?a=") == 0 or cmp (sys.argv[2][0:3],"?m=") == 0 or cmp (sys.argv[2][0:3],"?u=") == 0 or cmp (sys.argv[2][0:3],"?w=") == 0:
  54.     dialog = xbmcgui.Dialog()
  55.     if dialog.yesno("Confirmation", "Are you sure?"):
  56.         pageUrl = "http://mediaserver/markfolder.asp"+sys.argv[2][0:3]+sys.argv[2][3:-3]
  57.         f=urllib2.urlopen(pageUrl)
  58.         a=f.read()
  59.         f.close()
  60.         if a != "":
  61.             dialog = xbmcgui.Dialog()
  62.             ok = dialog.ok('Status', a)
  63. else:
  64.     movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc" : "2.0", "method" : "Files.GetDirectory", "params":{ "directory": "smb://mediaserver/movies/" }, "id": 1}'))
  65.     movieList = movieRecords["result"]["files"]
  66.     for movie in movieList:            
  67.         liz=xbmcgui.ListItem('[Mediaserver] - '+movie["label"],'')
  68.         url = sys.argv[0] + "?path=" + urllib.quote_plus(movie["file"])
  69.         xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,1)
  70.     xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement