Getting YouTube livestream URL

2019-04-13 13:15发布

问题:

I need a way to get the URLs of a YouTube live stream, ideally URLs for each quality (i.e. 240p, 360p).

What I tried so far:

  1. Use Wireshark (Don't know how to apply proper filters)
  2. Use urlsnoopers (Couldn't find anything that works in Linux)
  3. Get the m3u8 URL from the page source (Couldn't control quality)
  4. Use Firefox developer tools to analyze the network (Would not get the m3u8 URL for some links)

On another note I noticed that some of the lower quality stream URL links seem to get stuck after a few seconds. Any idea why?

回答1:

There's a Python tool called livestreamer that gets the job done.

Steps:

  1. Install python-pip (Python module management tool):

    yum install python-pip 
    
  2. Add the livestreamer module:

    sudo pip install livestreamer
    
  3. Play the video with the --stream-url option:

    livestreamer https://www.youtube.com/watch?v=eWRei_9cEO8 240p --stream-url