vimeo_me2
vimeo_me2 copied to clipboard
Apply an embed preset to a video?
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
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)
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:
- Get your video:
vimeo_video = VimeoMe2::Video.new('API_KEY','VIIDEO_ID')
- Add a preset to it:
vimeo_video.add_preset('1234')
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"]}>
Same response from vimeo_video.client.last_request
using your convenience method.
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.
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 usingput
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:
- Get your video:
vimeo_video = VimeoMe2::Video.new('API_KEY','VIIDEO_ID')
- 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