diff --git a/core/downloadtools.py b/core/downloadtools.py index 05d4754f..628b9bcb 100644 --- a/core/downloadtools.py +++ b/core/downloadtools.py @@ -110,6 +110,8 @@ def limpia_nombre_excepto_1(s): stripped = ''.join(c for c in s if c in validchars) # Convierte a iso s = stripped.encode("iso-8859-1") + if PY3: + s = s.decode('utf-8') return s @@ -169,7 +171,10 @@ def downloadbest(video_urls, title, continuar=False): for elemento in invertida: # videotitle = elemento[0] url = elemento[1] - logger.info("Downloading option " + title + " " + url.encode('ascii', 'ignore')) + if not PY3: + logger.info("Downloading option " + title + " " + url.encode('ascii', 'ignore')) + else: + logger.info("Downloading option " + title + " " + url.encode('ascii', 'ignore').decode('utf-8')) # Calcula el fichero donde debe grabar try: diff --git a/platformcode/unify.py b/platformcode/unify.py index 92ceda10..07302888 100644 --- a/platformcode/unify.py +++ b/platformcode/unify.py @@ -567,10 +567,12 @@ def title_format(item): title = '[B][COLOR limegreen][%s][/COLOR][/B] %s' % (check, item.title.decode('utf-8')) item.title = title.encode('utf-8') + if PY3: item.title = item.title.decode('utf-8') except: check = 'v' title = '[B][COLOR limegreen][%s][/COLOR][/B] %s' % (check, item.title.decode('utf-8')) item.title = title.encode('utf-8') + if PY3: item.title = item.title.decode('utf-8') return item diff --git a/platformcode/updater.py b/platformcode/updater.py index c389b315..7d84db1d 100644 --- a/platformcode/updater.py +++ b/platformcode/updater.py @@ -112,7 +112,7 @@ def check(background=False): if 'patch' in file: text = "" try: - localFile = open(addonDir + file["filename"], 'r+') + localFile = io.open(addonDir + file["filename"], 'r+', encoding="utf8") text = localFile.read() except IOError: # nuovo file # crea le cartelle se non esistono @@ -120,7 +120,7 @@ def check(background=False): if not os.path.exists(dirname): os.makedirs(dirname) - localFile = open(addonDir + file["filename"], 'w') + localFile = io.open(addonDir + file["filename"], 'w', encoding="utf8") patched = apply_patch(text, (file['patch']+'\n').encode('utf-8')) if patched != text: # non eseguo se giĆ  applicata (es. scaricato zip da github) @@ -250,7 +250,7 @@ def apply_patch(s,patch,revert=False): def getSha(path): try: - f = open(path, 'rb') + f = io.open(path, 'rb', encoding="utf8") except: return '' size = len(f.read()) @@ -417,7 +417,7 @@ def fOpen(file, mode = 'r'): logger.info('android, uso FileIO per leggere') return io.FileIO(file, mode) else: - return open(file, mode) + return io.open(file, mode) def _pbhook(numblocks, blocksize, filesize, url, dp): diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 892c1eb6..de06903c 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -917,8 +917,13 @@ def add_sources(path): nodo_video.appendChild(nodo_source) # Guardamos los cambios - filetools.write(SOURCES_PATH, - '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()])) + if not PY3: + filetools.write(SOURCES_PATH, + '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()])) + else: + filetools.write(SOURCES_PATH, + b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), + vfs=False) def ask_set_content(flag, silent=False):