Compare commits
No commits in common. "fa3df3d2e20cb00a35a38ccd8da4c16edcf99e67" and "df5fc374196f5b23a14104580bb9e511a8a4a7eb" have entirely different histories.
fa3df3d2e2
...
df5fc37419
13
README.md
13
README.md
@ -4,7 +4,6 @@ Tools to manage an Ultrastar DX song library. Features include:
|
|||||||
|
|
||||||
1. Deduplication
|
1. Deduplication
|
||||||
2. Organization
|
2. Organization
|
||||||
3. Recoding
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@ -43,15 +42,3 @@ python3 -m karaokatalog.deduplicate $SONG_LIBRARY
|
|||||||
```bash
|
```bash
|
||||||
python3 -m karaokatalog.organize $SONG_LIBRARY
|
python3 -m karaokatalog.organize $SONG_LIBRARY
|
||||||
```
|
```
|
||||||
|
|
||||||
### Recode
|
|
||||||
|
|
||||||
**Re-encode all txt files into UTF-8.** This will use normal UTF-8, i.e., UTF-8 without BOM. If the txt uses UTF-8 with BOM, BOM is removed.
|
|
||||||
|
|
||||||
⚠️ This will _irreversible_ change the encoding of the txt files (based on a guessed encoding).
|
|
||||||
|
|
||||||
ℹ️ Deduplication is risk-reduced: We only change the encoding if we are reasonably certain our guessed encoding is correct. However, we could still make mistakes when detecting.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m karaokatalog.recode $SONG_LIBRARY
|
|
||||||
```
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
from dataclasses import dataclass
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from karaokatalog.instructions.Instruction import Instruction
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class RecodeInstruction(Instruction):
|
|
||||||
"""
|
|
||||||
Open the file at the given path with the given old encoding, and save it with the given new encoding.
|
|
||||||
"""
|
|
||||||
|
|
||||||
path: Path
|
|
||||||
old_encoding: str
|
|
||||||
new_encoding: str
|
|
||||||
|
|
||||||
def __call__(self) -> None:
|
|
||||||
raise NotImplementedError()
|
|
@ -30,9 +30,7 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
instruction()
|
instruction()
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
logging.error(
|
logging.error(f"Could not move {instruction.old_path} -> {instruction.new_path}")
|
||||||
f"Could not move {instruction.old_path} -> {instruction.new_path}"
|
|
||||||
)
|
|
||||||
logging.info("Moving done")
|
logging.info("Moving done")
|
||||||
|
|
||||||
logging.info("Karaokatalog Organization done")
|
logging.info("Karaokatalog Organization done")
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
from karaokatalog.get_parser import get_parser
|
|
||||||
from karaokatalog.organize.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")
|
|
@ -1,8 +0,0 @@
|
|||||||
from collections.abc import Sequence
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from karaokatalog.instructions.RecodeInstruction import RecodeInstruction
|
|
||||||
|
|
||||||
|
|
||||||
def recode(paths: Sequence[Path]) -> Sequence[RecodeInstruction]:
|
|
||||||
raise NotImplementedError()
|
|
Loading…
x
Reference in New Issue
Block a user