5
votes

I would like to get a live m3u8 file rather than a DVR m3u8 as the latter contains too many segments (4 hours) and is slow and not convenient to download and process.

For example, the sky news live channel

www.youtube.com/watch?v=y60wDzZt8yg

What I have done:

Changing user-agent string to iPad or visiting

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

I could get something like

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/yes/maudio/1/gcr/gb/file/index.m3u8

which contains sub-m3u8 files of multiple resolutions.

When opening this 720p sub-m3u8 file

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

It contains the ts segments of recent 4 hours and it is so slow to process and do further things. I have found if I add the query string

?start_seq=344610

to the above link, I could get a much shorter m3u8 file which starts with this particular sequence. However, the number of sequences in the file will increase with time unless the start_seq parameter is increased at the same time.

In contrast, for a live stream without playback enabled by the channel provider, YouTube will automatically return a live m3u8 file which contains only several sequences of less than one minute. The most noticeable difference of the link is

playlist_type/LIVE

rather than

playlist_type/DVR

I am wondering if I could get a LIVE m3u8 file for those YouTube live streams whose providers allow playback? Maybe there are some parameters similar to the "start_seq=XXX"? Or there is some API which can return live m3u8 links directly? Thank you very much.

1
Did you find an answer to this?John Bassos

1 Answers

0
votes

I'm not sure this is exactly what your want, but using Charles Proxy with Firefox and setting the user agent to Safari on iOS I was able to get an m3u8 playlist with DVR links.

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

Full curl command with headers:

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

This link takes a cpn parameter which is a Channel Privacy Number. This was a parameter appended to the URL request which I believe is optional.