Skip to content

Instantly share code, notes, and snippets.

@rlamacraft
Created October 9, 2019 15:34
Show Gist options
  • Save rlamacraft/a7cd69743b46978ae3463ad07ed4c89f to your computer and use it in GitHub Desktop.
Save rlamacraft/a7cd69743b46978ae3463ad07ed4c89f to your computer and use it in GitHub Desktop.
# This YouTube video has a number of other people
# involved and links to them in the description in
# a clean way. Should serve as a good origin node.
ORIGIN_VIDEO_ID = "zUDqI9PJpc8"
import os
import json
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
scopes = ["https://www.googleapis.com/auth/youtube.readonly"]
def fetch_description(videoId):
# 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 = "client_secrets.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.videos().list(
part="snippet",
id=videoId
)
response = request.execute()
description = response["items"][0]["snippet"]["description"]
return(description)
if __name__ == "__main__":
print(fetch_description(ORIGIN_VIDEO_ID))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment