5

我想获得一个实时 m3u8 文件而不是 DVR m3u8,因为后者包含太多片段(4 小时)并且速度慢且下载和处理不方便。

比如天空新闻直播频道

www.youtube.com/watch?v=y60wDzZt8yg

我做了什么:

将用户代理字符串更改为 iPad 或访问

www.youtube.com/get_video_info?&video_id=y60wDzZt8yg

我可以得到类似的东西

manifest.googlevideo.com/api/manifest/hls_variant/playlist_type/DVR/signature/11D1EE619ACDCA91661CB6F42597F96F0C86CC1F.742A7B383F4B10A099B1C7AAEF1E15DCD2F160C6/ipbits/0/fexp/9416126%2C9420452%2C9422596%2C9423459%2C9423661%2C9423662/source/yt_live_broadcast/id/y60wDzZt8yg.2/ sver/3/key/yt6/upn/0y8ab4RaX_U/expire/1454380402/sparams/gcr%2Cid%2Cip%2Cipbits%2Citag%2Cmaudio%2Cplaylist_type%2Cpmbypass%2Csource%2Cexpire/ip/86.172.63.152/itag/0/pmbypass/是/maudio/1/gcr/gb/file/index.m3u8

其中包含多个分辨率的子 m3u8 文件。

打开这个 720p 子 m3u8 文件时

manifest.googlevideo.com/api/manifest/hls_playlist/id/y60wDzZt8yg.2/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/gir/yes/dg_shard/eTYwd0R6WnQ4eWcuMg。 95/hls_chunk_host/r7---sn-cu-n1qe.googlevideo.com/playlist_type/DVR/pmbypass/yes/gcr/gb/mm/32/mn/sn-cu-n1qe/ms/lv/mv/u/ pcm2cms/yes/pl/24/dover/3/fexp/9416126,9420452,9422596,9423459,9423661,9423662/sver/3/upn/0y8ab4RaX_U/mt/1454358580/ip/86.172.63.152/ipbits/0/expire// 1454380402/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,gir,dg_shard,hls_chunk_host,playlist_type,pmbypass,gcr,mm,mn,ms,mv,pcm2cms,pl/signature/ 86FCD06C0400556C7F94B21019707B2501F98308.659A34C0F8A2DC70CC8DC411CD5D723C55146DD3/key/dg_yt0/playlist/index.m3u8

它包含最近 4 小时的 ts 段,处理和做进一步的事情非常慢。我发现如果我添加查询字符串

?start_seq=344610

到上面的链接,我可以得到一个更短的 m3u8 文件,它以这个特定的序列开头。但是,除非同时增加 start_seq 参数,否则文件中的序列数会随时间增加。

相比之下,对于频道提供商未启用播放的直播,YouTube 将自动返回一个直播 m3u8 文件,该文件仅包含几个不到一分钟的序列。链接最明显的区别是

播放列表类型/直播

而不是

播放列表类型/DVR

我想知道是否可以为那些提供商允许播放的 YouTube 直播流获取 LIVE m3u8 文件?也许有一些类似于“start_seq=XXX”的参数?还是有一些 API 可以直接返回实时 m3u8 链接?非常感谢。

4

1 回答 1

0

我不确定这是否正是您想要的,但是在 Firefox 上使用 Charles Proxy 并将用户代理设置为 iOS 上的 Safari,我能够获得带有 DVR 链接的 m3u8 播放列表。

HTTP GET: https://manifest.googlevideo.com/api/manifest/hls_variant/upn/wLKv6OL3J1A/sparams/gcr%2Cid%2Cip%2Cipbits%2Citag%2Cplaylist_type%2Cpmbypass%2Cratebypass%2Csource%2Cexpire/expire/1454656348/signature/D1ADDA66092157D87C5DBAB0ECD81AB1D4467291.646FFD703F6ADA2C2E9769F7F3590274C9555148/id/y60wDzZt8yg.2/key/yt6/ip/209.122.120.50/ratebypass/yes/pmbypass/yes/gcr/us/itag/0/ipbits/0/fexp/9405349%2C9408491%2C9418223%2C9419543%2C9420452%2C9421886%2C9422596%2C9422780%2C9423661%2C9424135%2C9424163%2C9425065%2C9425200%2C9425744%2C9426402%2C9427000%2C9427753/playlist_type/DVR/source/yt_live_broadcast/sver/3/keepalive/yes/file/index.m3u8?cpn=OjahYpsGmZq6lLAS

带有标题的完整 curl 命令:

curl -H "Host: manifest.googlevideo.com" \
-H "User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" \
-H "Accept: video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5" \
-H "Accept-Language: en-US,en;q=0.5" \
-H "Range: bytes=0-" \
-H "Referer: https://m.youtube.com/watch?v=y60wDzZt8yg" \
https://manifest.googlevideo.com/api/manifest/hls_variant/upn/wLKv6OL3J1A/sparams/gcr%2Cid%2Cip%2Cipbits%2Citag%2Cplaylist_type%2Cpmbypass%2Cratebypass%2Csource%2Cexpire/expire/1454656348/signature/D1ADDA66092157D87C5DBAB0ECD81AB1D4467291.646FFD703F6ADA2C2E9769F7F3590274C9555148/id/y60wDzZt8yg.2/key/yt6/ip/209.122.120.50/ratebypass/yes/pmbypass/yes/gcr/us/itag/0/ipbits/0/fexp/9405349%2C9408491%2C9418223%2C9419543%2C9420452%2C9421886%2C9422596%2C9422780%2C9423661%2C9424135%2C9424163%2C9425065%2C9425200%2C9425744%2C9426402%2C9427000%2C9427753/playlist_type/DVR/source/yt_live_broadcast/sver/3/keepalive/yes/file/index.m3u8?cpn=OjahYpsGmZq6lLAS

这个链接接受一个cpn参数,它是一个频道隐私号码。这是附加到 URL 请求的参数,我认为它是可选的。

于 2016-02-05T01:19:43.110 回答