开眼视频的地址解析下载
2017-03-27 本文已影响1965人
Maslino
以开眼APP视频播放页面的分享地址 http://www.eyepetizer.net/detail.html?vid=18376 为例,说明如何得到视频的真实地址。
获取视频VID
视频VID可以从分享地址中的参数vid得来。
请求接口
用PC端浏览器打开上述分享地址,观察网络请求,可以找到API请求:http://baobab.kaiyanapp.com/api/v1/video/18376
请求该API返回的JSON数据如下:
{
"dataType": "VideoBeanForClientV1",
"id": 18376,
"title": "换个角度看充满魔性的深圳时装周",
"description": "换个角度看充满魔性的深圳时装周~啊啊啊简直停不下来!徐老师带你看一场另类深圳时装周",
"provider": {
"name": "PGC",
"alias": "PGC",
"icon": ""
},
"category": "时尚",
"author": {
"id": 418,
"icon": "http://img.kaiyanapp.com/0b27dac47841e5a84c172edd7aceb5a6.jpeg?imageMogr2/quality/60/format/jpg",
"name": "Peter XU Studio",
"description": "时尚达人徐峰立老师的团队,骨灰级国内外秀场报道,直击四大时装周最前沿。",
"link": "",
"latestReleaseTime": 1490584957000,
"videoNum": 7,
"adTrack": null,
"follow": {
"itemType": "author",
"itemId": 418,
"followed": false
}
},
"playUrl": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=default&source=ucloud",
"duration": 141,
"releaseTime": 1490533365000,
"playInfo": [
{
"height": 480,
"width": 854,
"urlList": [
{
"name": "ucloud",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=normal&source=ucloud"
},
{
"name": "qcloud",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=normal&source=qcloud"
}
],
"name": "标清",
"type": "normal",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=normal&source=ucloud"
},
{
"height": 720,
"width": 1280,
"urlList": [
{
"name": "ucloud",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=high&source=ucloud"
},
{
"name": "qcloud",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=high&source=qcloud"
}
],
"name": "高清",
"type": "high",
"url": "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=high&source=ucloud"
}
],
"consumption": {
"collectionCount": 22,
"shareCount": 15,
"replyCount": 0
},
"campaign": null,
"waterMarks": null,
"adTrack": null,
"tags": [],
"type": "NORMAL",
"subtitles": [],
"titlePgc": "换个角度看充满魔性的深圳时装周",
"descriptionPgc": "换个角度看充满魔性的深圳时装周~啊啊啊简直停不下来!徐老师带你看一场另类深圳时装周",
"remark": "",
"idx": 0,
"shareAdTrack": null,
"favoriteAdTrack": null,
"webAdTrack": null,
"date": 1490533365000,
"promotion": null,
"label": null,
"descriptionEditor": "",
"collected": false,
"played": false,
"coverForFeed": "http://img.kaiyanapp.com/dc76f4792449519504649e57e03fbc29.png?imageMogr2/quality/60/format/jpg",
"coverForDetail": "http://img.kaiyanapp.com/dc76f4792449519504649e57e03fbc29.png?imageMogr2/quality/60/format/jpg",
"coverBlurred": "http://img.kaiyanapp.com/1a3f3d4f08a5c8370cc51a52a3849f32.jpeg?imageMogr2/quality/60/format/jpg",
"coverForSharing": null,
"webUrlForWeibo": "http://wandou.im/3ml0vk",
"rawWebUrl": "http://www.eyepetizer.net/detail.html?vid=18376"
}
playInfo中列出了标清和高清码流的地址,分别有两种地址,一个是使用UCloud,另一个是使用QCloud(腾讯云)。实际上,开眼的标清、高清码流的分辨率分别对应的是各大在线视频网站的高清、超清码流。
Python代码示例
import re
import requests
url = 'http://www.eyepetizer.net/detail.html?vid=18376'
vid = re.search('vid=(\d+)', url).group(1)
api_url = 'http://baobab.kaiyanapp.com/api/v1/video/%s' % vid
r = requests.get(api_url)
for info in r.json()['playInfo']:
print info['name'], ': ', info['url']
执行上面的代码,输出结果如下:
标清 : http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=normal&source=ucloud
高清 : http://baobab.kaiyanapp.com/api/v1/playUrl?vid=18376&editionType=high&source=ucloud