Exemplo n.º 1
0
def on_post_processing():
    directory = nzb.get_nzb_directory()
    category = nzb.get_nzb_category()
    target = get_category_path(category)

    if os.path.isdir(directory) and target:
        # We need to move the files, delete the directory, and hide the NZB
        # from history.
        file = get_largest_file(category, directory, target)

        if file:
            nzb.log_detail('Found largest file %s.' % file)
            source_path = file
            target_path = os.path.join(target, os.path.basename(file))

            if os.path.isfile(target_path):
                nzb.log_warning('File %s already exists.' % target_path)
            else:
                nzb.log_detail('Copying %s to %s.' % (file, target_path))
                shutil.copyfile(source_path, target_path)
                nzb.set_nzb_directory_final(target)

            shutil.rmtree(directory)
            nzb.log_detail('Deleted directory %s.' % directory)
        else:
            nzb.log_warning('Failed to find largest video file.')
    else:
        nzb.log_warning('Directory %s does not exist.' % directory)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def on_post_processing():
    directory = nzb.get_nzb_directory()
    category = nzb.get_nzb_category()
    target = get_category_path(category)

    if os.path.isdir(directory) and target:
        # We need to move the files, delete the directory, and hide the NZB
        # from history.
        file = get_largest_file(category, directory, target)

        if file:
            nzb.log_detail("Found largest file %s." % file)
            source_path = file
            target_path = os.path.join(target, os.path.basename(file))

            if os.path.isfile(target_path):
                nzb.log_warning("File %s already exists." % target_path)
            else:
                nzb.log_detail("Copying %s to %s." % (file, target_path))
                shutil.copyfile(source_path, target_path)
                nzb.set_nzb_directory_final(target)

            shutil.rmtree(directory)
            nzb.log_detail("Deleted directory %s." % directory)
        else:
            nzb.log_warning("Failed to find largest video file.")
    else:
        nzb.log_warning("Directory %s does not exist." % directory)
Exemplo n.º 4
0
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)