31 lines
940 B
Python
31 lines
940 B
Python
import logging
|
|
|
|
from tqdm import tqdm
|
|
|
|
from karaokatalog.get_parser import get_parser
|
|
from karaokatalog.recode.recode import recode
|
|
|
|
logging.basicConfig(
|
|
format="%(asctime)s [%(levelname)s] %(message)s", level=logging.INFO
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = get_parser(
|
|
"recode", "Recode all txt files in the directory into UTF-8"
|
|
).parse_args()
|
|
logging.info("Recoding started")
|
|
|
|
logging.info("Finding *.txt files")
|
|
txt_paths = list(tqdm(args.library_path.rglob("*.txt"), unit=" files"))
|
|
logging.info(f"{len(txt_paths)} txt files found")
|
|
|
|
logging.info("Generating recode instructions")
|
|
recode_instructions = recode(txt_paths)
|
|
logging.info(f"{len(recode_instructions)} recode instructions generated")
|
|
|
|
logging.warning(f"Recoding {len(recode_instructions)} files!")
|
|
for instruction in tqdm(recode_instructions, unit=" files"):
|
|
instruction()
|
|
logging.info("Recoding done")
|