2023-10-08 23:44:14 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2023-10-08 18:37:42 +00:00
|
|
|
# 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"
|
|
|
|
|
2023-10-08 23:44:14 +00:00
|
|
|
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")
|
|
|
|
|
2023-10-08 18:37:42 +00:00
|
|
|
if __name__ == "__main__":
|
2023-10-08 23:44:14 +00:00
|
|
|
rip(sys.argv[-1])
|