Skip to content

Commit

Permalink
fix iqiyi
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzy823 committed Jan 28, 2015
1 parent 0fd7de8 commit 7423555
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/you_get/extractors/iqiyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@ def getVrsEncodeCode(vlink):
return loc2[::-1]

def getVMS(tvid,vid,uid):
tm=randint(1000,2000)
vmsreq='http://cache.video.qiyi.com/vms?key=fvip&src=p'+"&tvId="+tvid+"&vid="+vid+"&vinfo=1&tm="+str(tm)+"&enc="+hashlib.new('md5',bytes('ts56gh'+str(tm)+tvid,"utf-8")).hexdigest()+"&qyid="+uid+"&tn="+str(random())
return json.loads(get_content(vmsreq))
#tm ->the flash run time for md5 usage
#um -> vip 1 normal 0
#authkey -> for password protected video ,replace '' with your password
#puid user.passportid may empty?
#TODO: support password protected video
tm=randint(100,1000)
vmsreq='http://cache.video.qiyi.com/vms?key=fvip&src=1702633101b340d8917a69cf8a4b8c7' +\
"&tvId="+tvid+"&vid="+vid+"&vinfo=1&tm="+str(tm)+\
"&enc="+hashlib.new('md5',bytes('ts56gh'+str(tm)+tvid,"utf-8")).hexdigest()+\
"&qyid="+uid+"&tn="+str(random()) +"&um=0" +\
"&authkey="+hashlib.new('md5',bytes(''+str(tm)+tvid,'utf-8')).hexdigest()
tmp = get_content(vmsreq)
return json.loads(tmp)

def getDispathKey(rid):
tp=")(*&^flash@#$%a" #magic from swf
Expand All @@ -67,9 +77,15 @@ def iqiyi_download(url, output_dir = '.', merge = True, info_only = False):
assert videoid

info = getVMS(tvid,videoid,gen_uid)
assert info["code"] == "A000000"

title = info["data"]["vi"]["vn"]

# data.vp = json.data.vp
# data.vi = json.data.vi
# data.f4v = json.data.f4v
# if movieIsMember data.vp = json.data.np

#for highest qualities
#for http://www.iqiyi.com/v_19rrmmz5yw.html not vp -> np
try:
Expand All @@ -79,28 +95,24 @@ def iqiyi_download(url, output_dir = '.', merge = True, info_only = False):
log.e("[Error] Do not support for iQIYI VIP video.")
exit(-1)

# assert info["data"]['vp']["tkl"]!=''
bid=0
for i in info["data"]["vp"]["tkl"][0]["vs"]:
if int(i["bid"])<=10 and int(i["bid"])>=bid:
bid=int(i["bid"])
video_links=i["fs"]
#todo support choose quality with cmdline
video_links=i["flvs"] #now in i["flvs"] not in i["fs"]

urls=[]
size=0
for i in video_links:
vlink=i["l"]
# print(vlink)
if not vlink.startswith("/"):
#vlink is encode
vlink=getVrsEncodeCode(vlink)
assert vlink.endswith(".f4v")
size+=i["b"]
key=getDispathKey(vlink.split("/")[-1].split(".")[0])
size+=i["b"]
baseurl=info["data"]["vp"]["du"].split("/")
baseurl.insert(-1,key)
url="/".join(baseurl)+vlink+'?su='+gen_uid+'&client=&z=&bt=&ct=&tn='+str(randint(10000,20000))
url="/".join(baseurl)+vlink+'?su='+gen_uid+'&qyid='+uuid4().hex+'&client=&z=&bt=&ct=&tn='+str(randint(10000,20000))
urls.append(json.loads(get_content(url))["l"])

#download should be complete in 10 minutes
Expand Down

0 comments on commit 7423555

Please sign in to comment.