Fixed errant hex key generation. Added for loop to just grab the correct info not specific array parts.
2 files modified
1 files added
| | |
| | | import shlex |
| | | import json |
| | | from getaaxkey.getaaxkey import getcorrectkey |
| | | import querysubsonic |
| | | from querysubsonic import findalbumbyname |
| | | |
| | | # arguments |
| | | # activation_key, file name, codec(default to mp3) |
| | |
| | | metadata = getmetadata(rfile) |
| | | album = getmetadatatags('album') |
| | | #See if we got it already |
| | | if findalbumbyname(album): |
| | | return 0 |
| | | else: |
| | | if (findalbumbyname(album) == False): |
| | | artist = getmetadatatags('artist') |
| | | title = getmetadatatags('title') |
| | | act_byte = getcorrectkey(rfile) |
| | |
| | | grep = subprocess.Popen(["grep","-a", "hex"], stdin=cmd.stdout,stdout=subprocess.PIPE) |
| | | key,stderr = grep.communicate() |
| | | key = key.split() |
| | | return key[2].split(':')[1] |
| | | for x in key: |
| | | if "hex" in x: |
| | | return x.split(':')[1] |
| | | |
| | | |
| | | def checkagainstexisting(abytes,aaxfile): |
| | | ret = subprocess.Popen(["ffprobe","-activation_bytes", abytes ,"-hide_banner" , os.path.abspath(aaxfile)], stderr=subprocess.PIPE) |
| | |
| | | authcodes = readauthcode() |
| | | abyte = '' |
| | | for x in authcodes: |
| | | if (checkagainstexisting(x,aaxfile) == '0'): |
| | | if checkagainstexisting(x, aaxfile) == '0': |
| | | abyte = x |
| | | return abyte |
| | | if (abyte == ''): |
| | | if abyte == '': |
| | | csum = filechecksum(aaxfile) |
| | | abyte = newauthcode(csum) |
| | | writeauthcode(abyte) |
| New file |
| | |
| | | #!/usr/bin/python |
| | | |
| | | ## Eaxmple url |
| | | ## https://subsonic.darkurthe.net/audiobooks/rest/getMusicFolders.view?u=testuser&t=0733b8e9889d7a9986d82764cee9db1c&s=O5kgRb6X5jFFbPSW&v=1.15.0&c=myapp&f=json |
| | | ## https://subsonic.darkurthe.net/audiobooks/rest/search3.view?u=testuser&t=0733b8e9889d7a9986d82764cee9db1c&s=O5kgRb6X5jFFbPSW&c=myapp&f=json&v=1.15.0&query=album="Gypsy Morph" |
| | | |
| | | from hashlib import md5 |
| | | import random |
| | | import requests |
| | | |
| | | |
| | | def gensalt(): |
| | | ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| | | chars = [] |
| | | salt = "" |
| | | for i in range(16): |
| | | chars.append(random.choice(ALPHABET)) |
| | | salt = ''.join(str(x) for x in chars ) |
| | | return salt |
| | | |
| | | |
| | | def gentoken(passwd,salt): |
| | | m = md5() |
| | | m.update(passwd + salt) |
| | | return m.hexdigest() |
| | | |
| | | |
| | | def getalbumlist(user,passwd): |
| | | s = gensalt() |
| | | t = gentoken(passwd,s) |
| | | payload = {'u': user, 't': t, 's': s, 'c': 'audible', 'v': '1.15.0', 'f': 'json', 'type': 'alphabeticalByName', 'size': '500'} |
| | | r = requests.get('http://zombietc01.darkurthe.net:8080/audiobooks/rest/getAlbumList.view', payload, verify=False) |
| | | if r.status_code == 200: |
| | | jr = r.json() |
| | | return jr |
| | | |
| | | |
| | | def findalbumbyname(album): |
| | | album = album.strip() |
| | | alj = getalbumlist('testuser', 'testpass') |
| | | for item in alj["subsonic-response"]["albumList"]["album"]: |
| | | sablum = str(item['album']) |
| | | sablum = sablum.strip() |
| | | if sablum.lower() == album.lower(): |
| | | return True |
| | | return False |
| | | |
| | | |
| | | def updatelibrary(user,passwd): |
| | | s = gensalt() |
| | | t = gentoken(passwd,s) |
| | | payload = {'u': user, 't': t, 's': s, 'c': 'audible', 'v': '1.15.0'} |
| | | r = requests.get('http://zombietc01.darkurthe.net:8080/audiobooks/rest/startScan.view', payload, verify=False) |
| | | if r.status_code == 200: |
| | | return True |
| | | else: |
| | | return False |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | import sys |
| | | if len(sys.argv) >= 2: |
| | | args = sys.argv[1] |
| | | else: |
| | | print "I need an album name to lookup" |
| | | sys.exit(1) |
| | | out = findalbumbyname(str(sys.argv[1])) |
| | | if out == True: |
| | | print "Found: ",sys.argv[1] |
| | | else: |
| | | print sys.argv[1], "not found on subsonic server" |