Added the querysubsonic into this repo. Added a check to make sure we didn't already have the aax ablum in the library. This needs refinement as if the name isn't an exact match it won't work.
1 files modified
1 files added
| | |
| | | import shlex |
| | | import json |
| | | from getaaxkey.getaaxkey import getcorrectkey |
| | | import querysubsonic |
| | | |
| | | # arguments |
| | | # activation_key, file name, codec(default to mp3) |
| | |
| | | |
| | | for rfile in glob.glob(args.filename): |
| | | if rfile.find("aax") != -1 and os.path.isfile(rfile): |
| | | act_byte = getcorrectkey(rfile) |
| | | metadata = getmetadata(rfile) |
| | | album = getmetadatatags('album') |
| | | #See if we got it already |
| | | if findalbumbyname(album): |
| | | return 0 |
| | | else: |
| | | artist = getmetadatatags('artist') |
| | | title = getmetadatatags('title') |
| | | act_byte = getcorrectkey(rfile) |
| | | ddir = "%s/%s/%s" % (path, artist, title) |
| | | single_file_path = "%s/%s.mp3" % (ddir, title) |
| | | if not os.path.exists(ddir): |
| | |
| | | movetochapters(single_file_path, ddir, schap, title, cstart,cend) |
| | | os.remove(single_file_path) |
| | | getcoverart(rfile, ddir) |
| | | updatelibrary('testuser','testpass') |
| 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" |