From 66f817d6d1fa24713b556982a0de209f3322e868 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 22 Jan 2012 12:30:16 +0100 Subject: realdebrid encoding fix --- module/plugins/hoster/RealdebridCom.py | 5 +++-- module/utils/__init__.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'module') diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index ac55ea3f0..3a3ac99b0 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -5,6 +5,7 @@ import re from urllib import quote, unquote from random import randrange +from module.utils import encode from module.plugins.Hoster import Hoster class RealdebridCom(Hoster): @@ -43,8 +44,8 @@ class RealdebridCom(Hoster): password = self.getPassword().splitlines() if not password: password = "" else: password = password[0] - - url = "http://real-debrid.com/ajax/deb.php?lang=en&sl=1&link=%s&passwort=%s" % (quote(pyfile.url, ""), password) + + url = "http://real-debrid.com/ajax/deb.php?lang=en&sl=1&link=%s&passwort=%s" % (quote(encode(pyfile.url), ""), password) page = self.load(url) error = re.search(r'(.*)', page) diff --git a/module/utils/__init__.py b/module/utils/__init__.py index bf11fbc69..592bdbd7e 100644 --- a/module/utils/__init__.py +++ b/module/utils/__init__.py @@ -19,6 +19,16 @@ def decode(string): except: return string +def encode(string): + """ decode string to utf if possible """ + try: + if type(string) == unicode: + return string.encode("utf8", "replace") + else: + return string + except: + return string + def remove_chars(string, repl): """ removes all chars in repl from string""" if type(string) == str: -- cgit v1.2.3