From 7f5980f70224308a7fc41967000ade6a4ebc3631 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <cpomeroy@localhost.localdomain>
Date: Sat, 02 Dec 2017 05:21:48 +0000
Subject: [PATCH] Fixed errant hex key generation. Added for loop to just grab the correct info not specific array parts.
---
querysubsonic.py | 71 +++++++++++++++++++++++++++++++++++
getaaxkey/getaaxkey.py | 15 ++++---
aaxConvert.py | 6 +--
3 files changed, 82 insertions(+), 10 deletions(-)
diff --git a/aaxConvert.py b/aaxConvert.py
index 9afe859..9a8a721 100755
--- a/aaxConvert.py
+++ b/aaxConvert.py
@@ -6,7 +6,7 @@
import shlex
import json
from getaaxkey.getaaxkey import getcorrectkey
-import querysubsonic
+from querysubsonic import findalbumbyname
# arguments
# activation_key, file name, codec(default to mp3)
@@ -132,9 +132,7 @@
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)
diff --git a/getaaxkey/getaaxkey.py b/getaaxkey/getaaxkey.py
index a561ac9..4a5ea15 100644
--- a/getaaxkey/getaaxkey.py
+++ b/getaaxkey/getaaxkey.py
@@ -43,13 +43,16 @@
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()
+ 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)
+ ret = subprocess.Popen(["ffprobe", "-activation_bytes", abytes, "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
grep = subprocess.Popen(["grep", "mismatch", "-c"], stdin=ret.stderr, stdout=subprocess.PIPE)
works,out = grep.communicate()
return works.strip('\n')
@@ -59,10 +62,10 @@
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)
diff --git a/querysubsonic.py b/querysubsonic.py
new file mode 100644
index 0000000..5b5e0fb
--- /dev/null
+++ b/querysubsonic.py
@@ -0,0 +1,71 @@
+#!/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"
--
Gitblit v1.10.0