Brandon
Brandon

Reputation: 1013

How do I upload a transcript to YouTube via the API?

The relevant documentation is found here: https://developers.google.com/youtube/2.0/developers_guide_protocol_captions#Create_Caption_Track

I've tried the following, but I simply receive an esoteric "urllib2.HTTPError: HTTP Error 401: Unknown authorization header"

import gdata.youtube, gdata.youtube.service, urllib2
yt_service = gdata.youtube.service.YouTubeService()
yt_service.ClientLogin("[email protected]","password")
yt_service.ProgrammaticLogin()
auth = yt_service.current_token.get_token_string()
url = "https://gdata.youtube.com/feeds/api/videos/VIDEO_ID/captions"
req = urllib2.Request(url, "Transcript", {'Content-Type': 'application/vnd.youtube.timedtext; charset=UTF-8', 'Content-Language:': 'en', 'Authorization': auth})
f = urllib2.urlopen(req)

Upvotes: 1

Views: 369

Answers (1)

Jeff Posnick
Jeff Posnick

Reputation: 56124

There's a bunch of info in this blog post, including a link to this sample Python script for uploading captions.

Upvotes: 1

Related Questions