thibaudgg / video_info

Get video info from Dailymotion, Vimeo, Wistia, and YouTube URLs.

Home Page:https://rubygems.org/gems/video_info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange vimeo thumbnail url issue

drakmail opened this issue · comments

When I'm trying to get vimeo thumbnail (through scraper) I always getting this image:

image example

Steps to reproduce:

video = VideoInfo.new('https://vimeo.com/193970014')
video.thumbnail_medium
# => "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F607241994_200x150.jpg"

One more thing: if I remove vimeocdn filter part of string (for example, if I left only this part: https://i.vimeocdn.com/video/607241847_200x150.jpg) than I getting valid image:

valid image example

We're getting the image URLs from some JSON we ripped from a script tag (hacky, I know) and just modifying the resolution on the URL. It looks like the proper way would be to get them from meta tags, which we already have code to do.. The URL here works fine, despite being the same format as what we're returning now:

    <meta property="og:image" content="https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F607241994_1280x1280.webp&src1=https%3A%2F%2Ff.vimeocdn.com%2Fimages_v6%2Fshare%2Fplay_icon_overlay.png">

The https://i.vimeocdn.com/filter/overlay? stuff appears to add a play icon overlay. Changing the resolution via the image URL also seems to work fine..

We could parse out the image URL so that we don't have the overlay, but I'd imagine that'd make things much more prone to breakage. With the scraper I think it's better that things work rather than work optimally (people can get an API key if they need that), so for now I'm just going to make it return the meta tag URL as is (modifying the resolution of course). If you think it's worth removing the overlay, let me know.

Looking at the videos in our tests, it looks like your video is actually a special case. Other videos don't have the overlay. This video just has this: <meta property="og:image" content="https://i.vimeocdn.com/video/531688239_1280x720.webp">

I'm thinking we won't need different code to handle it (just gonna throw some regex at changing the resolutions...), but I'll add it to the unit tests.

It's fixed in master. I'll push a new gem out tonight. It ended up being simpler to just remove the overlay.

@drakmail 2.7 has been released on Ruby Gems. Feel free to upgrade.