Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Thumbnail Image? #218

Open
hartator opened this issue Apr 28, 2014 · 2 comments
Open

Add Thumbnail Image? #218

hartator opened this issue Apr 28, 2014 · 2 comments

Comments

@hartator
Copy link

Thanks for great code!

Any idea how to add a custom thumbnail to a video upload or is it not implemented yet?

@bodrovis
Copy link
Contributor

I believe it is not implemented

@blakeley
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants