今天想下载 IG 的一个视频, 于是打开了网页端, 找到视频标签, 查看是 blob, 于是去 Network 里找 m3u8, 但是没有找到.
测试链接: https://www.instagram.com/reel/CdYOo_QIB5L/
video 标签:
<video class="tWeCl" crossorigin="anonymous" playsinline="" poster="https://scontent-hkt1-2.cdninstagram.com/v/t51.2885-15/280525371_399280442062025_5345542004741217395_n.jpg" preload="none" type="video/mp4" src="blob:https://www.instagram.com/4feb10a9-7a9d-4d3c-b63a-6773a391bded" loop="" style="display: block;"></video>
于是就很好奇, 查看了一下, 它使用分段的 mp4 进行拼接成的视频, 视频链接如下:
links = [
'https://scontent-hkt1-2.cdninstagram.com/v/t66.30100-16/48765482_566184564823119_7249730986057316274_n.mp4?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_cat=1&_nc_ohc=4Ba61mlOYE4AX9Ym6rG&edm=APfKNqwBAAAA&ccb=7-4&oh=00_AT-ddAJEjKnOOOGslcGOVkxctcfcao29aLwNDjjWSC7d5g&oe=627D7BBA&_nc_sid=74f7ba&bytestart=0&byteend=782',
'https://scontent-hkt1-2.cdninstagram.com/v/t66.30100-16/48765482_566184564823119_7249730986057316274_n.mp4?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_cat=1&_nc_ohc=4Ba61mlOYE4AX9Ym6rG&edm=APfKNqwBAAAA&ccb=7-4&oh=00_AT-ddAJEjKnOOOGslcGOVkxctcfcao29aLwNDjjWSC7d5g&oe=627D7BBA&_nc_sid=74f7ba&bytestart=783&byteend=970',
'https://scontent-hkt1-2.cdninstagram.com/v/t66.30100-16/48765482_566184564823119_7249730986057316274_n.mp4?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_cat=1&_nc_ohc=4Ba61mlOYE4AX9Ym6rG&edm=APfKNqwBAAAA&ccb=7-4&oh=00_AT-ddAJEjKnOOOGslcGOVkxctcfcao29aLwNDjjWSC7d5g&oe=627D7BBA&_nc_sid=74f7ba&bytestart=971&byteend=22557',
'https://scontent-hkt1-2.cdninstagram.com/v/t66.30100-16/48765482_566184564823119_7249730986057316274_n.mp4?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_cat=1&_nc_ohc=4Ba61mlOYE4AX9Ym6rG&edm=APfKNqwBAAAA&ccb=7-4&oh=00_AT-ddAJEjKnOOOGslcGOVkxctcfcao29aLwNDjjWSC7d5g&oe=627D7BBA&_nc_sid=74f7ba&bytestart=22558&byteend=161856',
'https://scontent-hkt1-2.cdninstagram.com/v/t66.30100-16/48765482_566184564823119_7249730986057316274_n.mp4?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_cat=1&_nc_ohc=4Ba61mlOYE4AX9Ym6rG&edm=APfKNqwBAAAA&ccb=7-4&oh=00_AT-ddAJEjKnOOOGslcGOVkxctcfcao29aLwNDjjWSC7d5g&oe=627D7BBA&_nc_sid=74f7ba&bytestart=161857&byteend=304637',
];
于是自己写了下面这段代码, 手动拼接然后进行下载:
var blobs = await Promise.all(links.map(async link=> {
return await fetch(link).then(r=>r.blob())
}));
var combinedVideoBlob = blobs.reduce((a, b) => new Blob([a, b], { type: 'video/mp4' }));
var downloadA = document.createElement("a");
downloadA.download = "a.mp4";
downloadA.href = window.webkitURL.createObjectURL(combinedVideoBlob);
downloadA.click();
最终下载成功, 但是视频只有声音没有图像.
1
wunonglin 2022-05-11 16:13:46 +08:00
大概率是 mediastream 、http range
|
2
LeegoYih 2022-05-11 16:17:40 +08:00
you-get 支持下载视频和图片: https://github.com/soimort/you-get/
|
3
ynyounuo 2022-05-11 16:24:00 +08:00 1
1. 换成移动端的 UA 直接在 Network 的 media filter 下就有完整视频链接了
2. 多了去了 3. DASH/HLS + CENC 加密 |
4
yanyumihuang 2022-05-11 17:07:09 +08:00
Windows idm ,mac 不知道
|
5
findex 2022-05-11 17:50:38 +08:00
firefox 有插件,可以下载 instagram 视频,而且支持拼接。没必要自己写了。
|
6
FaiChou OP @LeegoYih 之前发过帖子, you-get 不好用了, 用 yt-dlp 代替 ( https://v2ex.com/t/818153#reply20).
|