Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
simplexml_load_file call to "http://gdata.youtube.com/feeds/api/videos/ID" returns 410 code and since the is no error handling it crashes.
Proposed resolution
Implement v3.0 API integration to fetch images. Fall back to the sane default (http://img.youtube.com/vi/[video_id]/hqdefault.jpg) if API is not configured correctly.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2619906.diff | 1.16 KB | mikgreen |
Comments
Comment #2
mikgreen CreditAttribution: mikgreen at Wunder commentedComment #3
mikgreen CreditAttribution: mikgreen at Wunder commentedComment #4
slashrsm CreditAttribution: slashrsm as a volunteer commentedCan we assume this thumbnail file exists for every video on YouTube? I remember searching docs and looking for any information about that, but I wasn't able to find anything useful.
Comment #5
mikgreen CreditAttribution: mikgreen at Wunder commentedIt's undocumented. So we can't rely on it fully.
But seems to work on all videos. From latest to very first video no YouTube.
There's no good alternative. Using official API v3 requires getting an API key from YouTube. Which I believe is too much of a hastle for most module users.
Comment #6
slashrsm CreditAttribution: slashrsm as a volunteer commentedI'd say we implement API v3.0 support and fall back to this thumbnail file if it is not configured properly.
Comment #7
slashrsm CreditAttribution: slashrsm as a volunteer commentedComment #8
phenaproximaFixed by https://github.com/drupal-media/media_entity_embeddable_video/pull/18.
Comment #9
Lukas von BlarerI tested your patch with and without an YouTube api key. Works perfectly. I only face one issue: First I used a Browser api key instead of a Server api key. When fetching a thumbnail, I got a WSOD. Shouldn't we catch that? This is the response from YouTube:
Except for that RTBC.
Comment #10
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedComment #11
phenaproximaCorrected: https://github.com/phenaproxima/media_entity_embeddable_video/commit/d47...
Comment #12
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedMerged. Thanks!
Comment #13
Lukas von BlarerThe fallback image is not working. I created a PR for this: https://github.com/drupal-media/media_entity_embeddable_video/pull/19
Comment #15
phenaproximaThat PR has been merged as well, so this is well and truly fixed.