mozilla / page-metadata-parser

DEPRECATED - A Javascript library for parsing metadata on a web page.
https://www.npmjs.com/package/page-metadata-parser
Mozilla Public License 2.0
271 stars 42 forks source link

Add video URL #19

Closed jaredlockhart closed 2 years ago

jaredlockhart commented 8 years ago

Pull out a video player URL

pdehaan commented 8 years ago

Just spotted in https://vimeo.com/180763356 source:

<meta property="og:type" content="video">
...
<meta property="og:video:url" content="https://player.vimeo.com/video/180763356?autoplay=1">
<meta property="og:video:secure_url" content="https://player.vimeo.com/video/180763356?autoplay=1">
<meta property="og:video:type" content="text/html">
<meta property="og:video:width" content="1280">
<meta property="og:video:height" content="720">

<meta property="og:video:url" content="https://vimeo.com/moogaloop.swf?clip_id=180763356&amp;autoplay=1">
<meta property="og:video:secure_url" content="https://vimeo.com/moogaloop.swf?clip_id=180763356&amp;autoplay=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="1280">
<meta property="og:video:height" content="720">

If we blindly pull some/all/first og:video:url or og:video:secure_url tags, we could get a crummy "application/x-shockwave-flash" SWF video.


Per http://ogp.me/#structured:

The og:video tag has the identical tags as og:image. Here is an example:

<meta property="og:video" content="http://example.com/movie.swf" />
<meta property="og:video:secure_url" content="https://secure.example.com/movie.swf" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:video:width" content="400" />
<meta property="og:video:height" content="300" />

Where og:image:type is "A MIME type for this image."

Not sure how easy it'd be to use Fathom to extract the video metadata and then filter out anything with a mime type of "application/x-shockwave-flash" since a bunch of these properties are duplicated and seem to be in specific groups/orders.

pdehaan commented 8 years ago

Similarly, here's a YouTube example of duplicated HTML/SWF videos: https://www.youtube.com/watch?v=tja9cTzgq5k

<meta property="og:type" content="video">

<meta property="og:video:url" content="https://www.youtube.com/embed/tja9cTzgq5k">
<meta property="og:video:secure_url" content="https://www.youtube.com/embed/tja9cTzgq5k">
<meta property="og:video:type" content="text/html">
<meta property="og:video:width" content="480">
<meta property="og:video:height" content="360">

<meta property="og:video:url" content="http://www.youtube.com/v/tja9cTzgq5k?version=3&amp;autohide=1">
<meta property="og:video:secure_url" content="https://www.youtube.com/v/tja9cTzgq5k?version=3&amp;autohide=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="480">
<meta property="og:video:height" content="360">