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

如何使用YouTube API下载本人已举办的直播活动?

How to Download Your Own YouTube Live Stream via API

Hey there! I’ve run into this exact issue before—YouTube’s UI lets you download your own live replays easily, but tracking down the right API endpoints can feel like a needle-in-haystack job. Here’s a straightforward breakdown to get it working:

1. Lock in the Right API Access First

  • You’ll need to use the YouTube Data API v3—this is the official tool for managing your own YouTube content.
  • Authenticate with OAuth 2.0 credentials that have the right permissions:
    • For read-only access to download your videos, use the scope https://www.googleapis.com/auth/youtube.readonly
    • If you need broader control (like managing future broadcasts), go with https://www.googleapis.com/auth/youtube
  • Don’t forget to enable the YouTube Data API v3 in your Google Cloud Console project and set up OAuth credentials for your app/script.

2. Grab the Video ID of Your Completed Live Stream

Once a live stream ends, it converts into a regular YouTube video. First, you need to pull the video ID linked to your finished broadcast:

  • Use the liveBroadcasts.list endpoint with these parameters:
    • part=snippet
    • broadcastStatus=completed
    • mine=true (this filters results to only your own broadcasts)
  • In the response, you’ll find the associated video ID under items[].snippet.resourceId.videoId

Alternatively, use the search.list endpoint for a more direct approach:

  • part=snippet
  • type=video
  • eventType=completed
  • mine=true
    This will return all your completed live stream videos directly, no extra steps needed.

3. Download the Video Using the Media API

With the video ID in hand, you can pull the actual video file using Google’s media download tools:

  • First, confirm ownership (though if you used mine=true earlier, this is already a given) with the videos.list endpoint and part=contentDetails.
  • Then, use Google’s client libraries (like google-api-python-client for Python) to handle the download. Here’s a quick example snippet:
    from googleapiclient.discovery import build
    from googleapiclient.http import MediaIoBaseDownload
    import io
    
    # Initialize the API client with your OAuth credentials
    youtube = build('youtube', 'v3', credentials=your_oauth_credentials)
    
    # Start the download process
    request = youtube.videos().get(id=YOUR_LIVE_STREAM_VIDEO_ID)
    file_handle = io.FileIO('my_live_replay.mp4', 'wb')
    downloader = MediaIoBaseDownload(file_handle, request)
    
    done = False
    while not done:
        status, done = downloader.next_chunk()
        print(f"Download progress: {int(status.progress() * 100)}%")
    

Quick Important Notes

  • You can only download videos you own—this API won’t let you access other users’ content.
  • If you hit permission errors, double-check your OAuth scope and make sure you’re authenticated as the live stream’s owner.
  • The download will default to the highest available quality, but you can specify quality parameters in the media downloader if needed.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 09:16:56