Skip to content

Commit

Permalink
fix bug & 上报添加BT热点统计
Browse files Browse the repository at this point in the history
  • Loading branch information
chliny committed Oct 4, 2013
1 parent 5fae0ad commit 8cc31a0
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions xfdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def __preprocess(self,password=None,verifycode=None,hashpasswd=None):
if sys.version_info >= (3,0):
H = self.__md5(I + bytes(verifycode[2],encoding="ISO-8859-1"))
else:
#print I+verifycode[2]
H = self.__md5(I + verifycode[2])
G = self.__md5(H + verifycode[1].upper())

Expand All @@ -115,7 +114,6 @@ def start(self):
except:
pass


opener = register_openers()
opener.add_handler(request.HTTPCookieProcessor(self.cookieJar))
opener.addheaders = [('User-Agent', 'Mozilla/5.0'),("Referer","http://lixian.qq.com/main.html")]
Expand Down Expand Up @@ -363,6 +361,7 @@ def __pushtor(self,url):
ireq = request.Request("http://lixian.qq.com/handler/bt_handler.php?cmd=readinfo",data1,header1)
torinfo = self.__request(ireq).encode("utf8").strip()
torinfo = "{" + "{".join(torinfo.split("{")[1:])

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

bthash = str(torinfo["hash"]).upper()
Expand All @@ -384,10 +383,12 @@ def __pushtor(self,url):
if fileentry["file_size_ori"] >= aversize:
defaultchose.append(str(index))

chosestr = raw_input("请选择要下载的文件,空格隔开:(默认:%s)" % " ".join(defaultchose))
chosestr = raw_input("请选择要下载的文件,空格隔开:(默认:%s,全部:a)" % " ".join(defaultchose))
realchose = chosestr.strip().split()
if realchose is None or len(realchose) == 0:
realchose = defaultchose
elif len(realchose) == 1 and realchose[0].lower() == 'a':
realchose = range(len(torinfo["files"]))

for i in realchose:
i = int(i)
Expand All @@ -405,7 +406,7 @@ def __pushtor(self,url):
btfilesize = "#".join(btsizes)
filename=self.getfilename_url(url)

data2={"cmd":"add_bt_task",
data3={"cmd":"add_bt_task",
#多个文件名以#隔开
"filename":btfilename,
#多个文件大小以#隔开
Expand All @@ -417,8 +418,12 @@ def __pushtor(self,url):
"r":random.random()
}

urlv2="http://lixian.qq.com/handler/xfjson2012.php"
self.__request(urlv2,data2)
urlv2 = """http://pinghot.qq.com/pingd?dm=lixian.qq.com.hot&url=/main.html&hottag=ISD.QQXF.XUANFENG_OFFLINE.ADD_BT_TASK&hotx=9999&hoty=9999&rand=%d""" % int(random.random()*100000)
self.__request(urlv2)

urlv3="http://lixian.qq.com/handler/xfjson2012.php"
self.__request(urlv3,data3)

return True

def __addtask(self):
Expand All @@ -428,8 +433,6 @@ def __addtask(self):
else:
url = self._addurl

uniurl = self.__toUnicode(url)
url = uniurl.encode("utf8")
if os.path.isfile(url):
self.__pushtor(url)

Expand Down Expand Up @@ -462,22 +465,6 @@ def __getmeta(self,magneturl):
sys.exit(-1)
return maghandler.get_torrent_info()

def __toUnicode(self,word):
if isinstance(word,unicode):
return word.strip()
if not isinstance(word,str):
return u""
word = word.strip()
try:
word = word.decode("utf8")
except:
try:
word = word.decode("GBK")
except:
word = word.decode("latin")

return word

def __online(self):
_print("输入需要在线观看的任务序号")
num = int(raw_input())-1
Expand Down

0 comments on commit 8cc31a0

Please # to comment.