def update_filelist(nzbid): # If a lock already exists in updating the cache file, bail out. if nzb.lock_exists(LOCK_FILELIST): return # Get the list of files from cache and from disk. nzb.lock_create(LOCK_FILELIST) try: cache_filepath = get_cache_filepath(nzbid) directory = nzb.get_nzb_directory() if not os.path.isdir(directory): nzb.log_warning('Directory %s does not appear valid.' % directory) filelist = nzb.get_new_files(os.listdir(directory), cache_filepath) # Cache the files that we've found that we just processed. with open(cache_filepath, 'a') as cachefile: for filename in filelist: name, extension = os.path.splitext(filename) if extension != '.tmp': cachefile.write(filename + '\n') process_download(directory, filename) cachefile.close() except Exception as e: traceback.print_exc() nzb.log_error(e) raise finally: nzb.lock_release(LOCK_FILELIST)
def reject(reason): nzbid = nzb.get_nzb_id() nzbname = nzb.get_nzb_name() nzb.log_error('Rejecting %s. %s.' % (nzbname, reason)) response = None if REJECT_ACTION == 'Pause': nzb.log_error('File %s was rejected, pausing download.' % nzbname) response = nzb.proxy().editqueue('GroupPause', 0, '', [nzbid]) elif REJECT_ACTION == 'Bad': nzb.log_error('File %s was rejected, marking as bad.' % nzbname) nzb.set_nzb_bad() response = True elif REJECT_ACTION == 'Fail': nzb.log_error('File %s was rejected, marking as failed.' % nzbname) response = nzb.set_nzb_fail(nzbid) if not response: nzb.log_error('Failed to apply the reject action.') nzb.exit(nzb.PROCESS_ERROR) nzb.exit(nzb.PROCESS_ERROR)