From 6983b92764198f3ee52f0da7b8d37c127fe21331 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <Chris Pomeroy>
Date: Fri, 08 Feb 2019 13:22:01 +0000
Subject: [PATCH] reverting the getmetadatatag

---
 aaxConvert.py |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/aaxConvert.py b/aaxConvert.py
index 5ae5d59..35156e7 100755
--- a/aaxConvert.py
+++ b/aaxConvert.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 import argparse
 import os
 import glob
@@ -6,7 +6,9 @@
 import shlex
 import json
 import requests
+import unicodedata
 from querysubsonic import findalbumbyname
+from time import sleep
 
 
 # arguments
@@ -51,6 +53,10 @@
     bit_rate = metadata['format']['bit_rate']
     return bit_rate[:2]
 
+def getmetacopyright():
+    copyright = unicodedata.normalize('NFKD', metadata['format']['tag']['copyright']).encode('ascii','ignore')
+    return copyright
+
 
 def getmetadatatags(key):
     # get specific data
@@ -66,7 +72,7 @@
                                                                                            getmetadatatags('title'), getmetadatatags('artist'),
                                                                                            getmetadatatags('album_artist'), getmetadatatags('album'),
                                                                                            getmetadatatags('date'), getmetadatatags('genre'),
-                                                                                           getmetadatatags('copyright'),outpath)
+                                                                                           getmetacopyright(),outpath)
     if args.verbose:
         print(command)
         process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
@@ -138,12 +144,17 @@
 def getcorrectkey(aaxfile):
     hex = filechecksum(aaxfile)
     payload = hex
-    r = requests.post('http://x86-docker01:8080/function/checkkey', payload, verify=False)
-    if r.status_code == 200:
-        key = r.text
-    else: 
-        print('Checkkey function is down please wait')
-    return key
+    recovery = 3
+    while recovery != 0:
+      r = requests.post('http://x86-docker01:8080/function/checkkey', payload, verify=False, timeout=None)
+      if r.status_code == 200:
+          key = r.text
+          recovery = 0
+          return key
+      else: 
+          print('Checkkey function is down please wait')
+          recovery = recovery - 1
+          sleep(5)
 
 for rfile in glob.glob(args.filename):
     if rfile.find("aax") != -1 and os.path.isfile(rfile):

--
Gitblit v1.10.0