#!/usr/bin/python
|
import argparse
|
import os
|
import glob
|
import subprocess
|
import json
|
|
# arguments
|
# activation_key, file name, codec(default to mp3)
|
parser = argparse.ArgumentParser()
|
parser.add_argument("--code", help="Activation Code from audible to decrypt files")
|
parser.add_argument("filename", help="Filename to convert")
|
|
args = parser.parse_args()
|
|
act_byte = ""
|
if args.code:
|
act_byte = args.code
|
elif os.path.isfile('./.authcode'):
|
act_byte = open('./.authcode').readline()
|
|
if act_byte == "":
|
print "Please provide an activation code from audible. Either at the command line or the .authcode file"
|
else:
|
print act_byte
|
|
for rfile in glob.glob(args.filename):
|
if rfile.find("aax") != -1 and os.path.isfile(rfile):
|
#print os.path.abspath(rfile)
|
ret = subprocess.check_output(["ffprobe", "-v", "quiet", "-hide_banner", "-show_format", "-show_chapters", "-print_format", "json", os.path.abspath(rfile)])
|
metadata = json.load(ret)
|
print ret
|
|