Mark Folder plugin for Plex / add to database

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
xayide Offline
Senior Member
Posts: 126
Joined: May 2010
Reputation: 0
Post: #11
OK got the code together and it worked good for a few weeks. But now all of a sudden it started acting up on all of my computers. After watching and marking/watched-checking a few movies I get script error which is not going away until I restart XBMC. It doesn't help just exiting the script out to the root of videos in xbmc then entering addons again and the error is still there. Is anyone able to see any direct flaws in the code?


--------------------------- CODE -------------------------------


import os #Used to access host file system
import os.path
import xbmcplugin #Used to interface with XBMC
import xbmcgui #Used for XBMC gui
import urllib #Used for URL handling
import urllib2

def listFolderContent(rootFolder):
folderContents = os.listdir(rootFolder)

#for each entry in the directory listing, create a listitem, then add it to XBMC (noting the check to see if it's a dir or not)
#if the entry IS a folder, then reuse this plugin as the URL, with the new root folder as a parameter
sz = len(folderContents)
mediaVideos = xbmc.getSupportedMedia("video")
found = 0
for entries in folderContents:
url = os.path.join(rootFolder,entries)
url2 = os.path.join(url,"desktop.ini")
isDir = os.path.isdir(url)
isFile = os.path.isfile(url2)
if entries.lower() <> "sample":
if isDir and isFile:
url = sys.argv[0] + "?path=" + url + "\\"
liz=xbmcgui.ListItem("[color=FFFF0000]"+entries+"[/color]",iconImage="DefaultVideo.png")
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,isDir,sz)
elif isDir:
url = sys.argv[0] + "?path=" + url + "\\"
liz=xbmcgui.ListItem(entries,'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,isDir,sz)
else:
ext = os.path.splitext(entries)[1].lower()
if ext in mediaVideos:
liz=xbmcgui.ListItem(entries,'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,isDir,sz)
found = 1
if found:
url = sys.argv[0] + "?a=" + rootFolder + "\\"
liz=xbmcgui.ListItem("-- Archive",'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
url = sys.argv[0] + "?m=" + rootFolder + "\\"
liz=xbmcgui.ListItem("-- Mark",'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
url = sys.argv[0] + "?u=" + rootFolder + "\\"
liz=xbmcgui.ListItem("-- Unmark",'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
url = sys.argv[0] + "?w=" + rootFolder + "\\"
liz=xbmcgui.ListItem("-- Watched",'')
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,0)
xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)
return (0)


#list the available drives on the host PC
def listDrives():
if (sys.platform == 'darwin'):
shares = os.listdir("/volumes")
for share in shares:
drive = "/volumes/"+share
liz=xbmcgui.ListItem(share,'')
url = sys.argv[0] + "?path=" + drive + "\\"
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,1)
elif (sys.platform == 'win32'):
for i in range(ord('a'), ord('z')+1):
drive = chr(i) + ":\\"
if os.path.exists(drive):
liz=xbmcgui.ListItem(drive,'')
url = sys.argv[0] + "?path=" + drive + "\\"
xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,1)
xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)
return(0)


#If a path has been supplied as a parameter, then use that as the root folder to browse, otherwise, start from a list of drives
if cmp (sys.argv[2][0:6],"?path=") == 0:
listFolderContent(sys.argv[2][6:])
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:
dialog = xbmcgui.Dialog()
if dialog.yesno("Confirmation", "Are you sure?"):
pageUrl = "http://10.0.0.7/commit.asp"+sys.argv[2][0:3]+urllib.quote_plus(sys.argv[2][3:])
f=urllib2.urlopen(pageUrl)
a=f.read()
f.close()
if a != "":
dialog = xbmcgui.Dialog()
ok = dialog.ok('Status', a)
else:
listDrives()
find quote
xayide Offline
Senior Member
Posts: 126
Joined: May 2010
Reputation: 0
Post: #12
This is the debug log of the error that happens sometimes after I played a movie or move to quickly in the menues for a while. I don't at all understand the errormessage, anyone can help?


01:56:03 T:608 M:1606332416 NOTICE: -->Python Interpreter Initialized<--
01:56:03 T:608 M:1606332416 DEBUG: XBPyThread::Process - The source file to load is C:\Program Files (x86)\XBMC\addons\MarkFolder.xayide.com\default.py
01:56:03 T:608 M:1606332416 DEBUG: XBPyThread::Process - Setting the Python path to C:\Program Files (x86)\XBMC\addons\MarkFolder.xayide.com;C:\Program Files (x86)\XBMC\addons\script.module.pil\lib;C:\Program Files (x86)\XBMC\addons\script.module.pysqlite\lib;special://xbmc/system/python/Lib;special://xbmcbin/system/python/python24.zip;special://xbmc/system/python\DLLs;special://xbmc/system/python\lib;special://xbmc/system/python\lib\plat-win;special://xbmc/system/python\lib\lib-tk;C:\Program Files (x86)\XBMC
01:56:03 T:608 M:1606332416 DEBUG: XBPyThread::Process - Entering source directory C:\Program Files (x86)\XBMC\addons\MarkFolder.xayide.com
01:56:03 T:608 M:1606348800 ERROR: Stat: fd == -1
01:56:03 T:608 M:1606348800 INFO: -->Python script returned the following error<--
01:56:03 T:608 M:1606348800 ERROR: Error Type: exceptions.RuntimeError
01:56:03 T:608 M:1606348800 ERROR: Error Contents: unable to get modification time from 'special://xbmc/system/python/Lib\tempfile.py'
01:56:03 T:608 M:1606344704 ERROR: Stat: fd == -1
01:56:03 T:608 M:1606336512 ERROR: Previous line repeats 1 times.
01:56:03 T:608 M:1606336512 INFO: -->End of Python script error report<--
01:56:03 T:608 M:1606336512 ERROR: Stat: fd == -1
01:56:03 T:608 M:1606336512 NOTICE: Traceback (most recent call last):
01:56:03 T:608 M:1606336512 NOTICE: File "<string>", line 1, in ?
01:56:03 T:608 M:1606336512 NOTICE: RuntimeError
01:56:03 T:608 M:1606336512 NOTICE: :
01:56:03 T:608 M:1606336512 NOTICE: unable to get modification time from 'special://xbmc/system/python/Lib\threading.py'
01:56:03 T:608 M:1606336512 INFO: Python script stopped
01:56:03 T:608 M:1606336512 DEBUG: Thread 608 terminating
01:56:03 T:1144 M:1606332416 DEBUG: XFILE::CPluginDirectory::WaitOnScriptResult - plugin exited prematurely - terminating
01:56:03 T:1144 M:1606332416 ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://MarkFolder.xayide.com/?path=x://[HDTV] - NATIONAL_GEOGRAPHIC_720P\National.Geographic.Big.Bigger.Biggest.Tunnel.720p.HDTV​.x264-TESTHD/
01:56:03 T:1144 M:1606332416 ERROR: CGUIMediaWindow::GetDirectory(plugin://MarkFolder.xayide.com/?path=x://[HDTV] - NATIONAL_GEOGRAPHIC_720P\National.Geographic.Big.Bigger.Biggest.Tunnel.720p.HDTV​.x264-TESTHD/) failed
01:56:03 T:1144 M:1606332416 DEBUG: python thread 21 destructed
find quote
Post Reply