您的位置:首页 > 数据 >
B站视频播放源地址获取及B站视频下载 全球实时
来源:CSDN 2023-02-01 15:15:19

突然之间,我们的B站视频播放失效了。之前直接使用的ibilibili,发现它的低清版本视频无法正常加载了。后来加上它的公众号,才发现,都不容易,十分感谢ibilibili站站长多年的坚持,尤其是听到他说这个站点每天受到几千人的攻击时。ibilibili站提供的高清视频下载器,下载m4s文件,最后再用ffmpeg转成mp4。 对于我们而言,视频的清晰度并不重要,我们需要播放直链,仅仅是为了播放和预览视频。下载B站视频本身并不是一个难事,所以下文我将首先介绍如何获取低清版直链,然后谈谈高清版下载如何是实现。


(资料图片仅供参考)

如果你对这方面有兴趣,可以和我们群交流学习,共同进步

之前,通过下面的文章,实现了B站视频在其他站点的快速预览和播放。大大地方便了对素材的快速选择。之前的源地址获取接口失效后,急需一种新的获取方式。

Bilibili播放-获取B站播放视频源地址的过程bilibili ,B站视频预览缩略图实现分析Bilibili,B站视频缩略图快速预览实现再分析

1.播放源获取

通过伪装移动UA请求网页,如下

curl "https://m.bilibili.com/video/av70663655.html?from=search" -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"  --compressed

得到的请求结果中,找到下面这段关键信息

window.__INITIAL_STATE__ = {"playingMedia": "","reduxAsyncConnect": {"loaded": true,"loadState": {"videoTag": {"loading": false,"loaded": true,"error": null},"videoInfo": {"loading": false,"loaded": true,"error": null}},"videoTag": [{"tag_id": 389808,"tag_name": "音乐现场","cover": "http://i0.hdslb.com/bfs/archive/e86c8d10377e534b8a1617280c8cef62ae62c30c.jpg","head_cover": "http://i0.hdslb.com/bfs/archive/3a8bc72ebc670579a0b97b68b973d8e5ed495b24.jpg","content": "收录音乐实况表演视频,和音乐来一次最本质的亲密接触","short_content": "和音乐来一次最本质的亲密接触","type": 3,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 136254,"atten": 62981},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 11687,"tag_name": "综艺","cover": "http://i0.hdslb.com/bfs/archive/e3c3689f4246c3a7c70f63ed79a786faf28a8ffe.png","head_cover": "","content": "","short_content": "","type": 3,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 976243,"atten": 181572},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 58183,"tag_name": "真人秀","cover": "","head_cover": "","content": "","short_content": "","type": 3,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 144418,"atten": 44876},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 9374,"tag_name": "HIPHOP","cover": "","head_cover": "","content": "","short_content": "","type": 3,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 98376,"atten": 67805},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 11905832,"tag_name": "Rhythm + Flow:Rapper","cover": "","head_cover": "","content": "","short_content": "","type": 1,"state": 0,"ctime": 1569454310,"count": {"view": 0,"use": 1,"atten": 1},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 21297,"tag_name": "嘻哈","cover": "","head_cover": "","content": "","short_content": "","type": 0,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 48813,"atten": 2951},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 82755,"tag_name": "饶舌","cover": "","head_cover": "","content": "","short_content": "","type": 0,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 5844,"atten": 406},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 401568,"tag_name": "NETFLIX","cover": "","head_cover": "","content": "","short_content": "","type": 0,"state": 0,"ctime": 1436866637,"count": {"view": 0,"use": 2656,"atten": 591},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}, {"tag_id": 6782056,"tag_name": "嘻哈王","cover": "","head_cover": "","content": "","short_content": "","type": 0,"state": 0,"ctime": 1522744265,"count": {"view": 0,"use": 625,"atten": 1},"is_atten": 0,"likes": 0,"hates": 0,"attribute": 0,"liked": 0,"hated": 0}],"videoInfo": {"bvid": "BV1bE411f72E","aid": 70663655,"videos": 4,"tid": 71,"tname": "综艺","copyright": 2,"pic": "http://i0.hdslb.com/bfs/archive/7675affb657fc8f2e6beb84a533d86512a8c4202.jpg","title": "【美国有嘻哈】《嘻哈星节奏|Rhythm + Flow》|英语中字|卡迪·B / T.I. / 钱斯勒|NETFLIX|持续更新","pubdate": 1570612692,"ctime": 1570612692,"desc": "Netflix\n国际巨星卡迪·B、饶舌钱斯勒、TI蒂普·哈里斯齐聚一堂,在Netflix 的首部音乐竞赛节目《嘻哈星节奏》中物色下一代亮眼嘻哈新秀。本节目邀来业界传奇人物共襄盛举,穿越数座城市,到洛杉矶、纽约、亚特兰大和芝加哥等嘻哈重镇挖掘才华洋溢的新人,并帮助这些未成名的艺术家崭露头角。","state": 0,"attribute": 2113859,"duration": "03:37:32","rights": {"bp": 0,"elec": 0,"download": 1,"movie": 0,"pay": 0,"hd5": 1,"no_reprint": 0,"autoplay": 1,"ugc_pay": 0,"is_cooperation": 0,"ugc_pay_preview": 0},"owner": {"mid": 314790542,"name": "Coun4","face": "http://i1.hdslb.com/bfs/face/912697005111fde1a42ef83f390da30fc17a69a6.jpg"},"stat": {"aid": 70663655,"view": 86398,"danmaku": 5017,"reply": 253,"favorite": 3552,"coin": 957,"share": 2245,"now_rank": 0,"his_rank": 0,"like": 1917,"dislike": 0,"evaluation": ""},"dynamic": "#嘻哈星节奏##嘻哈王##Rhythm + Flow:Rapper#\n热爱音乐,平凡的你一样可以拥有不平凡的人生。\n给你展示自我的舞台,废话不多说,It"s Showtime!\nRespect, peace & love.","cid": 122426590,"dimension": {"width": 1920,"height": 1080,"rotate": 0},"no_cache": false,"pages": [{"cid": 122426590,"page": 1,"from": "vupload","part": "EP01. 洛杉矶选秀","duration": 3465,"vid": "","weblink": "","dimension": {"width": 1920,"height": 1080,"rotate": 0}}, {"cid": 122427982,"page": 2,"from": "vupload","part": "EP02. 纽约选秀","duration": 3133,"vid": "","weblink": "","dimension": {"width": 1920,"height": 1080,"rotate": 0}}, {"cid": 122429123,"page": 3,"from": "vupload","part": "EP03. 亚特兰大选秀","duration": 3181,"vid": "","weblink": "","dimension": {"width": 1920,"height": 1080,"rotate": 0}}, {"cid": 122430489,"page": 4,"from": "vupload","part": "EP04. 芝加哥选秀","duration": 3273,"vid": "","weblink": "","dimension": {"width": 1920,"height": 1080,"rotate": 0}}],"subtitle": {"allow_submit": false,"list": [{"id": 16997718492708868,"lan": "zh-Hant","lan_doc": "中文(繁体)","is_lock": false,"subtitle_url": "http://i0.hdslb.com/bfs/subtitle/9395320795b484c45173b13ff2736355ad112dc7.json","author": {"mid": 0,"name": "","sex": "","face": "","sign": "","rank": 0,"birthday": 0}}, {"id": 16997839878488068,"lan": "en-US","lan_doc": "英语(美国)","is_lock": false,"subtitle_url": "http://i0.hdslb.com/bfs/subtitle/1ba653423487d65de099e55bd452ceace3a25919.json","author": {"mid": 0,"name": "","sex": "","face": "","sign": "","rank": 0,"birthday": 0}}, {"id": 16998625400324098,"lan": "zh-Hans","lan_doc": "中文(简体)","is_lock": false,"subtitle_url": "http://i0.hdslb.com/bfs/subtitle/d99b718d326043dc16772b8f7e534ec68fc70880.json","author": {"mid": 0,"name": "","sex": "","face": "","sign": "","rank": 0,"birthday": 0}}]},"originTitle": "【美国有嘻哈】《嘻哈星节奏|Rhythm + Flow》|英语中字|卡迪·B / T.I. / 钱斯勒|NETFLIX|持续更新","reid": 5,"toptype": "娱乐","initUrl": "//upos-hz-mirrorks3u.acgvideo.com/upgcxcode/90/65/122426590/122426590-1-6.mp4?e=ig8euxZM2rNcNbuVhwdVtWuVhwdVNEVEuCIv29hEn0l5QK==&uipk=5&nbs=1&deadline=1570938144&gen=playurl&os=ks3u&oi=3742040479&trid=06d1dfd471d34b8eb40c4cee6c79531ah&platform=html5&upsig=904b08c9cd9418a8acfd4384c8b05a30&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=0","status": "normal","initCid": 122426590,"initDuration": 3465,"initPage": 1}},"authInfo": "","listInfo": "","audioReducer": null,"audiolistReducer": null,"experiment": {"normal": "experiment","newOpenApp": 1,"videoHlv": "1"},"abserver": {"errorCode": 0,"expire": 1570931544623,"hit": {"hitGroup": "768_683_822"},"vars": [{"force": 0,"group": 768,"name": "playblock_dialog","value": 1}, {"force": 0,"group": 683,"name": "H5_download_ex","value": 0}, {"force": 0,"group": 822,"name": "copylink_abtest","value": 1}]},"videoReducer": null,"videoTag": "","rankingInfo": 0,"keywordInfo": "","pageTitle": "","partitionList": "","tagInfo": "","tagVideos": "","tagSimilar": "","userStatus": "","status": "","forbidden": false,"videoState": "init","gameMode": ""};

这其中的

"initUrl": "//upos-hz-mirrorks3u.acgvideo.com/upgcxcode/90/65/122426590/122426590-1-6.mp4?e=ig8euxZM2rNcNbuVhwdVtWuVhwdVNEVEuCIv29hEn0l5QK==&uipk=5&nbs=1&deadline=1570938144&gen=playurl&os=ks3u&oi=3742040479&trid=06d1dfd471d34b8eb40c4cee6c79531ah&platform=html5&upsig=904b08c9cd9418a8acfd4384c8b05a30&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=0"

就是一个用于播放的链接,定位到一个mp4文件。在某些浏览器中该文件是没有办法播放,是由于reffer检查,如果要将该链接引入到其他站点播放,则需要设置成 no-reffer。

2.高清下载

you-get想必很多人都熟悉了。

ucsheep@ucsheep-B250M-D2V:~$ you-get -u https://www.bilibili.com/video/av53788919?from=search&seid=18263359557066961621[1] 6330ucsheep@ucsheep-B250M-D2V:~$ site:                Bilibilititle:               初夏鞋子合集 | Shoes Collection | Meng Maostream:    - format:        dash-flv      container:     mp4      quality:       高清 1080P      size:          93.0 MiB (97562752 bytes)    # download-with: you-get --format=dash-flv [URL]User Agent: Python-urllib/3.5Real URLs:http://upos-hz-mirrorwcsu.acgvideo.com/upgcxcode/12/76/94087612/94087612-1-30077.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1570938738&gen=playurl&os=wcsu&oi=3742040479&trid=aea76d5dd80e481b991f0493f08f002eu&platform=pc&upsig=b6c4a378a7de6e8ce1148acb2c2f5879&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=0http://upos-hz-mirrorcosu.acgvideo.com/upgcxcode/12/76/94087612/94087612-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1570938738&gen=playurl&os=cosu&oi=3742040479&trid=aea76d5dd80e481b991f0493f08f002eu&platform=pc&upsig=44e8b21648f11edead3b09f784030012&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=0[1]+  已完成               you-get -u https://www.bilibili.com/video/av53788919?from=search

关键词:
相关文章
山西开年“数说”能源:煤炭增产保供兼顾“双碳”目标

山西开年“数说”能源:煤炭增产保供兼顾“双碳”

  今年煤炭增产不低于5%、将达1365亿吨,同时还要兼顾双碳。1月31日,能源大省山西开年即聚焦能源增产保供。  在2023年山西能源工作会上,更多

2023-02-01 10:54:02
2022年全国煤炭采选业营业收入突破4万亿元

2022年全国煤炭采选业营业收入突破4万亿元

  国家统计局31日发布消息,2022年,规模以上工业企业实现营业收入13791万亿元,比上年增长59%;发生营业成本11684万亿元,增长71%;营业收更多

2023-02-01 10:09:55
2022年中国神华净利同比预增36.6-40.6%_全球微头条

2022年中国神华净利同比预增36.6-40.6%_全球微头条

  中国神华1月30日晚间发布业绩预告,公司预计2022年度实现归属于本公司股东的净利润为687亿元至707亿元,同比增长366%至406%。  预计2022更多

2023-02-01 09:56:57
2022年冀中能源净利预增54.05-80.70% 天天资讯

2022年冀中能源净利预增54.05-80.70% 天天资讯

  冀中能源1月31日发布业绩预告,公司预计2022年实现归属于上市公司股东的净利润422亿至495亿元,同比增长5405%-8070%。扣非后净利润比上年更多

2023-02-01 10:03:54
天天热门:加强能源保障,让群众暖身也暖心

天天热门:加强能源保障,让群众暖身也暖心

  今年春节,冷空气强势来袭。大年初一早晨,漠河阿木尔镇劲涛气象站监测到零下53摄氏度的气温,低于1969年2月13日漠河气象站的监测数据,打更多

2023-02-01 10:10:04
2022年全国能源保供能力稳步提升

2022年全国能源保供能力稳步提升

  国家统计局近日发布的数据显示,2022年,全国规模以上工业发电量84万亿千瓦时,比上年增长22%。其中,火电增长09%;水电、核电、风电和太更多

2023-02-01 09:53:56
贵州:加强中长期合同履约监管 电煤供应量8000万吨以上

贵州:加强中长期合同履约监管 电煤供应量8000万

  近日,贵州省人民政府办公厅印发2023年《政府工作报告》重点工作责任分工方案,并提出把发展工业作为首要任务,加快建设现代化产业体系。更多

2023-01-31 10:09:30
山西省进一步加强复采矿井安全生产工作 世界短讯

山西省进一步加强复采矿井安全生产工作 世界短讯

  日前,山西省应急管理厅、国家矿山安全监察局山西局联合下发《关于进一步加强复采矿井安全生产工作的通知》,要求各级各部门紧盯春节复产更多

2023-01-31 09:59:43
快看点丨1月第三周天津市煤炭价格环比持平

快看点丨1月第三周天津市煤炭价格环比持平

  据天津市市场运行监测数据显示,1月份第三周(1月16日-1月22日),天津市煤炭均价为734元吨,环比持平。上周出现了旺季煤价的逆季节下跌,更多

2023-01-31 10:12:36
1月第三周山西省煤炭价格微幅上涨

1月第三周山西省煤炭价格微幅上涨

  据山西省商务厅生产资料市场监测数据显示,1月第三周(1月16日-22日),山西省煤炭均价131652元吨,环比上涨04%。其中,动力煤发热量5000-更多

2023-01-31 10:02:30