From c631e35c0f470ff9011f4ad676d24a0d358fbef8 Mon Sep 17 00:00:00 2001 From: chliny Date: Sat, 5 Oct 2013 21:56:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0BT=E4=BB=BB=E5=8A=A1=E5=8E=BB?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xfdown.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/xfdown.py b/xfdown.py index 8994b46..638befc 100755 --- a/xfdown.py +++ b/xfdown.py @@ -224,14 +224,17 @@ def __tohumansize(self,size): break return "%.1f%s"%(size,_dw) + def __getrawlist(self): + urlv = 'http://lixian.qq.com/handler/lixian/get_lixian_list.php' + res = self.__request(urlv,{}) + res = json.JSONDecoder().decode(res) + return res + def __getlist(self): """ 得到任务名与hash值 """ - urlv = 'http://lixian.qq.com/handler/lixian/get_lixian_list.php' - res = self.__request(urlv,{}) - res = json.JSONDecoder().decode(res) - + res = self.__getrawlist() if res is None or res["msg"]==_('未登录!'): loginres = json.JSONDecoder().decode(self.__getlogin()) if loginres is None or loginres["msg"]==_('未登录!'): @@ -361,11 +364,18 @@ def __pushtor(self,url): except: ireq = requests.post(urlv1,files={"myfile":open(url,'rb')}) - torinfo = ireq.text - torinfo = "{" + "{".join(torinfo.split("{")[1:]) + torinfo = "{" + "{".join(ireq.text.split("{")[1:]) torinfo = json.JSONDecoder().decode(torinfo) - print (torinfo) + + ires = self.__getrawlist() + if ires is None or ires["msg"]==_('未登录!'): + self.__Login() + ires = self.__getrawlist() + + oldfiles = [] + for fileinfo in ires["data"]: + oldfiles.append(fileinfo["file_name"]) bthash = str(torinfo["hash"]).upper() btfilenames = [] @@ -409,10 +419,16 @@ def __pushtor(self,url): return False fileentry = torinfo["files"][i] - btfilenames.append(fileentry["file_name"]) + filename = fileentry["file_name"] + if filename in oldfiles: + continue + btfilenames.append(filename) btindexs.append(str(i)) btsizes.append(str(fileentry["file_size_ori"])) + if len(btindexs)==0 or len(btfilenames)==0 or len(btsizes)==0: + return False + btindex = "#".join(btindexs) btfilename = "#".join(btfilenames) btfilesize = "#".join(btsizes)