Chris Pomeroy
2018-03-08 f75a70bc8fddc8b0aa94957eaa2b28a4e6d2cdea
Changed print from statement to function, changed getaaxkey to hand off generation of keys to faas
2 files modified
35 ■■■■ changed files
aaxConvert.py 7 ●●●● patch | view | raw | blame | history
getaaxkey/getaaxkey.py 28 ●●●●● patch | view | raw | blame | history
aaxConvert.py
@@ -67,7 +67,7 @@
                                                                                           getmetadatatags('date'), getmetadatatags('genre'),
                                                                                           getmetadatatags('copyright'),outpath)
    if args.verbose:
        print command
        print(command)
        process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
        while True:
            output = process.stdout.readline()
@@ -136,12 +136,15 @@
            artist = getmetadatatags('artist')
            title = getmetadatatags('title')
            act_byte = getcorrectkey(rfile)
            if act_byte == 1:
                print("The checkkey function is unavaliable")
            ddir = "%s/%s/%s" % (path, artist, title)
            single_file_path = "%s/%s.mp3" % (ddir, title)
            if not os.path.exists(ddir):
                os.makedirs(ddir)
            print ddir
            reencode(rfile, single_file_path)
            reencode(rfile, single_file_path)``
            if mode == 'chapter':
                chapter = 0
                numchapters = getchaptercount()
getaaxkey/getaaxkey.py
@@ -2,6 +2,7 @@
import os
import subprocess
import requests
def filechecksum(aaxfile):
    ret = subprocess.Popen(["ffprobe", "-v", "info", "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
@@ -17,7 +18,7 @@
        file = open(".authcode", "a")
        file.write(hashsum + os.linesep)
    except (IOError, OSError) as e:
        print "Can't write to .authcode"
        print("Can't write to .authcode")
        return 1
    finally:
        file.close()
@@ -31,7 +32,7 @@
      with open(".authcode") as f:
          hashes = f.read().split()
    except (IOError, OSError) as e:
        print "Can't read in .authcode"
        print("Can't read in .authcode")
        return 1
    finally:
        f.close()
@@ -39,17 +40,12 @@
def newauthcode(checksum):
    rcwd = os.path.dirname(os.path.realpath(__file__))
    command = "./rcrack *.rtc -h "
    command += checksum
    cmd = subprocess.Popen(command, cwd=rcwd, stdout=subprocess.PIPE, shell=True)
    grep = subprocess.Popen(["grep", "-a", "hex"], stdin=cmd.stdout, stdout=subprocess.PIPE)
    key, stderr = grep.communicate()
    key = key.split()
    for x in key:
        if "hex" in x:
            return x.split(':')[1]
    r = requests.post("http://x86-docker01.darkurthe.net:8080/function/checkkey", checksum )
    if r.status_code == 200:
        response = str(r.text)
        return response.strip()
    else:
        return 1
def checkagainstexisting(abytes,aaxfile):
    ret = subprocess.Popen(["ffprobe", "-activation_bytes", abytes, "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
@@ -77,11 +73,11 @@
    if len(sys.argv) >= 2:
        args = sys.argv[1]
    else:
        print "I need an file name to lookup"
        print("I need an file name to lookup")
        sys.exit(1)
    checksum = filechecksum(args)
    out = newauthcode(checksum.strip())
    if out is not None:
        print sys.argv[1], "Auth code is:", out
        print(sys.argv[1], "Auth code is:", out)
    else:
        print sys.argv[1], "no Authcode found"
        print(sys.argv[1], "no Authcode found")