Skip to content

Commit

Permalink
MediaEmbed: updated Facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Sep 9, 2024
1 parent 15d62a2 commit 22c5386
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7290,6 +7290,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests with data set #339
[x] Parsing tests with data set #340
[x] Parsing tests with data set #341
[x] Parsing tests with data set #342
[x] Parsing tests (JavaScript) with data set #0
[x] Parsing tests (JavaScript) with data set #1
[x] Parsing tests (JavaScript) with data set #2
Expand Down Expand Up @@ -7632,6 +7633,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests (JavaScript) with data set #339
[x] Parsing tests (JavaScript) with data set #340
[x] Parsing tests (JavaScript) with data set #341
[x] Parsing tests (JavaScript) with data set #342
[x] Parsing+rendering tests with data set #0
[x] Parsing+rendering tests with data set #1
[x] Parsing+rendering tests with data set #2
Expand Down
4 changes: 2 additions & 2 deletions src/Bundles/Fatdown.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Bundles/Forum.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Bundles/MediaPack.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
'dumpert'=>['attributes'=>[],'example'=>'https://www.dumpert.nl/item/6622577_4652b140','extract'=>['!dumpert\\.nl/(?:item|mediabase)/(?\'id\'\\d+[/_]\\w+)!'],'homepage'=>'https://www.dumpert.nl/','host'=>['dumpert.nl'],'iframe'=>['src'=>'//www.dumpert.nl/embed/{translate(@id,\'/\',\'_\')}'],'name'=>'dumpert','scrape'=>[],'tags'=>['.nl','entertainment']],
'eighttracks'=>['attributes'=>[],'example'=>['https://8tracks.com/lovinq/headphones-in-world-out','https://8tracks.com/lovinq/4982023'],'extract'=>['!8tracks\\.com/[-\\w]+/(?\'id\'\\d+)(?=#|$)!'],'homepage'=>'https://8tracks.com/','host'=>['8tracks.com'],'iframe'=>['height'=>400,'src'=>'//8tracks.com/mixes/{@id}/player_v3_universal','width'=>400],'name'=>'8tracks','scrape'=>[['extract'=>['!eighttracks://mix/(?\'id\'\\d+)!'],'match'=>['!8tracks\\.com/[-\\w]+/\\D!']]],'tags'=>['music']],
'espn'=>['attributes'=>[],'example'=>['https://www.espn.com/video/clip?id=17474659','https://www.espn.com/espnw/video/13887284/kyrgios-angry-code-violation-almost-hitting-ref','https://broadband.espn.go.com/video/clip?id=17481969'],'extract'=>['#video/(?:clip(?:\\?id=|/_/id/))?(?\'id\'\\d+)#'],'homepage'=>'https://www.espn.com/','host'=>['espn.com','espn.go.com'],'iframe'=>['src'=>'//www.espn.com/core/video/iframe?id={@id}'],'name'=>'ESPN','scrape'=>[],'tags'=>['sports']],
'facebook'=>['amp'=>['custom-element'=>'amp-facebook','src'=>'https://cdn.ampproject.org/v0/amp-facebook-0.1.js','template'=>'<amp-facebook layout="responsive" width="640" height="360"><xsl:if test="starts-with(@type,\'v\')"><xsl:attribute name="data-embed-as">video</xsl:attribute></xsl:if><xsl:attribute name="data-href">https://www.facebook.com/<xsl:choose><xsl:when test="@user"><xsl:value-of select="@user"/></xsl:when><xsl:otherwise>user</xsl:otherwise></xsl:choose>/<xsl:choose><xsl:when test="starts-with(@type,\'v\')">video</xsl:when><xsl:otherwise>post</xsl:otherwise></xsl:choose>s/<xsl:value-of select="@id"/></xsl:attribute></amp-facebook>'],'attributes'=>[],'example'=>['https://www.facebook.com/MetaforDevelopers/posts/451016937058647','https://www.facebook.com/watch/?v=224353158889229','https://fb.watch/3zYsXdnxjf/','https://www.facebook.com/reel/873906321076441'],'extract'=>['@facebook\\.com/.*?(?:fbid=|/permalink/|\\?v=)(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])(?:ost|ideo)s?/(?:[-\\w%]+/)?(?\'id\'\\d+)\\b@','@facebook\\.com/video/(?=post|video)(?\'type\'[pv])@','@facebook\\.com/events/(?\'id\'\\d+)\\b(?!/permalink)@','@facebook\\.com/watch/\\?(?\'type\'[pv])=@','@facebook.com/groups/[^/]*/(?\'type\'p)osts/(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/posts/pfbid(?\'pfbid\'\\w+)@','@facebook\\.com/permalink\\.php\\?story_fbid=(?:(?\'id\'\\d+)|pfbid(?\'pfbid\'\\w+))&id=(?\'page_id\'\\d+)@','@facebook\\.com/(?\'type\'r)eel/(?\'id\'\\d+)@'],'homepage'=>'https://www.facebook.com/','host'=>['facebook.com','fb.watch'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+\'px\';this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/facebook.min.html#<xsl:choose><xsl:when test="@user"><xsl:value-of select="@user"/>/<xsl:choose><xsl:when test="@type=\'r\'or@type=\'v\'">video</xsl:when><xsl:otherwise>post</xsl:otherwise></xsl:choose>s/<xsl:choose><xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when><xsl:otherwise>pfbid<xsl:value-of select="@pfbid"/></xsl:otherwise></xsl:choose></xsl:when><xsl:when test="@id"><xsl:value-of select="@type"/><xsl:value-of select="@id"/></xsl:when><xsl:otherwise>pfbid<xsl:value-of select="@pfbid"/></xsl:otherwise></xsl:choose>'],'name'=>'Facebook','scrape'=>[['extract'=>['@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])\\w+/(?\'id\'\\d+)(?!\\w)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/[.\\w]+/posts/pfbid@'],'url'=>'https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2F{@user}%2Fposts%2Fpfbid{@pfbid}'],['extract'=>['@story_fbid=(?\'id\'\\d+)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/permalink\\.php\\?story_fbid=pfbid(?\'pfbid\'\\w+)&id=(?\'page_id\'\\d+)@'],'url'=>'https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fpermalink.php%3Fstory_fbid%3Dpfbid{@pfbid}%26id%3D{@page_id}'],['extract'=>['@facebook\\.com/watch/\\?(?\'type\'v)=(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'v)ideos/(?\'id\'\\d+)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@fb\\.watch/.@']],['extract'=>['@facebook\\.com/\\w+/(?\'user\'[.\\w]+)/permalink/(?\'id\'\\d+)(?!\\w)@','@og:url[^>]+facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])(?:ost|ideo)s?/(?:[-\\w%]+/)?(?\'id\'\\d+)\\b@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/share/[pv]/\\w@']]],'tags'=>['social'],'tracking_policy'=>'https://www.facebook.com/help/1896641480634370'],
'facebook'=>['amp'=>['custom-element'=>'amp-facebook','src'=>'https://cdn.ampproject.org/v0/amp-facebook-0.1.js','template'=>'<amp-facebook layout="responsive" width="640" height="360"><xsl:if test="starts-with(@type,\'v\')"><xsl:attribute name="data-embed-as">video</xsl:attribute></xsl:if><xsl:attribute name="data-href">https://www.facebook.com/<xsl:choose><xsl:when test="@user"><xsl:value-of select="@user"/></xsl:when><xsl:otherwise>user</xsl:otherwise></xsl:choose>/<xsl:choose><xsl:when test="starts-with(@type,\'v\')">video</xsl:when><xsl:otherwise>post</xsl:otherwise></xsl:choose>s/<xsl:value-of select="@id"/></xsl:attribute></amp-facebook>'],'attributes'=>[],'example'=>['https://www.facebook.com/MetaforDevelopers/posts/451016937058647','https://www.facebook.com/watch/?v=224353158889229','https://fb.watch/3zYsXdnxjf/','https://www.facebook.com/reel/873906321076441'],'extract'=>['@facebook\\.com/.*?(?:fbid=|/permalink/|\\?v=)(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])(?:ost|ideo)s?/(?:[-%.\\w]+/)?(?\'id\'\\d+)\\b@','@facebook\\.com/video/(?=post|video)(?\'type\'[pv])@','@facebook\\.com/events/(?\'id\'\\d+)\\b(?!/permalink)@','@facebook\\.com/watch/\\?(?\'type\'[pv])=@','@facebook.com/groups/[^/]*/(?\'type\'p)osts/(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/posts/pfbid(?\'pfbid\'\\w+)@','@facebook\\.com/permalink\\.php\\?story_fbid=(?:(?\'id\'\\d+)|pfbid(?\'pfbid\'\\w+))&id=(?\'page_id\'\\d+)@','@facebook\\.com/(?\'type\'r)eel/(?\'id\'\\d+)@'],'homepage'=>'https://www.facebook.com/','host'=>['facebook.com','fb.watch'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+\'px\';this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/facebook.min.html#<xsl:choose><xsl:when test="@user"><xsl:value-of select="@user"/>/<xsl:choose><xsl:when test="@type=\'r\'or@type=\'v\'">video</xsl:when><xsl:otherwise>post</xsl:otherwise></xsl:choose>s/<xsl:choose><xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when><xsl:otherwise>pfbid<xsl:value-of select="@pfbid"/></xsl:otherwise></xsl:choose></xsl:when><xsl:when test="@id"><xsl:value-of select="@type"/><xsl:value-of select="@id"/></xsl:when><xsl:otherwise>pfbid<xsl:value-of select="@pfbid"/></xsl:otherwise></xsl:choose>'],'name'=>'Facebook','scrape'=>[['extract'=>['@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])\\w+/(?\'id\'\\d+)(?!\\w)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/[.\\w]+/posts/pfbid@'],'url'=>'https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2F{@user}%2Fposts%2Fpfbid{@pfbid}'],['extract'=>['@story_fbid=(?\'id\'\\d+)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/permalink\\.php\\?story_fbid=pfbid(?\'pfbid\'\\w+)&id=(?\'page_id\'\\d+)@'],'url'=>'https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fpermalink.php%3Fstory_fbid%3Dpfbid{@pfbid}%26id%3D{@page_id}'],['extract'=>['@facebook\\.com/watch/\\?(?\'type\'v)=(?\'id\'\\d+)@','@facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'v)ideos/(?\'id\'\\d+)@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@fb\\.watch/.@']],['extract'=>['@facebook\\.com/\\w+/(?\'user\'[.\\w]+)/permalink/(?\'id\'\\d+)(?!\\w)@','@og:url[^>]+facebook\\.com/(?\'user\'[.\\w]+)/(?\'type\'[pv])(?:ost|ideo)s?/(?:[-\\w%]+/)?(?\'id\'\\d+)\\b@'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['@facebook\\.com/share/[pv]/\\w@']]],'tags'=>['social'],'tracking_policy'=>'https://www.facebook.com/help/1896641480634370'],
'falstad'=>['attributes'=>[],'example'=>'https://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+10.20027730826997+50+5+43+v+176+272+256+144+0+0+40+5+0+0+0.5+w+176+272+336+272+0+r+336+272+256+144+0+1000','extract'=>['!falstad\\.com/circuit/circuitjs\\.html\\?c(?:ct=(?\'cct\'[^&]+)|tz=(?\'ctz\'[-+=\\w]+))!'],'homepage'=>'https://www.falstad.com/circuit/circuitjs.html','host'=>['falstad.com'],'iframe'=>['height'=>500,'src'=>'https://www.falstad.com/circuit/circuitjs.html?running=false&amp;c<xsl:choose><xsl:when test="@cct">ct=<xsl:value-of select="@cct"/></xsl:when><xsl:otherwise>tz=<xsl:value-of select="@ctz"/></xsl:otherwise></xsl:choose>','style'=>['max-height'=>'90vh'],'width'=>'100%'],'name'=>'Falstad Circuit Simulator','scrape'=>[]],
'flickr'=>['attributes'=>[],'example'=>['https://www.flickr.com/photos/8757881@N04/2971804544/lightbox/','https://flic.kr/8757881@N04/2971804544','https://flic.kr/p/5wBgXo'],'extract'=>['@flickr\\.com/photos/[^/]+/(?\'id\'\\d+)@','@flic\\.kr/(?!p/)[^/]+/(?\'id\'\\d+)@'],'homepage'=>'https://www.flickr.com/','host'=>['flic.kr','flickr.com'],'iframe'=>['height'=>500,'src'=>'https://www.flickr.com/photos/_/{@id}/player/','width'=>500],'name'=>'Flickr','scrape'=>[['extract'=>['@flickr\\.com/photos/[^/]+/(?\'id\'\\d+)@'],'match'=>['@flic\\.kr/p/(?\'short\'\\w+)@'],'url'=>'https://www.flickr.com/photo.gne?rb=1&short={@short}']],'tags'=>['images']],
'foxnews'=>['attributes'=>[],'example'=>'https://video.foxnews.com/v/3592758613001/reddit-helps-fund-homemade-hot-sauce-venture/','extract'=>['!video\\.foxnews\\.com/v/(?\'id\'\\d+)!'],'homepage'=>'https://www.foxnews.com/','host'=>['video.foxnews.com'],'iframe'=>['src'=>'//video.foxnews.com/v/video-embed.html?video_id={@id}'],'name'=>'Fox News','scrape'=>[],'tags'=>['news']],
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/MediaEmbed/Configurator/sites/facebook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<host>facebook.com</host>
<host>fb.watch</host>
<extract>@facebook\.com/.*?(?:fbid=|/permalink/|\?v=)(?'id'\d+)@</extract>
<extract>@facebook\.com/(?'user'[.\w]+)/(?'type'[pv])(?:ost|ideo)s?/(?:[-\w%]+/)?(?'id'\d+)\b@</extract>
<extract>@facebook\.com/(?'user'[.\w]+)/(?'type'[pv])(?:ost|ideo)s?/(?:[-%.\w]+/)?(?'id'\d+)\b@</extract>
<extract>@facebook\.com/video/(?=post|video)(?'type'[pv])@</extract>
<extract>@facebook\.com/events/(?'id'\d+)\b(?!/permalink)@</extract>
<extract>@facebook\.com/watch/\?(?'type'[pv])=@</extract>
Expand Down
9 changes: 9 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,15 @@ function ($configurator)
$configurator->MediaEmbed->add('facebook');
}
],
[
'https://www.facebook.com/greg.insco/videos/vb.21404288/10102275300870825/',
'<r><FACEBOOK id="10102275300870825" type="v" user="greg.insco">https://www.facebook.com/greg.insco/videos/vb.21404288/10102275300870825/</FACEBOOK></r>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('facebook');
}
],
[
'https://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+1.3241202019156522+43+5+50%0AR+736+368+736+304+0+0+40+3.3+0+0+0.5%0A162+736+368+736+416+2+default-led+1+0+0+0.01%0At+688+432+736+432+0+1+-0.2745603107888651+0.7370392451696097+100%0At+688+464+736+464+0+1+0.548427436901697+0.7373314588213099+100%0As+672+416+672+432+0+0+false%0As+672+448+672+464+0+0+false%0Aw+672+448+656+448+0%0Aw+672+416+656+416+0%0Aw+656+416+656+368+0%0Aw+656+368+736+368+0%0Aw+656+448+624+448+0%0Aw+624+448+624+368+0%0Aw+624+368+656+368+0%0Aw+736+480+736+528+0%0Ag+736+528+736+560+0%0Ar+688+432+672+432+0+1000%0Ar+688+464+672+464+0+1000%0Aw+736+416+800+416+0%0A162+800+416+880+416+2+default-led+1+0+0+0.01%0Ag+880+416+912+416+0%0A',
'<r><FALSTAD cct="$+1+0.000005+1.3241202019156522+43+5+50%0AR+736+368+736+304+0+0+40+3.3+0+0+0.5%0A162+736+368+736+416+2+default-led+1+0+0+0.01%0At+688+432+736+432+0+1+-0.2745603107888651+0.7370392451696097+100%0At+688+464+736+464+0+1+0.548427436901697+0.7373314588213099+100%0As+672+416+672+432+0+0+false%0As+672+448+672+464+0+0+false%0Aw+672+448+656+448+0%0Aw+672+416+656+416+0%0Aw+656+416+656+368+0%0Aw+656+368+736+368+0%0Aw+656+448+624+448+0%0Aw+624+448+624+368+0%0Aw+624+368+656+368+0%0Aw+736+480+736+528+0%0Ag+736+528+736+560+0%0Ar+688+432+672+432+0+1000%0Ar+688+464+672+464+0+1000%0Aw+736+416+800+416+0%0A162+800+416+880+416+2+default-led+1+0+0+0.01%0Ag+880+416+912+416+0%0A">https://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+1.3241202019156522+43+5+50%0AR+736+368+736+304+0+0+40+3.3+0+0+0.5%0A162+736+368+736+416+2+default-led+1+0+0+0.01%0At+688+432+736+432+0+1+-0.2745603107888651+0.7370392451696097+100%0At+688+464+736+464+0+1+0.548427436901697+0.7373314588213099+100%0As+672+416+672+432+0+0+false%0As+672+448+672+464+0+0+false%0Aw+672+448+656+448+0%0Aw+672+416+656+416+0%0Aw+656+416+656+368+0%0Aw+656+368+736+368+0%0Aw+656+448+624+448+0%0Aw+624+448+624+368+0%0Aw+624+368+656+368+0%0Aw+736+480+736+528+0%0Ag+736+528+736+560+0%0Ar+688+432+672+432+0+1000%0Ar+688+464+672+464+0+1000%0Aw+736+416+800+416+0%0A162+800+416+880+416+2+default-led+1+0+0+0.01%0Ag+880+416+912+416+0%0A</FALSTAD></r>',
Expand Down

0 comments on commit 22c5386

Please sign in to comment.