RETRIABLE_EXCEPTIONS = (httplib2.HttpLib2Error, IOError, httplib.NotConnected, # Always retry when these exceptions are raised. # Maximum number of times to retry before giving up. # Explicitly tell the underlying HTTP transport library not to retry, since The complete working sample for the upload_video.py script is listed below:įrom apiclient.http import MediaFileUploadįrom oauth2client.client import flow_from_clientsecretsįrom oauth2client.tools import argparser, run_flow Valid values are public, private, and unlisted. When uploading test videos, you may want to specify a -privacyStatus argument value to ensure that those videos are private or unlisted. The default behavior is for an uploaded video to be publicly visible ( public). PrivacyStatus: The privacy status of the video. Keywords: A comma-separated list of keywords associated with the video. The default value is 22, which refers to the People & Blogs category. Example: -description="Had fun surfing in Santa Cruz"Ĭategory: The category ID for the YouTube video category associated with the video. Example: -title="Summer vacation in California"ĭescription: The description of the video that you're uploading. Title: The title of the video that you are uploading. The list below defines the script's command-line arguments:įile: This argument identifies the location of the video file that you are uploading. "description": "Had fun surfing in Santa Cruz", "title": "Summer vacation in California", In this example, the script would build and insert the following video resource for the video: description="Had fun surfing in Santa Cruz" Python upload_video.py -file="/tmp/test_video_file.flv" The command-line arguments are all defined in detail in the following section. This request uploads a video and sets various metadata fields for the video, including its title, description, keywords, and category. The file should be in the same directory as the script. To use OAuth 2.0 steps with this script, you'll need to create a client_secrets.json file that contains information from the API Console. Register your application with Google so that it can use the OAuth 2.0 protocol to authorize access to user data. Install the Google APIs Client Library for Python ( google-api-python-client) Note: The sample script does not do error handling. (Client libraries for other popular programming languages are also available.) The code uses the Google APIs Client Library for Python. This guide provides and explains a Python script that uploads a YouTube video using the YouTube Data API.
0 Comments
Leave a Reply. |