这个接口的好处是不需要cookies,也不需要计算某个参数,替换tvid就可以用。
至于headers中的sign参数,通常情况下和t一起出现,有效期很长,另外目前不需要sign和t也能请求。
代码示例如下
import requests
url = "http://iface2.iqiyi.com/video/3.0/v_download"
querystring = {"api":"nil","app_t":"1","app_p":"gphone","app_k":"69842642483add0a63503306d63f0443","app_v":"10.9.0","dev_ua":"Redmi","dev_os":"10","dev_hw":"null","album_id":"239229801","tv_id":"8502453100","platform_id":"10","play_core":"nil","net_sts":"16","usr_res":"512","secure_v":"1","secure_p":"GPhone","qdv":"1","api_v":"9.8","req_sn":"1571529770886"}
headers = {
'sign': "abf536b8e1203ae3f2e6c5c8dbb9b65d",
'User-Agent': "iqiyi/com.qiyi.video/10.9.0/NetLib-okhttp/3.12.5.1",
't': "529636367",
'Accept': "*/*",
'Host': "iface2.iqiyi.com",
'Accept-Encoding': "gzip, deflate"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
返回示例
{
"code": 0,
"album": {
"_blk": 0,
"_cid": 2,
"_ct": "2019-03-18 10:34:23",
"_id": 239229801,
"_img": "http://m.iqiyipic.com/image/20191010/5f/ad/a_100272782_m_601_m2_120_160.jpg",
"_pc": 2,
"_pid": 239229801,
"_t": "光荣时代",
"_tvct": 1,
"_tvs": 46,
"ctype": 0,
"fst_time": "2019-04-25",
"tv_id": 8502453100,
"cpt_l": 1,
"cpt_r": 2,
"t_pc": 1,
"_dn": "2736",
"h1_img": "http://m.iqiyipic.com/image/20191010/5f/ad/a_100272782_m_601_m2_180_236.jpg",
"boss_type": 99,
"clm": "",
"tvfcs": "张译黄志忠明暗对决",
"year": "2019",
"t": "光荣时代",
"v2_img": "http://m.iqiyipic.com/image/20191010/5f/ad/a_100272782_m_601_m2_284_160.jpg",
"logo": 1,
"logo_position": -1,
"logo_hidden": [],
"business_type": []
},
"video": {
"_id": 8502453100,
"_n": "光荣时代第13集",
"subtitle": "朝阳冒充中统",
"_od": 13,
"desc": "北平开始打击“粮老虎”,很多奸商被抓。郑朝阳从奸商的往来账目中发现了杨凤刚的驻地——平西沙子口旧矿场。郑朝阳化妆粮食商人一路做了记号到旧矿场见到杨凤刚,杨凤刚知道郑朝阳是警察。郑朝阳则冒充自己是中统骗过杨凤刚,但还是被关押起来。在关押处发现了冼怡竟然也关在这里。矿场外,包围圈完成。矿场里,杨凤刚获悉郑朝阳说谎。下令连冼怡一起处决。这时,冼登奎带着委任状来和杨凤刚谈判。城里,郑朝山从旧警察多门的口中探听到郑朝阳带人抓捕杨凤刚的情报,紧急给杨凤刚发报撤离。\n",
"_img": "http://m.iqiyipic.com/image/20191014/77/39/v_139408871_m_601_160_90.jpg",
"_dn": "2705",
"s_t": 90,
"e_t": 2530,
"ts_res": {
"16": {
"vid": "becedab20c5e7a6f4a436d039cd0b103",
"len": 368685759,
"f4v_url": "",
"m3u8_url": "",
"dolby_len": 0,
"h265_len": 0,
"audio_aac_len": 0
},
"512": {
"vid": "a509b538d47e0e59c0ac51c16863950e",
"len": 704308245,
"f4v_url": "",
"m3u8_url": "",
"dolby_len": 0,
"h265_len": 0,
"audio_aac_len": 0
},
"4": {
"vid": "bc4a5528adf8ead809255ff2b5b183ea",
"len": 121820901,
"f4v_url": "",
"m3u8_url": "",
"dolby_len": 0,
"h265_len": 0,
"audio_aac_len": 0
},
"8": {
"vid": "e633dfc4ecb17a5824a86c728ca2ed4e",
"len": 163529602,
"f4v_url": "",
"m3u8_url": "",
"dolby_len": 0,
"h265_len": 0,
"audio_aac_len": 0
},
"128": {
"vid": "79fb300726b67a3d0dcdc0afd81d45b3",
"len": 65016514,
"f4v_url": "",
"m3u8_url": "",
"dolby_len": 0,
"h265_len": 0,
"audio_aac_len": 0
}
},
"mp4_res": {
"1": {
"vid": "716a30d6ec16b88b819f991d5a83857f",
"url": "",
"len": 77340238
},
"32": {
"vid": "ff9417948c6a9d9f96e7c8778228c27d",
"url": "",
"len": 128380783
},
"2": {
"vid": "ff9417948c6a9d9f96e7c8778228c27d",
"url": "",
"len": 128380783
}
},
"video_ctype": 0,
"boss_type": 1,
"pre_img": {
"pre_img_url": "http://preimage2.iqiyipic.com/preimage/20191018/87/fe/v_139408871_m_612_m1_220_124.jpg",
"rule": "1-30",
"interval": 10
},
"ta": {
"215235805": {
"id": 215235805,
"img": "http://pic2.iqiyipic.com/image/20191010/66/09/p_2001251_m_601_m3_128_128.jpg",
"name": "黄志忠"
},
"204240905": {
"id": 204240905,
"img": "http://pic6.iqiyipic.com/image/20181229/94/97/p_1037073_m_601_m2_128_128.jpg",
"name": "李添诺"
},
"203609805": {
"id": 203609805,
"img": "http://pic6.iqiyipic.com/image/20181229/08/12/p_1030762_m_601_m4_128_128.jpg",
"name": "张译"
},
"234334505": {
"id": 234334505,
"img": "http://pic3.iqiyipic.com/image/20181228/ed/19/p_5232901_m_601_m2_128_128.jpg",
"name": "张隽溢"
},
"215381805": {
"id": 215381805,
"img": "http://pic1.iqiyipic.com/image/20181229/ed/0d/p_2013408_m_601_m3_128_128.jpg",
"name": "潘之琳"
},
"214463605": {
"id": 214463605,
"img": "http://pic7.iqiyipic.com/image/20181228/08/81/p_2008149_m_601_m6_128_128.jpg",
"name": "黄品沅"
},
"214432805": {
"id": 214432805,
"img": "http://pic4.iqiyipic.com/image/20181229/da/a2/p_2006722_m_601_m3_128_128.jpg",
"name": "王骁"
}
},
"vip_type": "0",
"pay_mark": 2,
"business_type": [],
"play_mode": 1,
"fst_time": "20191019",
"video_tail_start_point": 2530000,
"bullet_num": "300"
},
"setting": {
"dl_type": 4,
"ts": "16,4,512,8,128",
"authResult": {
"auth_success": false
}
}
}