-
Notifications
You must be signed in to change notification settings - Fork 61
/
check_file.py
44 lines (39 loc) · 1.11 KB
/
check_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# binux<[email protected]>
import os
import time
import urllib
import logging
from sys import argv
from libs import lixian_api, tools
from pprint import pprint
#logging.getLogger().setLevel(logging.DEBUG)
tid_dic = {}
if os.path.exists("tid.dict"):
for line in open("tid.dict", "r"):
line = line.strip()
size, tid = line.split(" ", 1)
tid_dic[int(size)] = tid
if len(argv) != 2:
print "usage:", __file__, "filepath"
exit()
cid = tools.cid_hash_file(argv[1])
gcid = tools.gcid_hash_file(argv[1])
size = os.path.getsize(argv[1])
fid = tools.gen_fid(cid, size, gcid)
fake_url = "http://sendfile.vip.xunlei.com/download?fid=%s&mid=666&threshold=150&tid=%s" % (fid, tid_dic.get(size, 0))
print "cid: %s" % cid
print "gcid: %s" % gcid
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...",
ret = lx.webfilemail_url_analysis(fake_url)
if ret['result'] != 0:
print "no"
exit()
else:
print "yes!"