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

Apply an embed preset to a video? #35

Open
mattgilbertnet opened this issue Feb 10, 2021 · 6 comments
Open

Apply an embed preset to a video? #35

mattgilbertnet opened this issue Feb 10, 2021 · 6 comments

Comments

@mattgilbertnet
Copy link

Is there a way to apply an embed preset to a video using this gem, either on upload or afterwards given the vimeo ID? The API has support for this:
https://developer.vimeo.com/api/reference/embed-presets?version=#add_video_embed_preset

@mattgilbertnet
Copy link
Author

For a little more context, I've tried:
$vimeo.put("/videos/#{vimeo_id}/presets/#{preset_id}", code:204)

and got:

Traceback (most recent call last):
        2: from (irb):3
        1: from (irb):4:in `rescue in irb_binding'
VimeoMe2::RequestFailed (VimeoMe2::RequestFailed)

@bo-oz
Copy link
Owner

bo-oz commented Feb 10, 2021

You can get more information about the request by inpsecting the raw HTTParty reponse $vimeo.client.last_request after a failed call. You should get more info on why the request failed. Could you check? Basically when using put you're no longer leveraging the gem itself, but merely the shorthand to make calls directly via HTTParty.

I quickly created a convenience method for this call and updated the gem. So you can do this more easily:

  1. Get your video: vimeo_video = VimeoMe2::Video.new('API_KEY','VIIDEO_ID')
  2. Add a preset to it: vimeo_video.add_preset('1234')

@mattgilbertnet
Copy link
Author

Here's the result of $vimeo.client.last_request (Obfuscated some stuff that idk might be sensitive.):

#<HTTParty::Response:0x230f0 parsed_response="{"error":"The requested page couldn't be found."}", @response=#<Net::HTTPNotFound 404 Not Found readbody=true>, @headers={"connection"=>["close"], "content-length"=>["49"], "server"=>["nginx"], "content-type"=>["application/vnd.vimeo.error+json"], "expires"=>["Wed, 10 Feb 2021 10:16:46 GMT"], "cache-control"=>["private, no-store, no-cache"], "strict-transport-security"=>["max-age=31536000; includeSubDomains; preload"], "request-hash"=>[...], "x-bapp-server"=>[...], "x-vimeo-dc"=>["ge"], "accept-ranges"=>["bytes"], "via"=>["1.1 varnish, 1.1 varnish"], "date"=>["Wed, 10 Feb 2021 22:16:46 GMT"], "x-served-by"=>..., "x-cache"=>["MISS, MISS"], "x-cache-hits"=>["0, 0"], "x-timer"=>[...], "vary"=>["Accept,Vimeo-Client-Id"]}>

@mattgilbertnet
Copy link
Author

Same response from vimeo_video.client.last_request using your convenience method.

@mattgilbertnet
Copy link
Author

This might be helpful: I was able to set the preset using RestClient with:

RestClient.put(
  "https://api.vimeo.com/videos/#{vimeo_id}/presets/#{preset_id}",
  {},
  {
    "authorization": "Bearer #{VIMEO_API_KEY}"
  }
)

The {}, might be a clue.

@Cluster444
Copy link
Contributor

You can get more information about the request by inpsecting the raw HTTParty reponse $vimeo.client.last_request after a failed call. You should get more info on why the request failed. Could you check? Basically when using put you're no longer leveraging the gem itself, but merely the shorthand to make calls directly via HTTParty.

I quickly created a convenience method for this call and updated the gem. So you can do this more easily:

  1. Get your video: vimeo_video = VimeoMe2::Video.new('API_KEY','VIIDEO_ID')
  2. Add a preset to it: vimeo_video.add_preset('1234')

The URI Path for this is missing a '/' between the base_uri and the preset portion of the path, example I get using this is

/videos/1234preset/1234

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