Open hartator opened 10 years ago
I believe it is not implemented
I have a nearly-working implementation of thumbnail uploads, but there's some bug that I can't work out.
class YouTubeIt
class Client
def thumbnail_update(video_id, data)
client.thumbnail_update(video_id, data)
end
end
module Upload
class VideoUpload
def v3_base_url
"https://www.googleapis.com"
end
def thumbnail_update(video_id, data)
puts @dev_key
upload_header = {
"Content-Type" => "image/png",
"Content-Length" => "#{data.size}",
"Authorization" => ": Bearer #{@access_token.token}",
"X-GData-Key" => "key=#{@dev_key}",
}
upload_url = "/upload/youtube/v3/thumbnails/set?videoId=#{video_id}&access_token=#{@access_token.token}"
response = yt_session(v3_base_url).post(upload_url, data, upload_header)
end
end
end
end
client.thumbnail_update(yt_vid_id, open(thumbnail_filename))
When running this code, I get the following response:
AuthenticationError: { "error": { "errors": [ { "domain": "youtube.thumbnail", "reason": "forbidden", "message": "Forbidden", "locationType": "header", "location": "Authorization" } ], "code": 403, "message": "Forbidden" }}
The documentation at https://developers.google.com/youtube/v3/guides/authentication suggests I'm authorized and performing an action correctly, but my application isn't authorized. Either way, hard coding in the authentication parameters like this is less than ideal and should be managed in the authorization_headers method; I did it like this just to hack it together. Perhaps someone else can build on this code to finish this implement this method correctly.
Thanks for great code!
Any idea how to add a custom thumbnail to a video upload or is it not implemented yet?