Fixed YouTube preview image not retrieved if &list is in in the URL

Kevin

Well-known member
Affected version
2.2.7 PL1
When embedding a YouTube URL the preview image is not retrieved if the list parameter is included. The video itself plays fine but no preview image is retrieved.

Example #1: https://www.youtube.com/watch?v=a01QQZyl-_I

This works fine in that the small preview image is shown when entering the details and when viewing it in the XFMG listing.

1636748194467.png

Example #2: https://www.youtube.com/watch?v=a01QQZyl-_I&list=PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf&index=10

This is the same video but is part of the list. The small preview image is not shown when entering the details and no image is shown in the XFMG listing.

1636748281275.png

Here's how both them look in the XFMG listing....

1636748325684.png
 

Nicolas FR

Well-known member
Hello,
 

Kevin

Well-known member
Hello,
Hello? 🤔

In that thread it sounds like you're referring to an actual YT list which, as you noted, is not supported by XF to be embedded. Those are links like https://www.youtube.com/playlist?list=PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf.

However, this thread is about individual songs within a list. Those can embedded and play just fine in XF. Those are links like https://www.youtube.com/watch?v=djV11Xbc914&list=PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf. There is no reason why a parameter within the URL should be breaking retrieving the thumbnail.
 

Kevin

Well-known member
The list parameter seems to be the source of a malfunction somewhere.
Yeah, it looks like an update to the YT URL parsing over the years may have broken it.

The function matchCallback in /XF/Bbode/Helper/YouTube.php looks for the 'list' parameter and if found saves it as part of the matched media ID (so a URL like https://www.youtube.com/watch?v=a01QQZyl-_I&list=PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf&index=10 gets turned into a01QQZyl-_I, list: PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf for the matched ID.​
That seems to work fine everywhere in XF since the video IDs are recognized & parsed as needed to embed the YT code and is why the actual video still plays in XFMG.​
With XFMG when retrieving the thumbnail the function getTempThumbnailPath in /src/addons/XFMG/EmbedData/YouTube.php seems to be looking for a video ID with a ":" colon in it and, if found, to parse out just the actual video ID a01QQZyl-_I when creating the thumbnail URL. So the XF devs know that the media ID could have extra data in it and to work around it to get the real ID.​
But in the example of a01QQZyl-_I, list: PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf it doesn't get matched in the regex so the URL requested ends up as https://i.ytimg.com/vi/a01QQZyl-_I, list: PLmXxqSJJq-yXrCPGIT2gn8b34JjOrl4Xf/maxresdefault.jpg instead of https://i.ytimg.com/vi/a01QQZyl-_I/maxresdefault.jpg so it of course fails.​
My guess is that the regex needs to be updated. Maybe something like (.*)(\,\.*) to parse on "," instead of the colon but this is where the XF guys know what they're doing far better than I so I'll wait & see what the patch fix looks like. :D
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.2.4).

Change log:
When embedding a YouTube video, if a list parameter is included, exclude this from the URL when fetching the thumbnail image.
There may be a delay before changes are rolled out to the XenForo Community.
 

Kevin

Well-known member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.2.4).
... this seems to be working as expected, thanks. 👍




(My new side project involves embedding a lot of YT videos so this fix helps.)
 
Top