diff --git a/xfdown.py b/xfdown.py index 41a8156..e1cc35a 100755 --- a/xfdown.py +++ b/xfdown.py @@ -14,7 +14,7 @@ import random,time import json,os,sys,re,hashlib import getopt -from poster.streaminghttp import register_openers +#from poster.streaminghttp import register_openers def _(string): try: @@ -114,8 +114,9 @@ def start(self): except: pass - opener = register_openers() - opener.add_handler(request.HTTPCookieProcessor(self.cookieJar)) + opener = request.build_opener(request.HTTPCookieProcessor(self.cookieJar)) + #opener = register_openers() + #opener.add_handler(request.HTTPCookieProcessor(self.cookieJar)) opener.addheaders = [('User-Agent', 'Mozilla/5.0'),("Referer","http://lixian.qq.com/main.html")] request.install_opener(opener) @@ -355,11 +356,15 @@ def __pushtor(self,url): """ 上传torrent文件信息及添加BT任务 """ - from poster.encode import multipart_encode - - data1,header1 = multipart_encode({"myfile":open(url)}) - ireq = request.Request("http://lixian.qq.com/handler/bt_handler.php?cmd=readinfo",data1,header1) - torinfo = self.__request(ireq).encode("utf8").strip() + #from poster.encode import multipart_encode + import requests + + urlv1 = "http://lixian.qq.com/handler/bt_handler.php?cmd=readinfo" + #data1,header1 = multipart_encode({"myfile":open(url)}) + #ireq = request.Request("http://lixian.qq.com/handler/bt_handler.php?cmd=readinfo",data1,header1) + ireq = requests.post(urlv1,files={"myfile":open(url)}) + #torinfo = self.__request(ireq.text).encode("utf8").strip() + torinfo = ireq.text.encode("utf8").strip() torinfo = "{" + "{".join(torinfo.split("{")[1:]) torinfo = json.JSONDecoder().decode(torinfo) @@ -373,8 +378,8 @@ def __pushtor(self,url): for fileentry in torinfo["files"]: try: totalsize += fileentry["file_size_ori"] - except: - print ("torrent error!") + except Exception as e: + print ("torrent error!",e) return False aversize = totalsize / len(torinfo["files"])