コード例 #1
0
ファイル: sub_extract.py プロジェクト: Nyx0uf/python-scripts
                f"{common.COLOR_WHITE}[+] Extracting track {sub_stream.id} from {common.COLOR_YELLOW}{infile} with {common.COLOR_PURPLE}{cmd}{common.COLOR_WHITE}"
            )
            os.system(cmd)
        p_queue.task_done()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("input",
                        type=Path,
                        help="Path to directory or single video file")
    parser.add_argument("-v",
                        "--verbose",
                        dest="verbose",
                        action="store_true",
                        help="Verbose mode")
    args = parser.parse_args()
    LOGGER = logger.Logger(args.verbose)

    # Sanity checks
    common.ensure_exist(["ffmpeg"])
    if args.input.exists() is None:
        common.abort(parser.format_help())

    # Get a list of files
    files = common.list_directory(args.input.resolve())
    queue = common.as_queue(files)

    # Extract
    common.parallel(extract_subtitles, (queue, ))
コード例 #2
0
ファイル: fbtrim.py プロジェクト: Nyx0uf/python-scripts
    parser.add_argument("input", type=Path, help="Path to binary or directory")
    parser.add_argument("-p", "--pretend", dest="pretend", action="store_true", help="Do not trim, just print")
    args = parser.parse_args()

    # Sanity check
    if args.arch not in ARCHS:
        common.abort(f"{common.COLOR_RED}[!] ERROR: Invalid arch {common.COLOR_WHITE}{args.arch}\n{common.COLOR_YELLOW}[+] Available archs:\n- {ARCHS}")

    # Get executable list
    tmp: List[Path] = []
    if args.input.is_dir() is True:
        tmp = common.walk_directory(args.input, common.is_executable)
    elif common.is_executable(args.input):
        tmp.append(args.input)

    paths: List[Path] = []
    q = common.as_queue(tmp)
    common.parallel(fct=th_filter, args=(q, args.arch, paths, ))

    bytes_saved = int(0)
    for path in paths:
        print(f"{common.COLOR_WHITE}[+] Trimming {common.COLOR_YELLOW}{path}{common.COLOR_WHITE}")
        if args.pretend is False:
            osize = path.stat().st_size
            remove_arch(args.arch, path)
            nsize = path.stat().st_size
            bytes_saved += (osize - nsize)

    if args.pretend is False:
        print(f"{common.COLOR_WHITE}[+] {common.COLOR_GREEN if bytes_saved > 0 else common.COLOR_RED}{bytes_saved} bytes saved ({bytes_saved / 1048576:4.2f}Mb)")