コード例 #1
0
ファイル: pre.py プロジェクト: GoblinDynamiteer/scripts
def print_rename_info(src, dst, line=False):
    print("renamed:")
    print(" " * 5, cstr(str(src), Color.Orange))
    print(cstr("--->", "grey"))
    print(" " * 5, cstr(str(dst), Color.LightGreen))
    if line:
        print_line()
コード例 #2
0
ファイル: lister.py プロジェクト: GoblinDynamiteer/scripts
 def print(self):
     _path_str = cstr(str(self._path.parent.resolve()), Color.Grey)
     _name_str = cstr(self._path.name, Color.LightGreen)
     print(f"{_path_str}/{_name_str}")
     if self._omdb_result.valid:
         self._print_data("title", self._omdb_result.title)
         self._print_data("year", self._omdb_result.year)
         self._print_data("genre", self._omdb_result.genre)
     print_line()
コード例 #3
0
def main():
    args = get_args()
    srt_filenames = []
    if args.search_subscene is not None:
        if args.verbose:
            print("searching subscene")
        subscene = SubScene(args.search_subscene, verbose=args.verbose)
        for lang in [Language.English, Language.Swedish]:
            if args.lang is not None:
                if args.lang == "en" and lang != Language.English:
                    continue
                if args.lang == "sv" and lang != Language.Swedish:
                    continue
            sub = subscene.result.get_best(lang)
            if sub:
                srt_path = sub.download_and_unzip()
                if srt_path:
                    handle_srt(srt_path)
            else:
                print(f"could not find any subs for language: {lang}")
        return 0
    if "*" in args.file:
        items = list(Path().glob(args.file))
        if items:
            pfcs(f"found i[{len(items)}] item matching i[{args.file}]")
        for num, item in enumerate(items, 1):
            if len(items) > 1:
                pfcs(f"processing item i[{num}] of {len(items)}")
            if item.suffix.endswith("srt"):
                handle_srt(item.name, auto_move=args.auto_move)
            else:
                pfcs(f"skipping item w[{item.name}], not srt")
            print_line()
        print("done!")
        sys.exit(0)
    file_path = Path(args.file)
    if not file_path.exists():
        print("passed file does not exists")
        exit()
    if file_path.suffix.endswith('zip'):
        srt_filenames = find_srt_filenames_in_zip(file_path)
        if not srt_filenames:
            print("could not find srt in zip file!")
            exit()
        for srt_filename in srt_filenames:
            command = f"unzip -oj {file_path} {srt_filename}"
            if run.local_command(command, print_info=False):
                print(f"extracted {cstr(srt_filename, 154)}!")
    elif file_path.suffix.endswith('srt'):
        srt_filenames = [file_path.name]
    else:
        print("no subtitle file to process..")
        exit()
    [handle_srt(srt, auto_move=args.auto_move) for srt in srt_filenames]
コード例 #4
0
 def print(self):
     tot = 0
     for bank_str in self.accounts:
         tot_bank = 0
         for _, account in self.accounts[bank_str].items():
             account.print()
             val = account.get_latest_balance().value
             tot_bank += val
             tot += val
         print(fcs(f" o[- {bank_str} total]: {to_kr_str(tot_bank)}"))
         print_line()
     print(fcs(f"o[ - total]: {to_kr_str(tot)}"))
コード例 #5
0
ファイル: base_log.py プロジェクト: GoblinDynamiteer/scripts
 def print_large_header(self, title, no_prefix=False):
     print_line()
     _figlet = Figlet()
     for _fig_line in _figlet.renderText(title).split("\n"):
         _str = _fig_line.replace("\n", "")
         if all(" " == ch for ch in _str):
             continue
         if _str:
             if no_prefix:
                 print(_str)
             else:
                 self.log(_str)
     print_line()
コード例 #6
0
ファイル: rename.py プロジェクト: GoblinDynamiteer/scripts
def rename_operation(file_path,
                     operations,
                     dont_rename=False,
                     space_replace_char: str = '_'):
    "Runs string operations on filename, then renames the file"
    new_file_name = file_path.name
    for operation in operations:
        if operation is op_spaces_to_char:
            new_file_name = operation(new_file_name,
                                      replace_char=space_replace_char)
        else:
            new_file_name = operation(new_file_name)
    renamed_file_path = file_path.parent / new_file_name
    old = to_color_str(file_path.relative_to(Path.cwd()), 'orange')
    new = to_color_str(renamed_file_path.relative_to(Path.cwd()), 'green')
    if new_file_name == file_path.name:
        print(f'kept filename: {to_color_str(file_path.name, "green")}')
    else:
        if not dont_rename:
            os.rename(file_path, renamed_file_path)
        print(f"renamed {old}\n" f" -->    {new}")
    print_line()