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

[v3] YouTube oembed returning consent.youtube.com link #434

Closed
kinglozzer opened this issue Mar 31, 2021 · 3 comments
Closed

[v3] YouTube oembed returning consent.youtube.com link #434

kinglozzer opened this issue Mar 31, 2021 · 3 comments

Comments

@kinglozzer
Copy link

This isn’t really an issue with this library (at least, I’m 99% sure it isn’t) so I’ll close this straight away - I just wanted to post it here for visibility, in case someone else like me is searching for this problem and also wondering if they’re alone...

https://youtube.com/oembed is sometimes returning an iframe as expected, and sometimes returning an anchor which links to https://consent.youtube.com:

<a href="https://consent.youtube.com/ml?continue=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D<VIDEOIDHERE>%26feature%3Dyoutu.be&amp;gl=GB&amp;hl=en-GB&amp;pc=yt&amp;uxe=24020388&amp;src=1">
    Before you continue to YouTube
</a>

I can’t recreate this locally, or even reliably on the live site, so it’s really difficult to try to debug what’s happening here. Given that the consent URL wants to redirect to the video, and not https://youtube.com/oembed, I can only assume that it is actually reaching the oembed API and that is returning the consent URL. Requesting the same embed code again later seems to work fine, so my best guess is that it depends which of YouTube’s edge servers responds.

I’ve reported it to YouTube via the “Send Feedback” thing as that’s the only place I could find to report an issue. I have no idea if I should expect a response!

@kinglozzer kinglozzer reopened this Apr 1, 2021
@kinglozzer kinglozzer changed the title YouTube oembed returning consent.youtube.com link [v3] YouTube oembed returning consent.youtube.com link Apr 1, 2021
@kinglozzer
Copy link
Author

kinglozzer commented Apr 1, 2021

Re-opening as it’s now happening more widely for people (in the UK & EU anyway). Note that this only appears to be happening on v3 of the library, not sure if it’s patchable or if this will just be a “wontfix”.

The problem is that when embedding a URL like https://www.youtube.com/watch?v=YgGzAKP_HuM, v3 of the library will first attempt to fetch that URL itself before it calls the oembed. The original URL redirects to the consent page:

https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYgGzAKP_HuM&gl=GB&m=0&pc=yt&uxe=23983172&hl=en-GB&src=1

The library then tries to call the oembed endpoint with that URL as the source, instead of the original video URL:

https://www.youtube.com/oembed?url=https%3A%2F%2Fconsent.youtube.com%2Fml%3Fcontinue%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DYgGzAKP_HuM%26gl%3DGB%26hl%3Den-GB%26pc%3Dyt%26uxe%3D23983172%26src%3D1&format=json

A patch for this would ideally ensure that the oembed endpoint is called with the original URL. I’ve not investigated how much work that’s likely to be

oscarotero added a commit that referenced this issue Apr 1, 2021
Update YouTube Oembed adapter to work with new consent page (fixes #434)
@oscarotero
Copy link
Owner

Ok, pull request merged and v3.4.14 published.
Thanks

@kinglozzer
Copy link
Author

kinglozzer commented Apr 1, 2021

Thanks @oscarotero! Unfortunately there’s one thing I didn’t take into consideration: when people use short youtu.be URLs instead of the full URL - I’ll submit a new PR for that, it should be a pretty simple tweak

Edit: #436

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

2 participants