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

Cant fetch thumbnails #206

Closed
NowakJR opened this issue Sep 23, 2021 · 9 comments
Closed

Cant fetch thumbnails #206

NowakJR opened this issue Sep 23, 2021 · 9 comments

Comments

@NowakJR
Copy link

NowakJR commented Sep 23, 2021

Hey, so lately I've gotten into a problem with fetching thumbnails from vimeo, every single thumbnail in a project was vertical bars in colours of a rainbow. It turned out vimeo changed their url format, and didnt bother to tell anyone(thread: https://community.roku.com/t5/Roku-Developer-Program/Vimeo-Thumbnail-is-not-showing-in-any-channel/td-p/721844)
So to get to the real thumbnails which are here, under pictures/sizes/link I had to monkeypatch this gem.

"pictures": {
"uri": "/videos/604925161/pictures/1241392221",
"active": true,
"type": "custom",
"sizes": [
{
"width": 100,
"height": 75,
"link": "https://i.vimeocdn.com/video/1241392221-cd13a462737b76c8d54c15bf8d38b15575bc04d18031d4653c97d0b2c8eb6db3-d_100x75?r=pad",

Are you planning on fixing this issue?
Cheers.

@pozelli
Copy link

pozelli commented Sep 24, 2021

Hey
How did you do the monkeypatch?
Thanks

@fakenine
Copy link

Hey @NowakJR. I'd also be interested for the monkey patch while we wait for a fix, thanks :)

@NowakJR
Copy link
Author

NowakJR commented Sep 27, 2021

Hi guys here is how I did the monkey patch: In file where i am fetching thumbnail URL i added these lines of code in Base class

VideoInfo::Providers::VimeoAPI.module_eval do

            def thumbnail_id

              @thumbnail_id ||= _parse_picture_id(_video['pictures']['sizes'].first['link'])

            end

            def _parse_picture_id(string)

              a, b, c = string.split("/").last.split("-")

              d = c.split("_").first

              [a, b, d].join("-")

            end

          end

I know variables names are kinda bad but I left them like that for a while until i have time to change them.

@fakenine
Copy link

@NowakJR Thank you! I will test this

@pozelli
Copy link

pozelli commented Sep 27, 2021

Yeah, it works! Thanks!

I created the file: config/initializers/video_info.rb with the following code:

VideoInfo::Providers::VimeoAPI.module_eval do
  def thumbnail_id
    @thumbnail_id ||= _parse_picture_id(_video['pictures']['sizes'].first['link'])
  end
  def _parse_picture_id(uri)
    a, b, c = uri.split("/").last.split("-")
    d = c.split("_").first
    [a, b, d].join("-")
  end
end

@asgerb
Copy link

asgerb commented Sep 28, 2021

Thanks for the patch @NowakJR. I found that it fails on certain videos so here's a cleaned up version which works with all the videos I've tested:

VideoInfo::Providers::VimeoAPI.module_eval do
  THUMBNAIL_LINK_REGEX = /.*\/(\d+\-[^_]+)/

  def thumbnail_id
    @thumbnail_id ||= _parse_picture_id(_video.dig("pictures", "sizes").first["link"])
  end

  private

  def _parse_picture_id(uri)
    uri.match(THUMBNAIL_LINK_REGEX)[1]
  end
end

@NowakJR
Copy link
Author

NowakJR commented Sep 29, 2021

Awesome man! This also looks much better. Thank you very much for contributing @asgerb

@NowakJR NowakJR closed this as completed Sep 30, 2021
@NowakJR NowakJR reopened this Oct 12, 2021
@ruanltbg
Copy link

Thank you @asgerb and @NowakJR . That worked fine.

Hey @joaocv3 , any idea when we could have this merged in?

@joaocv3
Copy link
Collaborator

joaocv3 commented Nov 15, 2021

Hi guys, thanks for the inputs!

I couldnt find much time to work on it for the last weeks

just released v3.0.2 🚀

@joaocv3 joaocv3 closed this as completed Nov 15, 2021
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

6 participants