How can I get the actual video URL of a YouTube live stream?

前端 未结 3 1139
庸人自扰
庸人自扰 2020-11-29 18:38

Is there a way to get the HLS URL for YouTube live streams like this one https://www.youtube.com/embed/WVZpCdHq3Qg

I\'ve tried the typical get_video_info methods but

3条回答
  •  再見小時候
    2020-11-29 18:52

    Yes this is possible Since the question is update, this solution can only gives you the embed url not the HLS url, check @JAL answer. with the ressource search.list and the parameters:

    * part: id
    * channelId: UCURGpU4lj3dat246rysrWsw
    * eventType: live
    * type: video
    

    Request :

    GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCURGpU4lj3dat246rysrWsw&eventType=live&type=video&key={YOUR_API_KEY}
    

    Result:

     "items": [
      {
       "kind": "youtube#searchResult",
       "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/enc3-yCp8APGcoiU_KH-mSKr4Yo\"",
       "id": {
        "kind": "youtube#video",
        "videoId": "WVZpCdHq3Qg"
       }
      },
    

    Then get the videoID value WVZpCdHq3Qg for example and add the value to this url:

    https://www.youtube.com/embed/ + videoID
    https://www.youtube.com/watch?v= + videoID
    

提交回复
热议问题