Youtube api Youtube api检测实时视频

Youtube api Youtube api检测实时视频,youtube-api,live,Youtube Api,Live,是否有一种使用视频列表检测实时视频的方法?或者如果你有视频ID的话,用其他方式 https://www.googleapis.com/youtube/v3/videos?id=8WbMEmtUckA&key=API_KEY&part=id,snippet 我在这里看不到这样的信息:另一种方式;您可以尝试使用Youtube搜索列表,只需将eventType参数设置为live,您将在结果上获得直播视频 Python示例用于直播和当前观看最多的视频: import os impor

是否有一种使用视频列表检测实时视频的方法?或者如果你有视频ID的话,用其他方式

https://www.googleapis.com/youtube/v3/videos?id=8WbMEmtUckA&key=API_KEY&part=id,snippet

我在这里看不到这样的信息:

另一种方式;您可以尝试使用Youtube搜索列表,只需将eventType参数设置为live,您将在结果上获得直播视频

Python示例用于直播和当前观看最多的视频:

import os

import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors

scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]

def main():
    # Disable OAuthlib's HTTPS verification when running locally.
    # *DO NOT* leave this option enabled in production.
    os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

    api_service_name = "youtube"
    api_version = "v3"
    client_secrets_file = "YOUR_CLIENT_SECRET_FILE.json"

    # Get credentials and create an API client
    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
        client_secrets_file, scopes)
    credentials = flow.run_console()
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, credentials=credentials)

    request = youtube.search().list(
        part="snippet",
        eventType="live",
        maxResults=50,
        order="viewCount",
        type="video"
    )
    response = request.execute()

    print(response)

if __name__ == "__main__":
    main()
更多详细信息:YouTube返回一个包含大量信息的长json文件。我们只需要“视频ID”

示例“CZByYnUbAgI”复制此Id并粘贴到


另一种方式;您可以尝试使用Youtube搜索列表,只需将eventType参数设置为live,您将在结果上获得直播视频

Python示例用于直播和当前观看最多的视频:

import os

import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors

scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]

def main():
    # Disable OAuthlib's HTTPS verification when running locally.
    # *DO NOT* leave this option enabled in production.
    os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

    api_service_name = "youtube"
    api_version = "v3"
    client_secrets_file = "YOUR_CLIENT_SECRET_FILE.json"

    # Get credentials and create an API client
    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
        client_secrets_file, scopes)
    credentials = flow.run_console()
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, credentials=credentials)

    request = youtube.search().list(
        part="snippet",
        eventType="live",
        maxResults=50,
        order="viewCount",
        type="video"
    )
    response = request.execute()

    print(response)

if __name__ == "__main__":
    main()
更多详细信息:YouTube返回一个包含大量信息的长json文件。我们只需要“视频ID”

示例“CZByYnUbAgI”复制此Id并粘贴到

选项在同一链接的接受答案中或中描述。选项在同一链接的接受答案中或中描述。