Skip to content

Commit

Permalink
try for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
chliny committed Oct 5, 2013
1 parent e6c81db commit 98fdc2b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions xfdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import random,time
import json,os,sys,re,hashlib
import getopt
#from poster.streaminghttp import register_openers

def _(string):
try:
Expand Down Expand Up @@ -115,8 +114,6 @@ def start(self):
pass

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)

Expand Down Expand Up @@ -356,18 +353,19 @@ def __pushtor(self,url):
"""
上传torrent文件信息及添加BT任务
"""
#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,"rb")})
#torinfo = self.__request(ireq.text).encode("utf8").strip()
try:
ireq = requests.post(urlv1,files={"myfile":open(url,'r')})
except:
ireq = requests.post(urlv1,files={"myfile":open(url,'rb')})

torinfo = ireq.text
torinfo = "{" + "{".join(torinfo.split("{")[1:])

torinfo = json.JSONDecoder().decode(torinfo)
print (torinfo)

bthash = str(torinfo["hash"]).upper()
btfilenames = []
Expand Down

0 comments on commit 98fdc2b

Please # to comment.