From c25d74d33297ff07c6bfd6e93c6312581f7b9319 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <chris.pomeroy@hotmail.com>
Date: Sun, 18 Apr 2021 18:48:22 +0000
Subject: [PATCH] Updated the way we get the activation_key and checksum

---
 aaxConvert.py |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/aaxConvert.py b/aaxConvert.py
index a348117..84e72a6 100755
--- a/aaxConvert.py
+++ b/aaxConvert.py
@@ -44,8 +44,10 @@
 
 
 def getmetadata(aaxfile):
-    ret = subprocess.check_output(["ffprobe", "-v", "info", "-hide_banner", "-show_format", "-show_chapters", "-print_format", "json", os.path.abspath(aaxfile)])
-    mdata = json.loads(ret)
+    ret = subprocess.run(["ffprobe", "-v", "info", "-hide_banner", "-show_format", "-show_chapters", "-print_format", "json", os.path.abspath(aaxfile)], capture_output=True)
+    mdata = json.loads(ret.stdout)
+    aret = ret.stderr.decode().split('\n')[0]
+    mdata["checksum"] = aret.split()[-1]
     return mdata
 
 
@@ -133,24 +135,23 @@
     process = subprocess.call(shlex.split(command))
     return
 
-def filechecksum(aaxfile):
-#The the hex checksum from the file
-    ret = subprocess.Popen(["ffprobe", "-v", "info", "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
-    grep = subprocess.Popen(["grep", "checksum"], stdin=ret.stderr, stdout=subprocess.PIPE)
-    awk = subprocess.Popen(["awk", " { print $8 } "], stdin=grep.stdout, stdout=subprocess.PIPE)
-    hashsum,out = awk.communicate()
-    hashsum = str(hashsum).strip('\n')
-    return hashsum
+# def filechecksum(aaxfile):
+# #The the hex checksum from the file
+#     ret = subprocess.Popen(["ffprobe", "-v", "info", "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
+#     grep = subprocess.Popen(["grep", "checksum"], stdin=ret.stderr, stdout=subprocess.PIPE)
+#     awk = subprocess.Popen(["awk", " { print $8 } "], stdin=grep.stdout, stdout=subprocess.PIPE)
+#     hashsum,out = awk.communicate()
+#     hashsum = hashsum.decode().strip('\n')
+#     return hashsum
 
-def getcorrectkey(aaxfile):
+def getcorrectkey():
 #request the key for the checksum
-    hex = filechecksum(aaxfile)
-    payload = hex
     try:
-        r = requests.post('http://prod-faas-gw.darkurthe.net:8080/function/checkkey', payload, verify=False, timeout=None)
+        r = requests.post('http://prod-faas-gw.darkurthe.net:8080/function/checkkey', metadata['checksum'], verify=False, timeout=None)
         return r.text
     except requests.exceptions.HTTPError as err:
         raise error
+        return None
 
 for rfile in glob.glob(args.filename):
     if rfile.find("aax") != -1 and os.path.isfile(rfile):

--
Gitblit v1.10.0