2012-06-19, 18:36
(2012-06-19, 02:15)datalore44 Wrote: Hi. Has anyone managed to get this working yet?
I tried Snavaro`s code and all it did was to lock up!
Could not a separate script be made that could give you the delete option after you press stop?
Hi datalore,
I have been working on the lockup issues. Several things apparently come into play. First, there is no way currently to determine when the CleanLibrary function is finished, and apparently if the Container is Refreshed while cleaning is in progress.. it just locks up. To solve that issue, I have moved the PreviousMenu and Container.Refresh commands ahead of the Cleaning function. That way,I did not have to worry about setting sleep delays that varied by computer speed, library size etc.
From what I have learned, monitoring the Clean function will be possible in Frodo, as it has been implemented in the recent builds via Library.IsScanningVideo.
Here is my updated code. Try it and let me know what other bugs there are.
Code:
import xbmc, xbmcgui, os, sys
import xbmcvfs
import ntpath
file = xbmc.getInfoLabel( "ListItem.FilenameAndPath" )
title1 = xbmc.getInfoLabel( "ListItem.TVShowTitle" )
title2 = xbmc.getInfoLabel( "ListItem.Title" )
#either title1 or title2 will be a null string
title = title1 + title2
print "file = " + file
filename = ntpath.basename(file)
filename1, ext = os.path.splitext(filename)
# for future development to delete ancillary files
file1 = filename1 + ".nfo" #...same filename different extension
file2 = filename1 + ".tbn"
if title == title1:
category = "TvShowTitles"
else:
category = "MovieTitles"
#------------above category code not needed for now----------
if (not xbmc.abortRequested):
if xbmcvfs.exists(file):
xbmcvfs.delete(file)
#comment out above line for testing...remove comment hash to implement
print "Deleting " + file #for debugging only ..can be deleted
xbmc.executebuiltin("XBMC.Notification(%s, %s, %i)" % ('Deleting File',filename + ' is being deleted.',4000)) # Screen notification of file deletion process
xbmc.sleep(4000)
else:
print "File does not exist!"
xbmc.executebuiltin("XBMC.Notification(%s, %s, %i)" % ('File Not Found',filename + ' not found in database!',4000))
# Check for deletion process to finish before cleaning.
while (xbmcvfs.exists(file) and not xbmc.abortRequested):
xbmc.sleep(3000)
print "File deletion not yet complete..."
# Check if the library is being updated before cleaning up
while (xbmc.getCondVisibility("Library.IsScanningVideo")):
xbmc.sleep(5000)
xbmc.executebuiltin("Notification(Library Scan in Progress,Waiting Until Library Scan Completes...,5000)")
if (not xbmcvfs.exists(file)):
print "File has been deleted."
# refresh display
xbmc.executebuiltin("xbmc.action(PreviousMenu)")
xbmc.sleep(1000)
xbmc.executebuiltin("Container.Refresh")
xbmc.executebuiltin("XBMC.CleanLibrary(video)")
print "Cleaning library"
# The following will only work in Eden 12.0
#while (xbmc.getCondVisibility('Library.IsScanningVideo')) : #wait while CleanLibrary finishes
# xbmc.sleep(5000)