Skip to content

Commit

Permalink
添加BT任务去重
Browse files Browse the repository at this point in the history
  • Loading branch information
chliny committed Oct 5, 2013
1 parent 98fdc2b commit c631e35
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions xfdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]==_('未登录!'):
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c631e35

Please # to comment.