From f2f550bfa1c20d423cceab1e7cba9a39cb5344d0 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sun, 8 Oct 2023 19:44:14 -0400 Subject: [PATCH] finish rip --- rip.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/rip.py b/rip.py index cd9d5e6..8023810 100644 --- a/rip.py +++ b/rip.py @@ -1,6 +1,30 @@ -# name=$(basename "$1" .aax) +import os +import subprocess +import sys + # ffmpeg -y -activation_bytes $KEY -i "$name.aax" -map_metadata 0 -id3v2_version 3 -codec:a copy -vn "output/$name.m4b" # mv "$name.aax" "converted/$name.aax" +def rip(filename): + key = os.environ.get("AUDIBLE_KEY") + if not key: + raise Exception("set envvar AUDIBLE_KEY") + name = filename[:-4] + commands = [ + "ffmpeg", + "-y", + "-activation_bytes", key, + "-i", f"{name}.aax", + "-map_metadata", "0", + "-id3v2_version", "3", + "-codec:a", "copy", + "-vn", f"output/{name}.m4b" + ] + if subprocess.run(commands).returncode == 0: + print("FFmpeg Script Ran Successfully") + subprocess.run(["mv", f"{name}.aax", f"converted/{name}.aax"]) + else: + print("There was an error ripping") + if __name__ == "__main__": - main() + rip(sys.argv[-1])