|
|
@ -42,11 +42,32 @@ def decrypt_aax_file(aax_path: str, profile:str):
|
|
|
|
|
|
|
|
|
|
|
|
except subprocess.CalledProcessError as err:
|
|
|
|
except subprocess.CalledProcessError as err:
|
|
|
|
logging.info(f"Fehler bei Prozess ausfuehrung. {err}")
|
|
|
|
logging.info(f"Fehler bei Prozess ausfuehrung. {err}")
|
|
|
|
#HowTo-WiemanshinkriegtAbsurdewirklichwissenschaftlicheEmpfehlungenfralleLebenslagen_ep7.aax 2>&1 | grep checksum
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def convert_to_m4b(aax_path:str, profile:str):
|
|
|
|
def convert_to_m4b(aax_path:str, profile:str):
|
|
|
|
logging.info("Ich converteeee...")
|
|
|
|
logging.info("Ich converteeee...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
#Laden des Profils
|
|
|
|
|
|
|
|
profiles = None
|
|
|
|
|
|
|
|
with open('profiles.yml', 'r') as profile_yaml:
|
|
|
|
|
|
|
|
profiles = yaml.safe_load(profile_yaml)
|
|
|
|
|
|
|
|
profile_id = profiles.get(profile)
|
|
|
|
|
|
|
|
logging.info(f'Loaded Profile: {profile}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aax_name = aax_path.split('/')[1] # Fuer vollen Datei-Name
|
|
|
|
|
|
|
|
aax_name = aax_name.split('.')[0] # Fuer Datei-Namen ohne Endung
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Konvertierung der aax Datei zu m4b
|
|
|
|
|
|
|
|
cmd_ffmpeg = f"ffmpeg -activation_bytes {profile_id} -i {aax_path} -c copy m4b_outputs/{aax_name}.m4b"
|
|
|
|
|
|
|
|
result_ffmpeg = subprocess.run(cmd_ffmpeg, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
|
|
|
|
|
|
logging.info(f"Konvertierung abgeschlossen. m4b_outputs/{aax_name}.m4b erstellt.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except subprocess.CalledProcessError as err:
|
|
|
|
|
|
|
|
logging.info(f"Fehler bei Prozess ausfuehrung. {err}")
|
|
|
|
|
|
|
|
# ffmpeg -activation_bytes fc07e32c -i aax_inputs/HowTo-WiemanshinkriegtAbsurdewirklichwissenschaftlicheEmpfehlungenfralleLebenslagen_ep7.aax -c copy output.m4b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
argparser = argparse.ArgumentParser(description="Dieses Script konvertiert verschluesselte Audible Buecher zu unverschluesselte m4b-Audiobooks.")
|
|
|
|
argparser = argparse.ArgumentParser(description="Dieses Script konvertiert verschluesselte Audible Buecher zu unverschluesselte m4b-Audiobooks.")
|
|
|
@ -58,7 +79,10 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
convert_parser = cmd_parser.add_parser('convert', help="Konvertiert ein aax-Audiobook in ein m4b-Audiobook.")
|
|
|
|
convert_parser = cmd_parser.add_parser('convert', help="Konvertiert ein aax-Audiobook in ein m4b-Audiobook.")
|
|
|
|
convert_parser.add_argument('aax', type=path_to_aax, help='Path zu einem zu entschluesselnden aax file')
|
|
|
|
convert_parser.add_argument('aax', type=path_to_aax, help='Path zu einem zu entschluesselnden aax file')
|
|
|
|
convert_parser.add_argument('profile', type=str, help="Zugehoeriges Profile fuer entschluesselung")
|
|
|
|
convert_parser.add_argument('profile', type=str, help="Zugehoeriges Profile fuer Entschluesselung")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convert_all_parser = cmd_parser.add_parser('convert-all', help="Konvertiert alle aax-Audiobooks in m4b-Audiobooks.")
|
|
|
|
|
|
|
|
convert_all_parser.add_argument('profile', type=str, help="Zugehoeriges Profile fuer Entschluesselung")
|
|
|
|
|
|
|
|
|
|
|
|
args: argparse.Namespace = argparser.parse_args(args=None if sys.argv[1:] else ['--help'])
|
|
|
|
args: argparse.Namespace = argparser.parse_args(args=None if sys.argv[1:] else ['--help'])
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +107,8 @@ if __name__ == "__main__":
|
|
|
|
decrypt_aax_file(aax_file, profile)
|
|
|
|
decrypt_aax_file(aax_file, profile)
|
|
|
|
|
|
|
|
|
|
|
|
elif args.cmd == "convert":
|
|
|
|
elif args.cmd == "convert":
|
|
|
|
if profiles is None or profiles.get(args.profiles) is None or args.profiles not in profiles:
|
|
|
|
|
|
|
|
|
|
|
|
if profiles is None or profiles.get(args.profile) is None or args.profile not in profiles:
|
|
|
|
logging.info(f"Profil {args.profile} existiert nicht. Bitte ueber decrypt anlegen lassen.")
|
|
|
|
logging.info(f"Profil {args.profile} existiert nicht. Bitte ueber decrypt anlegen lassen.")
|
|
|
|
sys.exit()
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
@ -93,6 +118,10 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
convert_to_m4b(aax_file, profile)
|
|
|
|
convert_to_m4b(aax_file, profile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif args.cmd == "convert-all":
|
|
|
|
|
|
|
|
logging.info(f"Convert wird fuer alle aax im Input-Ordner durchgefuehrt")
|
|
|
|
|
|
|
|
#TODO Implement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|