Beispiel #1
0
def create_data_and_move_with_custom_number(file_path: str, custom_number,
                                            oCC):
    conf = config.getInstance()
    file_name = os.path.basename(file_path)
    try:
        print("[!] [{1}] As Number Processing for '{0}'".format(
            file_path, custom_number))
        if custom_number:
            core_main(file_path, custom_number, oCC)
        else:
            print("[-] number empty ERROR")
        print("[*]======================================================")
    except Exception as err:
        print("[-] [{}] ERROR:".format(file_path))
        print('[-]', err)

        if conf.link_mode():
            print("[-]Link {} to failed folder".format(file_path))
            os.symlink(file_path, os.path.join(conf.failed_folder(),
                                               file_name))
        else:
            try:
                print("[-]Move [{}] to failed folder".format(file_path))
                shutil.move(file_path,
                            os.path.join(conf.failed_folder(), file_name))
            except Exception as err:
                print('[!]', err)
def create_data_and_move(file_path: str, zero_op, oCC):
    # Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
    debug = config.getInstance().debug()
    n_number = get_number(debug, os.path.basename(file_path))
    file_path = os.path.abspath(file_path)

    if debug is True:
        print(f"[!] [{n_number}] As Number making data for '{file_path}'")
        if zero_op:
            return
        if n_number:
            core_main(file_path, n_number, oCC)
        else:
            print("[-] number empty ERROR")
            moveFailedFolder(file_path)
        print("[*]======================================================")
    else:
        try:
            print(f"[!] [{n_number}] As Number making data for '{file_path}'")
            if zero_op:
                return
            if n_number:
                core_main(file_path, n_number, oCC)
            else:
                raise ValueError("number empty")
            print("[*]======================================================")
        except Exception as err:
            print(f"[-] [{file_path}] ERROR:")
            print('[-]', err)

            try:
                moveFailedFolder(file_path)
            except Exception as err:
                print('[!]', err)
def create_data_and_move(file_path: str, c: config.Config, debug):
    # Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
    n_number = get_number(debug, os.path.basename(file_path))
    file_path = os.path.abspath(file_path)

    if debug == True:
        print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number))
        core_main(file_path, n_number, c)
        print("[*]======================================================")
    else:
        try:
            print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number))
            core_main(file_path, n_number, c)
            print("[*]======================================================")
        except Exception as err:
            print("[-] [{}] ERROR:".format(file_path))
            print('[-]', err)

            # 3.7.2 New: Move or not move to failed folder.
            if c.failed_move() == False:
                if c.soft_link():
                    print("[-]Link {} to failed folder".format(file_path))
                    os.symlink(file_path, conf.failed_folder() + "/")
            elif c.failed_move() == True:
                if c.soft_link():
                    print("[-]Link {} to failed folder".format(file_path))
                    os.symlink(file_path, conf.failed_folder() + "/")
                else:
                    try:
                        print("[-]Move [{}] to failed folder".format(file_path))
                        shutil.move(file_path, conf.failed_folder() + "/")
                    except Exception as err:
                        print('[!]', err)
def create_data_and_move(file_path: str, c: config.Config, debug):
    # Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
    file_name = os.path.basename(file_path)
    n_number = get_number(debug, file_name)
    file_path = os.path.abspath(file_path)

    if c.useDatabase() is True:
        multi_part, part = get_part(n_number, file_path)
        alreadyInDB = database.addNumber(
            n_number + part, os.path.relpath(file_path, os.getcwd()))
        if alreadyInDB:
            print(
                "[!]Data for [{}] with number [{}] is in the database".format(
                    file_path, n_number))
            if not c.ignoreDatabase():
                return

    if debug == True:
        print("[!]Making Data for [{}], the number is [{}]".format(
            file_path, n_number))
        if n_number:
            core_main(file_path, n_number, c)
        else:
            print("[-] number empty ERROR")
        print("[*]======================================================")
    else:
        try:
            print("[!]Making Data for [{}], the number is [{}]".format(
                file_path, n_number))
            if n_number:
                core_main(file_path, n_number, c)
            else:
                raise ValueError("number empty")
            print("[*]======================================================")
        except Exception as err:
            print("[-] [{}] ERROR:".format(file_path))
            print('[-]', err)

            # 3.7.2 New: Move or not move to failed folder.
            if c.failed_move() == False:
                if c.soft_link():
                    print("[-]Link {} to failed folder".format(file_path))
                    os.symlink(file_path,
                               os.path.join(conf.failed_folder(), file_name))
            elif c.failed_move() == True:
                if c.soft_link():
                    print("[-]Link {} to failed folder".format(file_path))
                    os.symlink(file_path,
                               os.path.join(conf.failed_folder(), file_name))
                else:
                    try:
                        print(
                            "[-]Move [{}] to failed folder".format(file_path))
                        shutil.move(
                            file_path,
                            os.path.join(conf.failed_folder(), file_name))
                    except Exception as err:
                        print('[!]', err)
def create_data_and_move_with_custom_number(file_path: str, c: config.Config, custom_number):
    try:
        print("[!]Making Data for [{}], the number is [{}]".format(file_path, custom_number))
        core_main(file_path, custom_number, c)
        print("[*]======================================================")
    except Exception as err:
        print("[-] [{}] ERROR:".format(file_path))
        print('[-]', err)

        if c.soft_link():
            print("[-]Link {} to failed folder".format(file_path))
            os.symlink(file_path, conf.failed_folder() + "/")
        else:
            try:
                print("[-]Move [{}] to failed folder".format(file_path))
                shutil.move(file_path, conf.failed_folder() + "/")
            except Exception as err:
                print('[!]', err)