Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not no_sources:
- # start reading sources.xml and build SQL statements to exclude these sources from any cleaning
- try:
- display_list =[]
- for video in root.findall('video'):
- dbglog('Contents of sources.xml file')
- for sources in video.findall('source'):
- for path_name in sources.findall('name'):
- the_path_name = path_name.text
- for paths in sources.findall('path'):
- the_path = paths.text.replace("'","''")
- display_list.append(the_path)
- dbglog('%s - %s' % (the_path_name, the_path))
- if first_time:
- first_time = False
- my_command = "strPath NOT LIKE '" + the_path + "%'"
- our_source_list = 'Keeping files in ' + the_path
- else:
- my_command = my_command + " AND strPath NOT LIKE '" + the_path + "%'"
- our_source_list = our_source_list + ', ' + the_path
- if path_name == '':
- no_sources = True
- dbglog('******* WARNING *******')
- dbglog('local sources.xml specified in settings')
- dbglog('But no sources found in sources.xml file')
- dbglog('Defaulting to alternate method for cleaning')
- except:
- log('Error parsing sources.xml file')
- xbmcgui.Dialog().ok(addonname, 'Error parsing sources.xml file - script aborted')
- exit_on_error()
- if is_pvr:
- my_command = my_command + " AND strPath NOT LIKE 'pvr://%'"
- our_source_list = our_source_list + 'Keeping PVR info '
- if excluding:
- my_command = my_command + exclude_command
- our_source_list = our_source_list + 'Keeping items from excludes.xml '
- if bookmarks:
- my_command = my_command + ' AND idFile NOT IN (SELECT idFile FROM bookmark)'
- our_source_list = our_source_list + 'Keeping bookmarked files '
- # construct the full SQL query
- sql = \
- """DELETE FROM files WHERE idPath IN(SELECT idPath FROM path where (""" + my_command + """));"""
- if no_sources:
- my_command = ''
- our_source_list = 'NO SOURCES FOUND - REMOVING rtmp(e), plugin and http info '
- dbglog('Not using sources.xml')
- if is_pvr:
- my_command = my_command + "strPath NOT LIKE 'pvr://%'"
- our_source_list = our_source_list + 'Keeping PVR info '
- if bookmarks:
- if my_command:
- my_command = my_command + ' AND idFile NOT IN (SELECT idFile FROM bookmark)'
- else:
- my_command = my_command + ' idFile NOT IN (SELECT idFile FROM bookmark)'
- our_source_list = our_source_list + 'Keeping bookmarked files '
- if excluding:
- if my_command:
- my_command = my_command + exclude_command
- else:
- my_command = my_command + exclude_command.replace('AND','',1)
- our_source_list = our_source_list + 'Keeping items from excludes.xml '
- # Build SQL query
- if not no_sources: # this is SQL for no sources
- sql = """DELETE FROM files WHERE idPath IN ( SELECT idPath FROM path WHERE ((""" + my_command + """)));"""
- # sql2="""DELETE FROM path WHERE idPath IN (SELECT * FROM( SELECT idPath FROM path WHERE ((strPath LIKE 'rtmp://%' OR strPath Like 'rtmpe:%' OR strPath LIKE 'plugin:%' OR strPath LIKE 'http://%') AND (""" + my_command +"""))) as pathsub);"""
- else:
- sql = """DELETE FROM files WHERE idPath IN (SELECT idPath FROM path WHERE ((strPath LIKE 'rtmp://%' OR strPath LIKE 'rtmpe:%' OR strPath LIKE 'plugin:%' OR strPath LIKE 'http://%' OR strPath LIKE 'https://%') AND (""" + my_command + """)));"""
- # sql2= """DELETE FROM path WHERE idPath IN (SELECT * FROM( SELECT idPath FROM path WHERE (strPath LIKE 'rtmp://%' OR strPath Like 'rtmpe:%' OR strPath LIKE 'plugin:%' OR strPath LIKE 'http://%') as pathsub);"""
- if my_command == "":
- sql=sql.replace('((strPath','(strPath').replace(' AND ()))',')')
- dbglog('SQL command is %s' % sql)
- if not specificpath and not replacepath:
- dbglog (our_source_list)
- our_select = sql.replace('DELETE FROM files','SELECT strPath FROM path',1)
- if bookmarks: # have to delete from paths table rather than files as there is a conflicting trigger on the files table
- our_select = sql.replace('DELETE FROM files', 'SELECT strPath FROM path WHERE idPath in (SELECT idPath FROM files', 1)
- our_select = our_select.replace('bookmark)', 'bookmark))',1)
- sql = sql.replace('DELETE FROM files','DELETE FROM path',1)
- dbglog('Select Command is %s' % our_select)
- elif not replacepath and specificpath: # cleaning a specific path
- if specific_path_to_remove != '':
- sql = """delete from path where idPath in(select * from (SELECT idPath FROM path WHERE (strPath LIKE '""" + specific_path_to_remove +"""%')) as temptable)"""
- our_select = "SELECT strPath FROM path WHERE idPath IN (SELECT idPath FROM path WHERE (strPath LIKE'" + specific_path_to_remove + "%'))"
- dbglog('Select Command is %s' % our_select)
- else:
- xbmcgui.Dialog().ok(addonname,'Error - Specific path selected but no path defined. Script aborted')
- dbglog("Error - Specific path selected with no path defined")
- exit_on_error()
- else: # must be replacing a path at this point
- if old_path != '' and new_path != '':
- our_select = "SELECT strPath from path WHERE strPath Like '" + old_path + "%'"
- else:
- xbmcgui.Dialog().ok(addonname,'Error - Replace path selected but one or more paths are not defined. Script aborted')
- dbglog('Error - Missing path for replacement')
- exit_on_error()
- xbmc.sleep(500)
- if promptdelete:
- cleaner_log_file(our_select, False)
- mydisplay = MyClass('cleaner-window.xml', addonpath, 'Default', '1080i')
- mydisplay.doModal()
- del mydisplay
- if flag == 1:
- i = True
- else:
- i = False
- else:
- i = True
Add Comment
Please, Sign In to add comment