dyatlov/go-opengraph

No metadata generated for YouTube links

Closed this issue · 4 comments

Recently, we've started seeing some cases where YouTube links aren't generating metadata using this library. It looks like YouTube is putting their <meta> tags in the body of their HTML for some reason along with some other tags that are only supposed to be in the head.

YouTube's current HTML is invalid, so presumably they'll fix it at some point, but in the mean time, we'll have to be more tolerant of incorrect HTML. We're going to fork this library to make it find meta tags in the body in the mean time, but would you be interested in having that change merged upstream?

Thank you for reaching out Harrisson.
Yes, it's definitely worth merging into upstream as this problem might happen to other sites as well. Though need to make sure that headers take precedence (as it's the only valid place by standard).

Btw, did you consider using oembed information? Youtube can provide some of the information in open standardised format.

I didn't bother prioritizing meta tags in the head since that doesn't seem necessary since that's another case that we hopefully shouldn't see in practice. Some other libraries I looked at also just check the whole tree for meta tags without any special behaviour to prioritize ones in the head, so I think it should be fine, but I can look at adding that if you want.

We did look a bit at using oEmbed in our app at some point, but I think we ran into some security issues around embedding external html or an iframe into the app which blocked using it. Right now, we just use OpenGraph for everything with some special handling for YouTube previews.

Thank you, I merged the request!