combine audiobooks: extend to opus
asd asd
This commit is contained in:
1 parent
e4f1cce494
commit
8b6fc7fdcd
2 files changed
+10
-50
No files matched your search
@@ -43,7 +43,10 @@ def ffmpeg_escape(path: Path) -> str:
|
||||
return str(path.resolve()).replace("'", r"'\''")
|
||||
|
||||
def create_m4b(root_path: Path, book_dir: Path) -> None:
|
||||
media_files = sorted(book_dir.glob("*.m[p,4][3,b,a]"))
|
||||
media_files = sorted(list(book_dir.glob("*.mp3"))
|
||||
+ list(book_dir.glob("*.m4a"))
|
||||
+ list(book_dir.glob("*.m4b"))
|
||||
+ list(book_dir.glob("*.opus")))
|
||||
if not media_files:
|
||||
return
|
||||
|
||||
@@ -152,6 +155,7 @@ def find_book_dirs(root: Path) -> tuple[list[Any], int]:
|
||||
list(root.rglob("*.mp3"))
|
||||
+ list(root.rglob("*.m4a"))
|
||||
+ list(root.rglob("*.m4b"))
|
||||
+ list(root.rglob("*.opus"))
|
||||
)
|
||||
|
||||
counts: dict[Path, int] = {}
|
||||
@@ -166,7 +170,7 @@ def find_book_dirs(root: Path) -> tuple[list[Any], int]:
|
||||
for directory, count in counts.items():
|
||||
if count > 1:
|
||||
directories.append(directory)
|
||||
size += sum(file.stat().st_size for pattern in ("*.mp3", "*.m4a", "*.m4b") for file in directory.glob(pattern))
|
||||
size += sum(file.stat().st_size for pattern in ("*.mp3", "*.m4a", "*.m4b", "*.opus") for file in directory.glob(pattern))
|
||||
|
||||
|
||||
return sorted(directories), size
|
||||
@@ -179,7 +183,6 @@ def process_book(args):
|
||||
except Exception as exc:
|
||||
return book_dir, str(exc)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@@ -196,7 +199,10 @@ def main() -> None:
|
||||
raise SystemExit(f"Path does not exist: {target}")
|
||||
|
||||
# Direct book folder
|
||||
if any(target.glob("*.m[p,4][3,b]")):
|
||||
if any(list(target.glob("*.mp3"))
|
||||
+ list(target.glob("*.m4a"))
|
||||
+ list(target.glob("*.m4b"))
|
||||
+ list(target.glob("*.opus"))):
|
||||
create_m4b(target.parent,target)
|
||||
return
|
||||
|
||||
|
||||
Reference in new issue
Block a user