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

Issue 238: Add Support for Bluesky #239

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/Plugins/MediaEmbed/Sites.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<td><code>bitchute</code></td>
<td>https://www.bitchute.com/video/y9AejeZ2vD0/</td>
</tr>
<tr title="Bluesky" id="bluesky">
<td><code>bluesky</code></td>
<td>https://bsky.app/profile/jamesgunn.bsky.social/post/3l6kscjixz22q</td>
</tr>
<tr title="Brightcove" id="brightcove">
<td><code>brightcove</code></td>
<td>https://players.brightcove.net/219646971/default_default/index.html?videoId=4815779906001<br/>https://link.brightcove.com/services/player/bcpid4773906090001?bckey=AQ~~,AAAAAA0Xi_s~,r1xMuE8k5Nyz5IyYc0Hzhl5eZ5cEEvlm&amp;bctid=4815779906001</td>
Expand Down
173 changes: 86 additions & 87 deletions src/Bundles/MediaPack.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Bundles/MediaPack/Renderer.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +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'=>[],'example'=>['https://bsky.app/profile/jamesgunn.bsky.social/post/3l6kscjixz22q'],'extract'=>['!bsky\.app/profile/(?\'name\'[A-Za-z0-9.]+)/post/(?\'id\'\\w+)!'],'homepage'=>'https://bsky.app/','host'=>['bsky.app'],'iframe'=>['height'=>350,'src'=>'https://embed.bsky.app/embed/did:{@did}/app.bsky.feed.post/{@id}','width'=>550],'name'=>'Bluesky','scrape'=>[['extract'=>['!"did":\s*"did:(?\'did\'[a-zA-Z0-9._:%-]+)"!'],'match'=>['//'],'url'=>'https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor={@name}']],'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
15 changes: 15 additions & 0 deletions src/Plugins/MediaEmbed/Configurator/sites/bluesky.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<site name="Bluesky" homepage="https://bsky.app/">
<example>https://bsky.app/profile/jamesgunn.bsky.social/post/3l6kscjixz22q</example>

<oembed endpoint="https://embed.bsky.app/oembed"
scheme="https://bsky.app/profile/{@name}/post/{@id}"/>

<tags><tag>social</tag></tags>

<host>bsky.app</host>
<extract>!bsky\.app/profile/(?'name'[A-Za-z0-9.]+)/post/(?'id'\w+)!</extract>
<scrape url="https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor={@name}">
<extract>!"did":\s*"did:(?<did>[a-zA-Z0-9._:%-]+)"!</extract>
</scrape>
<iframe width="550" height="350" src="https://embed.bsky.app/embed/did:{@did}/app.bsky.feed.post/{@id}"/>
</site>
9 changes: 9 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,15 @@ function ($configurator)
$configurator->MediaEmbed->add('bitchute');
}
],
[
'https://bsky.app/profile/jamesgunn.bsky.social/post/3l6kscjixz22q',
'<r><BLUESKY name="jamesgunn.bsky.social" id="3l6kscjixz22q">https://bsky.app/profile/jamesgunn.bsky.social/post/3l6kscjixz22q</BLUESKY></r>',
[],
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