From 5b93d4e7d957a2d58510a708d2f1677f6500a536 Mon Sep 17 00:00:00 2001 From: chliny Date: Sun, 27 Oct 2013 00:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBT=E6=96=87=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E6=9C=89=E4=B8=AD=E6=96=87=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=87=BA?= =?UTF-8?q?=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xfdown.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/xfdown.py b/xfdown.py index b7d610a..0563032 100755 --- a/xfdown.py +++ b/xfdown.py @@ -433,10 +433,10 @@ def __pushtor(self,myfile,filename): return False fileentry = torinfo["files"][i] - filename = fileentry["file_name"] - if filename in oldfiles: + inname = fileentry["file_name"] + if inname in oldfiles: continue - btfilenames.append(filename) + btfilenames.append(inname) btindexs.append(str(i)) btsizes.append(str(fileentry["file_size_ori"])) @@ -445,6 +445,7 @@ def __pushtor(self,myfile,filename): btindex = "#".join(btindexs) btfilename = "#".join(btfilenames) + btfilename = self.toUnicode(btfilename).encode("utf8") btfilesize = "#".join(btsizes) data3={"cmd":"add_bt_task", @@ -467,6 +468,20 @@ def __pushtor(self,myfile,filename): return True + def toUnicode(self,word): + if isinstance(word,unicode): + return word + if not isinstance(word,str): + return None + if word == None or word == "": + return word + try: + word = word.decode("utf8") + except: + word = word.decode("gbk") + + return word + def __addtask(self): if self._addurl == '': _print ("请输入下载地址:")