combine audiobooks: remove unecessary function
This commit is contained in:
1 parent
7158dd4960
commit
dc0cd02e58
1 file changed
-31
@@ -8,7 +8,6 @@ import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
RED = "\033[91m"
|
||||
GREEN = "\033[92m"
|
||||
@@ -145,36 +144,6 @@ def create_m4b(root_path: Path, book_dir: Path) -> None:
|
||||
else:
|
||||
log_message(f"{RED}[ERROR]{RESET} - {book_dir.name} - Code: {result.returncode}, Stderr: {result.stderr}")
|
||||
|
||||
def find_book_dirs(root: Path) -> tuple[list[Any], int]:
|
||||
"""
|
||||
A book directory is any directory containing more than one
|
||||
audiobook file (.mp3, .m4a, .m4b)
|
||||
"""
|
||||
|
||||
media_files = (
|
||||
list(root.rglob("*.mp3"))
|
||||
+ list(root.rglob("*.m4a"))
|
||||
+ list(root.rglob("*.m4b"))
|
||||
+ list(root.rglob("*.opus"))
|
||||
)
|
||||
|
||||
counts: dict[Path, int] = {}
|
||||
|
||||
for file in media_files:
|
||||
if counts.get(file.parent, 0) > 1:
|
||||
continue
|
||||
counts[file.parent] = counts.get(file.parent, 0) + 1
|
||||
|
||||
directories = []
|
||||
size = 0
|
||||
for directory, count in counts.items():
|
||||
if count > 1:
|
||||
directories.append(directory)
|
||||
size += sum(file.stat().st_size for pattern in ("*.mp3", "*.m4a", "*.m4b", "*.opus") for file in directory.glob(pattern))
|
||||
|
||||
|
||||
return sorted(directories), size
|
||||
|
||||
def process_book(args):
|
||||
target, book_dir = args
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user