예제 #1
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)
예제 #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)
예제 #3
0
def on_nzb_added():
    # Clean up any previous runs.
    clean_up()

    # Lock the script from running again.
    nzb.lock_create(SCRIPT_NAME)
    nzbid = nzb.get_nzb_id()

    # Move the last RAR file to the top.
    reorder_queued_items(nzbid)
예제 #4
0
def on_nzb_added():
    # Clean up any previous runs.
    clean_up()

    # Lock the script from running again.
    nzb.lock_create(SCRIPT_NAME)
    nzbid = nzb.get_nzb_id()

    # Move the last RAR file to the top.
    reorder_queued_items(nzbid)
예제 #5
0
def main():
    """
    We need to check to make sure the script can run in the provided
    environment and that certain status checks have occurred. All of the
    calls here will exit with an exit code if the check fails.
    """
    try:
        # If the script state was set to Disabled, we don't need to run.
        if SCRIPT_STATE == 'Disabled':
            nzb.exit(nzb.PROCESS_SUCCESS)

        # Check the status before we decide if we can continue.
        nzb.check_nzb_status()

        # Check if lock exists.
        if nzb.lock_exists('FileMover'):
            nzb.log_info('Lock exists, skipping execution.')
            nzb.exit(nzb.PROCESS_SUCCESS)
        else:
            nzb.lock_create('FileMover')

        # Check version of NZBGet to make sure we can run.
        nzb.check_nzb_version(13.0)

        # Wire up your event handlers before the call.
        # User the form nzb.set_handler(<event>, <function>)
        nzb.set_handler('POST_PROCESSING', on_post_processing)
        nzb.set_handler('SCHEDULED', on_scheduled)

        # Do not change this line, it checks the current event
        # and executes any event handlers.
        nzb.execute()
    except Exception as e:
        traceback.print_exc()
        nzb.exit(nzb.PROCESS_ERROR, e)
    finally:
        clean_up()
예제 #6
0
def main():
    """
    We need to check to make sure the script can run in the provided
    environment and that certain status checks have occurred. All of the
    calls here will exit with an exit code if the check fails.
    """
    try:
        # If the script state was set to Disabled, we don't need to run.
        if SCRIPT_STATE == "Disabled":
            nzb.exit(nzb.PROCESS_SUCCESS)

        # Check the status before we decide if we can continue.
        nzb.check_nzb_status()

        # Check if lock exists.
        if nzb.lock_exists("FileMover"):
            nzb.log_info("Lock exists, skipping execution.")
            nzb.exit(nzb.PROCESS_SUCCESS)
        else:
            nzb.lock_create("FileMover")

        # Check version of NZBGet to make sure we can run.
        nzb.check_nzb_version(13.0)

        # Wire up your event handlers before the call.
        # User the form nzb.set_handler(<event>, <function>)
        nzb.set_handler("POST_PROCESSING", on_post_processing)
        nzb.set_handler("SCHEDULED", on_scheduled)

        # Do not change this line, it checks the current event
        # and executes any event handlers.
        nzb.execute()
    except Exception as e:
        traceback.print_exc()
        nzb.exit(nzb.PROCESS_ERROR, e)
    finally:
        clean_up()