1

Is there a way to detect live video using videos list? Or some other way if you have video ID?

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

I dont see this info here: https://developers.google.com/youtube/v3/docs/videos/list

Toniq
  • 4,492
  • 12
  • 50
  • 109

1 Answers1

0

Another way; You can try with a Youtube Search list, just set the eventType parameter to live and you will get live broadcasting videos on the result...

Python example for live broadcast and currently most viewed videos:

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()

More detail: YouTube return a long json file with a lot of information. We want just 'videoId'

example 'CZByYnUbAgI' copy this Id and paste on to end of https://www.youtube.com/watch?v=

3V3R-3ST
  • 51
  • 1
  • 8