Permalink
Browse files

add some tools

  • Loading branch information...
1 parent d214e3c commit 59e4a056cb63bfa0a928e7626c51c9057028e174 Binux committed Mar 22, 2012
Showing with 155 additions and 5 deletions.
  1. +25 −3 DOCUMENT
  2. +16 −2 libs/lixian_api.py
  3. +27 −0 libs/tools.py
  4. +53 −0 upload_local_file.py
  5. +34 −0 vip_checker.py
View
@@ -150,10 +150,10 @@ _update_torrent output example:
http://gdl.lixian.vip.xunlei.com/download?
-fid=3KUoDlBy9IotAFn5vQAHc5VUIgKiwSgmAAAAAHYA3duVUUeWgaJI4JGu5syK9PLK& // unknow base64: 384bit
+fid=3KUoDlBy9IotAFn5vQAHc5VUIgKiwSgmAAAAAHYA3duVUUeWgaJI4JGu5syK9PLK& // base64: 与cid,size,gcid相关(size为小字节序)
mid=666& // maybe: always 666
threshold=150& // maybe: always 150
-tid=A950BAE38A2E7398186D4127315DB76F // unknow: 256bit
+tid=A950BAE38A2E7398186D4127315DB76F // unknow: 256bit
srcid=4 // maybe: always 4
verno=1 // maybe: always 1
g=7600DDDB9551479681A248E091AEE6CC8AF4F2CA& // gcid: for normal download gcid == cid
@@ -166,7 +166,6 @@ s=640205218& //totalByte
m=0& // mayby: always 0
n=01324486025B4775690D459D7F43726F770F6CBF6F345D5B46347DA817445D5B422876D1025B783236556EA51C335D2E6D0A47E45F00000000 // filename
-
============= fid ===============
Mqf8+nvtpUHjObcqRhUZ48+pSyC6g5YAAAAAAOdP2L6oBqlz78rSDdJeSmAW8DrW
32 a7 fc fa 7b ed a5 41 e3 39 b7 2a 46 15 19 e3 cf a9 4b 20 ba 83 96 00 00 00 00 00 e7 4f d8 be a8 06 a9 73 ef ca d2 0d d2 5e 4a 60 16 f0 3a d6
@@ -182,6 +181,9 @@ bmoVFKr2E5DUB/xlGj60zFPsPf9cJAEAAAAAAGfBDu9xfQjqU63CLmXZk6fyCTmX
Mqf8+nvtpUHjObcqRhUZ48+pSyC6g5YAAAAAAOdP2L6oBqlz78rSDdJeSmAW8DrW
32 a7 fc fa 7b ed a5 41 e3 39 b7 2a 46 15 19 e3 cf a9 4b 20 ba 83 96 00 00 00 00 00 e7 4f d8 be a8 06 a9 73 ef ca d2 0d d2 5e 4a 60 16 f0 3a d6
+http://dl.t.sendfile.vip.xunlei.com/test?fid=epoLAiRpf4hqvFk5ium5hS8fgTsehjEKAAAAAlzaZ1T12vLWThMDYUyHPDn6qZou&mid=666&threshold=150&tid=526963723467ACE9C0173EDEA26859F8
+http://dl.t.sendfile.vip.xunlei.com/test?fid=epoLAiRpf4hqvFk5ium5hS8fgTsehjEKAAAAAIzaZ1T12vLWThMDYUyHPDn6qZou&mid=666&threshold=150&tid=526963723467ACE9C0173EDEA26859F8
+
===== tid =======
7A F5 61 B4 B1 6D 7B C2 6C 85 79 38 D4 F1 29 BC
8525F6A2DE09DA10B986CF95B41C6355
@@ -428,3 +430,23 @@ get_process 有session验证,并且对于不允许的格式都返回5_10000,
ed2k://|file|[%E9%81%93%E5%85%B0][NHK%E7%BA%AA%E5%BD%95%E7%89%87]%E9%9D%9E%E6%B4%B2%E6%A2%A6%EF%BC%882%EF%BC%89%EF%BC%9A%E5%A4%A7%E5%9C%B0%E4%B9%8B%E5%8A%9B%E4%B8%BA%E6%88%91%E6%89%80%E7%94%A8.mp4|932511064|284B94C0EE49DA0E3A84F28B8161EA7B|h=EWOXPIPIUW5NDOBJSCVGDPLAZQ777WGL|/
在云点播中已经完成转码,可以播放,但是在离线空间内依旧无法秒传。
+kuai直接建立离线任务api
+http://sendfile.vip.xunlei.com/filename?fid=epoLAiRpf4hqvFk5ium5hS8fgTsehjEKAAAAAIzaZ1T12vLWThMDYUyHPDn6qZou&threshold=150&tid=526963723467ACE9C0173EDEA26859F8
+
+fid = epoLAiRpf4hqvFk5ium5hS8fgTsehjEKAAAAAIzaZ1T12vLWThMDYUyHPDn6qZou
+cid 01111010 10011010 00001011 00000010 00100100 01101001 01111111 10001000 01101010 10111100 01011001 00111001 10001010 11101001 10111001 10000101
+ 00101111 00011111 10000001 00111011
+size 00011110 10000110 00110001 00001010 00000000 00000000 00000000 00000000 小字节序
+gcid 10001100 11011010 01100111 01010100 11110101 11011010 11110010 11010110 01001110 00010011 00000011 01100001 01001100 10000111 00111100 00111001
+ 11111010 10101001 10011010 00101110
+cid = 7A9A0B0224697F886ABC59398AE9B9852F1F813B
+ 01111010 10011010 00001011 00000010 00100100 01101001 01111111 10001000 01101010 10111100 01011001 00111001 10001010 11101001 10111001 10000101
+ 00101111 00011111 10000001 00111011
+gcid = 8CDA6754F5DAF2D64E1303614C873C39FAA99A2E
+ 10001100 11011010 01100111 01010100 11110101 11011010 11110010 11010110 01001110 00010011 00000011 01100001 01001100 10000111 00111100 00111001
+ 11111010 10101001 10011010 00101110
+size = 171017758
+
+tid = 526963723467ACE9C0173EDEA26859F8
+01010010 01101001 01100011 01110010 00110100 01100111 10101100 11101001 11000000 00010111 00111110 11011110 10100010 01101000 0101001 11111000
+
View
@@ -708,8 +708,22 @@ def vod_check_vip(self):
def vod_get_bt_list(self, cid):
pass
- def vod_get_list_pic(self, gcid):
- pass
+ VOD_GET_LIST_PIC = "http://dynamic.vod.lixian.xunlei.com/interface/get_list_pic"
+ def vod_get_list_pic(self, gcids):
+ params = {
+ "callback": "jsonp1234567890",
+ "t": self._now,
+ "ids": "", # urlhash
+ "gcid": ",".join(gcids),
+ "rate": 0
+ }
+ r = self.session.get(self.VOD_GET_LIST_PIC, 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]
VOD_GET_BT_PIC = "http://dynamic.vod.lixian.xunlei.com/interface/get_bt_pic"
def vod_get_bt_pic(self, cid, bindex=[]):
View
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+# binux<17175297.hk@gmail.com>
+
+import os
+import struct
+import hashlib
+
+def parse_fid(fid):
+ cid, size, gcid = struct.unpack("<20sq20s", fid.decode("base64"))
+ 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()
+
+def dcid_hash_file(path):
+ h = hashlib.sha1()
+ size = os.path.getsize(path)
+ with open(path, 'rb') as stream:
+ if size < 0xF000:
+ h.update(stream.read())
+ else:
+ h.update(stream.read(0x5000))
+ stream.seek(size/3)
+ h.update(stream.read(0x5000))
+ stream.seek(size-0x5000)
+ h.update(stream.read(0x5000))
+ return h.hexdigest().upper()
View
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+# binux<17175297.hk@gmail.com>
+
+import os
+import time
+import logging
+from sys import argv
+from libs import lixian_api, tools
+from pprint import pprint
+
+#logging.getLogger().setLevel(logging.DEBUG)
+
+if len(argv) != 4:
+ print "usage: upload_local_file.py username passwd filepath"
+ exit()
+
+lx = lixian_api.LiXianAPI()
+print "login...",
+if lx.login(argv[1], argv[2]):
+ print "ok"
+else:
+ print "error"
+ exit()
+lx.task_check("http://www.baidu.com/")
+gcid = tools.dcid_hash_file(argv[3])
+print "cid: %s" % gcid
+size = os.path.getsize(argv[3])
+fid = tools.gen_fid(gcid, size, gcid)
+#print "fid: %s" % fid
+#print "checking file exist...",
+#ret = lx.webfilemail_url_analysis("http://sendfile.vip.xunlei.com/filename?tid=0&fid=%s" % fid)
+#if ret['result'] != 0:
+ #print "no"
+#else:
+ #print "yes!"
+print "adding task to lixian..."
+lx.add_task_with_dict("http://www.baidu.com/", {
+ "cid": gcid,
+ "gcid": "",
+ "size": size,
+ "title": os.path.split(argv[3]),
+ })
+print "wating for 3 seconds..."
+time.sleep(3)
+print "fetch tasks..."
+for task in lx.get_task_list(pagenum=100):
+ if task['cid'] == gcid:
+ if "lixian_url" in task and task['lixian_url']:
+ print task['lixian_url']
+ else:
+ print "this file may not exist on lixian.xunlei.com"
+ break
View
@@ -0,0 +1,34 @@
+# -*- encoding: utf-8 -*-
+# author: binux<17175297.hk@gmail.com>
+
+from sys import argv
+from libs.lixian_api import LiXianAPI
+
+if len(argv) != 3:
+ print "usage: vip_check.py user_list test_task"
+
+fp = open(argv[1], "r")
+for line in fp:
+ line = line.strip()
+ username, password = line.split()
+ xunlei = LiXianAPI()
+ if not xunlei.login(username, password):
+ print username, "login error"
+ #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"
+ tid = 0
+ for task in tasks:
+ if task['task_type'] == 'normal':
+ if not tid and task['lixian_url']:
+ #tid = task['task_id']
+ pass
+ elif task['task_type'] in ['bt', 'magenet']:
+ for file in xunlei.get_bt_list(task['task_id'], task['cid']):
+ if not tid and file['lixian_url']:
+ tid = file['task_id']
+ print "%s:%s:%s" % (xunlei.uid, xunlei.gdriveid, tid)

0 comments on commit 59e4a05

Please sign in to comment.