Permalink
Browse files

add api get_vip_info, add thuner:// , update vip_checker

  • Loading branch information...
1 parent 8e3d94f commit 62225a5f5a1db976eb87c6e87eaf36973c41ff07 Binux committed Mar 26, 2012
Showing with 26 additions and 4 deletions.
  1. +1 −0 check_file.py
  2. +14 −0 libs/lixian_api.py
  3. +4 −1 libs/tools.py
  4. +7 −3 vip_checker.py
View
@@ -32,6 +32,7 @@
print "size: %s" % size
print "fid: %s" % fid
print "fake_url: %s" % fake_url
+print "thunder_url: %s" % tools.encode_thunder(fake_url)
lx = lixian_api.LiXianAPI()
print "checking file exist...",
View
@@ -793,3 +793,17 @@ def is_miaoxia(self, url, bindex=[]):
if info['result'] == 0:
return True
return False
+
+ VIP_INFO_URL = "http://dynamic.vip.xunlei.com/login/asynlogin_contr/asynProxy/"
+ def get_vip_info(self):
+ params = {
+ "cachetime": self._now,
+ "callback": "jsonp123456"
+ }
+ r = self.session.get(self.VIP_INFO_URL, params=params)
+ if r.error:
+ r.raise_for_status()
+ function, args = parser_js_function_call(r.content)
+ DEBUG(pformat(args))
+ assert args
+ return args[0]
View
@@ -10,7 +10,7 @@ def parse_fid(fid):
return cid.encode("hex").upper(), size, gcid.encode("hex").upper()
def gen_fid(cid, size, gcid):
- return struct.pack("<20sq20s", cid.decode("hex"), size, gcid.decode("hex")).encode("base64").strip()
+ return struct.pack("<20sq20s", cid.decode("hex"), size, gcid.decode("hex")).encode("base64").replace("\n", "")
def gcid_hash_file(path):
h = hashlib.sha1()
@@ -38,3 +38,6 @@ def cid_hash_file(path):
stream.seek(size-0x5000)
h.update(stream.read(0x5000))
return h.hexdigest().upper()
+
+def encode_thunder(url):
+ return "thunder://"+("AA"+url+"ZZ").encode("base64").replace("\n", "")
View
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
# author: binux<17175297.hk@gmail.com>
-from sys import argv
+from sys import argv, stderr
from libs.lixian_api import LiXianAPI
if len(argv) != 3:
@@ -13,14 +13,18 @@
username, password = line.split()
xunlei = LiXianAPI()
if not xunlei.login(username, password):
- print username, "login error"
+ print >> stderr, username, "login error"
+ continue
+ else:
+ info = xunlei.get_vip_info()
+ print >> stderr, username, "expiredate:", info.get("expiredate", "unknow"), "level:", info.get("level", "0")
#tasks = xunlei.get_task_list(10, 2)
tasks = None
if not tasks:
xunlei.add(argv[2])
tasks = xunlei.get_task_list(10, 0)
if not tasks:
- print username, "add task error"
+ print >> stderr, username, "add task error"
tid = 0
for task in tasks:
if task['task_type'] == 'normal':

0 comments on commit 62225a5

Please sign in to comment.