You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检测YouTube指定文件是否为直播流?

Yes, this is totally feasible!

You can absolutely check if a specified YouTube video/stream is live (or an upcoming/completed live broadcast) using the YouTube Data API v3. I’ve worked through this exact use case before, so let me break down how to pull it off step by step:

1. Use the Videos.list endpoint

This is the core API endpoint you’ll need. You just need to pass two critical parameters:

  • id: The unique ID of the YouTube content you want to check
  • part: Specify snippet and liveStreamingDetails — these are the sections that hold all the live status data

Here’s a quick example request using curl:

curl "https://www.googleapis.com/youtube/v3/videos?id=YOUR_TARGET_CONTENT_ID&part=snippet,liveStreamingDetails&key=YOUR_YOUTUBE_API_KEY"

2. Interpret the response

Look for these key fields in the API’s returned data to determine the content’s live status:

  • Currently live stream:
    • snippet.liveBroadcastContent will be set to "live"
    • liveStreamingDetails will include an actualStartTime timestamp, and no actualEndTime (since the stream is still running)
  • Upcoming scheduled live stream:
    • snippet.liveBroadcastContent will be "upcoming"
    • liveStreamingDetails will have a scheduledStartTime timestamp marking when the stream goes live
  • Completed live stream (replay):
    • snippet.liveBroadcastContent will be "completed"
    • liveStreamingDetails will contain both actualStartTime and actualEndTime timestamps
  • Regular non-live video:
    • The liveStreamingDetails field won’t appear in the response at all
    • snippet.liveBroadcastContent will be "none"

Quick notes

  • For public content, you only need a standard YouTube Data API key (no OAuth authentication required). If you’re checking private/unlisted live streams, you’ll need to authenticate with appropriate permissions.
  • Double-check that your API key has the YouTube Data API v3 enabled in the Google Cloud Console before making requests.

内容的提问来源于stack exchange,提问作者Wojciech Urbaniak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:14:16