Skip to content

Commit

Permalink
MediaEmbed: updated Bluesky
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Nov 16, 2024
1 parent 922ca9e commit acb7c7f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 57 deletions.
8 changes: 6 additions & 2 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,7 @@ Configurable (s9e\TextFormatter\Tests\Configurator\Traits\Configurable)
[x] __get() throws a RuntimeException if the property does not exist
[x] __get($k) returns null if the property is null
[x] __set('foo', 'bar') calls setFoo('bar') if it exists
[ ] __set() can create new properties
[x] __set() can create new properties
[x] __set() can replace an instance of Foo with another instance of Foo
[x] __set() can replace an instance of Foo with an instance of FooPlus, which extends Foo
[x] __set() throws an exception if an instance of Foo would be replaced by an instance of Bar
Expand Down Expand Up @@ -7300,6 +7300,8 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests with data set #342
[x] Parsing tests with data set #343
[x] Parsing tests with data set #344
[x] Parsing tests with data set #345
[x] Parsing tests with data set #346
[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 @@ -7645,6 +7647,8 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests (JavaScript) with data set #342
[x] Parsing tests (JavaScript) with data set #343
[x] Parsing tests (JavaScript) with data set #344
[x] Parsing tests (JavaScript) with data set #345
[x] Parsing tests (JavaScript) with data set #346
[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 Expand Up @@ -7953,7 +7957,7 @@ Unformatted (s9e\TextFormatter\Tests\Renderers\Unformatted)
XSLT (s9e\TextFormatter\Tests\Renderers\XSLT)
[x] Is serializable
[x] Does not serialize the XSLTProcessor instance
[ ] Preserves other properties during serialization
[x] Preserves other properties during serialization
[x] setParameter() accepts values that contain both types of quotes but replaces ASCII character " with Unicode character 0xFF02 because of https://bugs.php.net/64137
[x] Does not output </embed> end tags
[x] Does not improperly replace single quotes inside attribute values
Expand Down
4 changes: 2 additions & 2 deletions src/Bundles/Forum.php

Large diffs are not rendered by default.

103 changes: 52 additions & 51 deletions src/Bundles/MediaPack.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
'bandcamp'=>['attributes'=>[],'example'=>['https://proleter.bandcamp.com/album/curses-from-past-times-ep','https://proleter.bandcamp.com/track/downtown-irony','https://therunons.bandcamp.com/track/still-feel'],'extract'=>[],'homepage'=>'https://bandcamp.com/','host'=>['bandcamp.com'],'iframe'=>['height'=>400,'src'=>'//bandcamp.com/EmbeddedPlayer/size=large/minimal=true/<xsl:choose><xsl:when test="@album_id">album=<xsl:value-of select="@album_id"/><xsl:if test="@track_num">/t=<xsl:value-of select="@track_num"/></xsl:if></xsl:when><xsl:otherwise>track=<xsl:value-of select="@track_id"/></xsl:otherwise></xsl:choose><xsl:if test="$MEDIAEMBED_THEME=\'dark\'">/bgcol=333333/linkcol=0f91ff</xsl:if>','width'=>400],'name'=>'Bandcamp','scrape'=>[['extract'=>['!/album=(?\'album_id\'\\d+)!'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['!bandcamp\\.com/album/.!']],['extract'=>['!(?:"|&quot;)album_id(?:"|&quot;):(?\'album_id\'\\d+)!','!(?:"|&quot;)track_num(?:"|&quot;):(?\'track_num\'\\d+)!','!/track=(?\'track_id\'\\d+)!'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['!bandcamp\\.com/track/.!']]],'tags'=>['music']],
'bbcnews'=>['attributes'=>[],'example'=>['https://www.bbc.com/news/video_and_audio/must_see/42847060/calls-to-clean-off-banksy-mural-in-hull','https://www.bbc.co.uk/news/av/world-africa-48141248/fifteen-year-old-nigerian-builds-small-scale-construction-machines','https://www.bbc.co.uk/news/av/embed/p0783sg7/48125671'],'extract'=>['@bbc\\.co(?:m|\\.uk)/news/(?:av|video_and_audio)/(?:\\w+-)+(?\'id\'\\d+)@','@bbc\\.co(?:m|\\.uk)/news/(?:av|video_and_audio)/embed/(?\'id\'\\w+/\\d+)@','@bbc\\.co(?:m|\\.uk)/news/(?:av|video_and_audio)/\\w+/(?\'id\'\\d+)@','@bbc\\.co(?:m|\\.uk)/news/av-embeds/(?\'id\'\\d+)@'],'homepage'=>'https://www.bbc.com/news/video_and_audio/headlines/','host'=>['bbc.co.uk','bbc.com'],'iframe'=>['src'=>'//www.bbc.com/news/av-embeds/<xsl:choose><xsl:when test="starts-with(@playlist,\'/news/\')"><xsl:choose><xsl:when test="contains(@playlist,\'-\')"><xsl:value-of select="substring-after(substring-after(translate(@playlist,\'A\',\'#\'),\'news/\'),\'-\')"/></xsl:when><xsl:otherwise><xsl:value-of select="substring-after(translate(@playlist,\'A\',\'/\'),\'/news/\')"/></xsl:otherwise></xsl:choose></xsl:when><xsl:when test="contains(@id,\'/\')"><xsl:value-of select="substring-after(@id,\'/\')"/></xsl:when><xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise></xsl:choose>'],'name'=>'BBC News','scrape'=>[],'tags'=>['news']],
'bitchute'=>['attributes'=>[],'example'=>'https://www.bitchute.com/video/y9AejeZ2vD0/','extract'=>['@bitchute\\.com/(?:embed|video)/(?\'id\'[-\\w]+)@'],'homepage'=>'https://www.bitchute.com/','host'=>['bitchute.com'],'iframe'=>['src'=>'https://www.bitchute.com/embed/{@id}/'],'name'=>'BitChute','oembed'=>['endpoint'=>'https://www.bitchute.com/oembed/','scheme'=>'https://www.bitchute.com/video/{@id}/'],'scrape'=>[],'tags'=>['videos']],
'bluesky'=>['attributes'=>['embedder'=>['filterChain'=>['#regexp(/^(?:[-\\w]*\\.)*bsky\\.app$/)'],'required'=>true],'url'=>['filterChain'=>['urldecode','#regexp(/^at:\\/\\/[.:\\w]+\\/[.\\w]+\\/\\w+$/)'],'required'=>true]],'example'=>['https://bsky.app/profile/bsky.app/post/3kkrqzuydho2v','https://bsky.app/profile/bnewbold.net/post/3kxjq2auebs2f'],'extract'=>['#https://(?\'embedder\'[.\\w]+)/oembed.*?url=(?\'url\'[\\w%.]+)#'],'helper'=>'s9e\\TextFormatter\\Plugins\\MediaEmbed\\Configurator\\SiteHelpers\\BlueskyHelper','homepage'=>'https://bsky.app/','host'=>['bsky.app'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>600,'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/bluesky.min.html#<xsl:value-of select="@url"/>#<xsl:value-of select="@embedder"/>','width'=>600],'name'=>'Bluesky','scrape'=>[['extract'=>['#https://(?\'embedder\'[.\\w]+)/oembed.*?url=(?\'url\'[\\w%.]+)#'],'match'=>['#/profile/[^/]+/post/.#']]],'source'=>'https://embed.bsky.app/','tags'=>['social']],
'bluesky'=>['attributes'=>['embedder'=>['filterChain'=>['#regexp(/^(?:[-\\w]*\\.)*bsky\\.app$/)'],'required'=>true],'url'=>['filterChain'=>['urldecode','#regexp(/^at:\\/\\/[.:\\w]+\\/[.\\w]+\\/\\w+$/)'],'required'=>true]],'example'=>['https://bsky.app/profile/bsky.app/post/3kkrqzuydho2v','https://bsky.app/profile/bnewbold.net/post/3kxjq2auebs2f'],'extract'=>['#^https://(?\'embedder\'[.\\w]+)/oembed.*?url=(?\'url\'[\\w%.]+)#'],'helper'=>'s9e\\TextFormatter\\Plugins\\MediaEmbed\\Configurator\\SiteHelpers\\BlueskyHelper','homepage'=>'https://bsky.app/','host'=>['bsky.app'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>600,'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/bluesky.min.html#<xsl:value-of select="@url"/>#<xsl:value-of select="@embedder"/>','width'=>600],'name'=>'Bluesky','scrape'=>[['extract'=>['#https://(?\'embedder\'[.\\w]+)/oembed.*?url=(?\'url\'[\\w%.]+)#'],'match'=>['#/profile/[^/]+/post/.#']]],'source'=>'https://embed.bsky.app/','tags'=>['social']],
'brightcove'=>['attributes'=>['bckey'=>['required'=>false]],'example'=>['https://players.brightcove.net/219646971/default_default/index.html?videoId=4815779906001','https://link.brightcove.com/services/player/bcpid4773906090001?bckey=AQ~~,AAAAAA0Xi_s~,r1xMuE8k5Nyz5IyYc0Hzhl5eZ5cEEvlm&bctid=4815779906001'],'extract'=>['@link\\.brightcove\\.com/services/player/bcpid(?\'bcpid\'\\d+).*?bckey=(?\'bckey\'[-,~\\w]+).*?bctid=(?\'bctid\'\\d+)@','@players\\.brightcove\\.net/(?\'bcpid\'\\d+)/.*?videoId=(?\'bctid\'\\d+)@'],'homepage'=>'https://www.brightcove.com/','host'=>['link.brightcove.com','players.brightcove.net'],'iframe'=>['src'=>'https://<xsl:choose><xsl:when test="@bckey">link.brightcove.com/services/player/bcpid<xsl:value-of select="@bcpid"/>?bckey=<xsl:value-of select="@bckey"/>&amp;bctid=<xsl:value-of select="@bctid"/>&amp;secureConnections=true&amp;secureHTMLConnections=true&amp;autoStart=false&amp;height=360&amp;width=640</xsl:when><xsl:otherwise>players.brightcove.net/<xsl:value-of select="@bcpid"/>/default_default/index.html?videoId=<xsl:value-of select="@bctid"/></xsl:otherwise></xsl:choose>'],'name'=>'Brightcove','scrape'=>[],'tags'=>['videos']],
'bunny'=>['attributes'=>[],'example'=>'https://video.bunnycdn.com/play/759/eb1c4f77-0cda-46be-b47d-1118ad7c2ffe','extract'=>['@/(?:embed|play)/(?\'video_library_id\'\\d+)/(?\'video_id\'[-\\w]+)@'],'homepage'=>'https://bunny.net/stream/','host'=>['iframe.mediadelivery.net','video.bunnycdn.com'],'iframe'=>['src'=>'https://iframe.mediadelivery.net/embed/{@video_library_id}/{@video_id}?autoplay=false'],'name'=>'Bunny Stream','scrape'=>[],'tags'=>['videos']],
'captivate'=>['attributes'=>[],'example'=>['https://player.captivate.fm/episode/03f47eef-4a8f-4616-8922-c77cb3d1edfa','https://decoding-the-gurus.captivate.fm/episode/sam-harris'],'extract'=>['@//player\\.captivate\\.fm/episode/(?\'id\'[-\\w]+)(?:\\?t=(?\'t\'\\d+))?@'],'homepage'=>'https://www.captivate.fm/','host'=>['captivate.fm'],'iframe'=>['height'=>200,'max-width'=>900,'src'=>'https://player.captivate.fm/episode/{@id}?t={@t}','style'=>['border-radius'=>'6px'],'width'=>'100%'],'name'=>'Captivate','scrape'=>[['extract'=>['@//player\\.captivate\\.fm/episode/(?\'id\'[-\\w]+)@'],'match'=>['@//(?!player\\.)[-\\w]+\\.captivate\\.fm/episode/.@']]],'tags'=>['podcasts']],
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/MediaEmbed/Configurator/sites/bluesky.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!-- https://atproto.com/specs/at-uri-scheme -->
<host>bsky.app</host>
<extract>#https://(?'embedder'[.\w]+)/oembed.*?url=(?'url'[\w%.]+)#</extract>
<extract>#^https://(?'embedder'[.\w]+)/oembed.*?url=(?'url'[\w%.]+)#</extract>
<scrape>
<match>#/profile/[^/]+/post/.#</match>
<extract>#https://(?'embedder'[.\w]+)/oembed.*?url=(?'url'[\w%.]+)#</extract>
Expand Down
18 changes: 18 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,24 @@ function ($configurator)
$configurator->MediaEmbed->add('bitchute');
}
],
[
'https://embed.bsky.app/oembed?format=json&url=at%3A%2F%2Fdid%3Aplc%3Az72i7hdynmk6r22z27h6tvur%2Fapp.bsky.feed.post%2F3kkrqzuydho2v',
'<r><BLUESKY embedder="embed.bsky.app" url="at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3kkrqzuydho2v">https://embed.bsky.app/oembed?format=json&amp;url=at%3A%2F%2Fdid%3Aplc%3Az72i7hdynmk6r22z27h6tvur%2Fapp.bsky.feed.post%2F3kkrqzuydho2v</BLUESKY></r>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('bluesky');
}
],
[
'http://embed.bsky.app/https://xembed.bsky.app/oembed?format=json&url=at%3A%2F%2Fdid%3Aplc%3Az72i7hdynmk6r22z27h6tvur%2Fapp.bsky.feed.post%2F3kkrqzuydho2v',
'<t>http://embed.bsky.app/https://xembed.bsky.app/oembed?format=json&amp;url=at%3A%2F%2Fdid%3Aplc%3Az72i7hdynmk6r22z27h6tvur%2Fapp.bsky.feed.post%2F3kkrqzuydho2v</t>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('bluesky');
}
],
[
'https://link.brightcove.com/services/player/bcpid4773906090001?bckey=AQ~~,AAAAAA0Xi_s~,r1xMuE8k5Nyz5IyYc0Hzhl5eZ5cEEvlm&bctid=4815779906001',
'<r><BRIGHTCOVE bckey="AQ~~,AAAAAA0Xi_s~,r1xMuE8k5Nyz5IyYc0Hzhl5eZ5cEEvlm" bcpid="4773906090001" bctid="4815779906001">https://link.brightcove.com/services/player/bcpid4773906090001?bckey=AQ~~,AAAAAA0Xi_s~,r1xMuE8k5Nyz5IyYc0Hzhl5eZ5cEEvlm&amp;bctid=4815779906001</BRIGHTCOVE></r>',
Expand Down

0 comments on commit acb7c7f

Please sign in to comment.