Skip to content

Commit

Permalink
MediaEmbed: updated Bandcamp
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Aug 3, 2024
1 parent 6c90871 commit c30ea71
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6893,6 +6893,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Scraping tests with data set #52
[x] Scraping tests with data set #53
[x] Scraping tests with data set #54
[x] Scraping tests with data set #55
[x] Scraping+rendering tests with data set #0
[x] Scraping+rendering tests with data set #1
[x] Scraping+rendering tests with data set #2
Expand Down
8 changes: 4 additions & 4 deletions src/Bundles/Fatdown.php

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Bundles/Forum.php

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/Bundles/MediaPack.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
'audioboom'=>['attributes'=>[],'example'=>'https://audioboom.com/posts/2493448-robert-patrick','extract'=>['!audioboo(?:\\.f|m\\.co)m/(?:boo|post)s/(?\'id\'\\d+)!'],'homepage'=>'https://audioboom.com/','host'=>['audioboo.fm','audioboom.com'],'iframe'=>['height'=>150,'max-width'=>700,'src'=>'//audioboom.com/posts/{@id}/embed/v3','width'=>'100%'],'name'=>'Audioboom','scrape'=>[],'tags'=>['podcasts']],
'audiomack'=>['attributes'=>[],'choose'=>['otherwise'=>['iframe'=>['height'=>252,'max-width'=>900,'src'=>'https://www.audiomack.com/embed/song/<xsl:choose><xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when><xsl:otherwise><xsl:value-of select="@artist"/>/<xsl:value-of select="@title"/></xsl:otherwise></xsl:choose>','width'=>'100%']],'when'=>['iframe'=>['height'=>400,'max-width'=>900,'src'=>'https://www.audiomack.com/embed/album/<xsl:choose><xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when><xsl:otherwise><xsl:value-of select="@artist"/>/<xsl:value-of select="@title"/></xsl:otherwise></xsl:choose>','width'=>'100%'],'test'=>'@mode=\'album\'']],'example'=>['https://www.audiomack.com/your-music-fix/song/jammin-kungs-remix-1','https://www.audiomack.com/chance-the-rapper/album/acid-rap'],'extract'=>['!audiomack\\.com/(?\'mode\'album|song)/(?\'artist\'[-\\w]+)/(?\'title\'[-\\w]+)!','!audiomack\\.com/(?\'artist\'[-\\w]+)/(?\'mode\'album|song)/(?\'title\'[-\\w]+)!'],'homepage'=>'https://www.audiomack.com/','host'=>['audiomack.com'],'name'=>'Audiomack','scrape'=>[],'tags'=>['music']],
'audius'=>['attributes'=>[],'example'=>['https://audius.co/feedbachmusic/album/lights-ii-62147','https://audius.co/audiusplaylists/playlist/culture-over-clout-56948','https://audius.co/manilakilla/chet-porter-the-longest-day-ever-manila-killa-edit'],'extract'=>[],'homepage'=>'https://audius.co/','host'=>['audius.co'],'iframe'=>['height'=>'<xsl:choose><xsl:when test="@track_id">12</xsl:when><xsl:otherwise>48</xsl:otherwise></xsl:choose>0','max-width'=>'<xsl:choose><xsl:when test="@track_id">9</xsl:when><xsl:otherwise>4</xsl:otherwise></xsl:choose>00','src'=>'https://audius.co/embed/<xsl:choose><xsl:when test="@track_id">track/<xsl:value-of select="@track_id"/>?flavor=compact</xsl:when><xsl:when test="@album_id">album/<xsl:value-of select="@album_id"/>?flavor=card</xsl:when><xsl:otherwise>playlist/<xsl:value-of select="@playlist_id"/>?flavor=card</xsl:otherwise></xsl:choose>','width'=>'100%'],'name'=>'Audius','scrape'=>[['extract'=>['!"id"\\s*:\\s*"(?\'track_id\'\\w+)"!'],'match'=>['@audius\\.co/(?!v1/)(?\'user\'[-.\\w]+)/(?!album/|playlist/)(?\'slug\'[%\\-.\\w]+)@'],'url'=>'https://discoveryprovider.audius.co/v1/resolve?app_name=s9e-textformatter&url=/{@user}/{@slug}'],['extract'=>['!"id"\\s*:\\s*"(?\'album_id\'\\w+)"!'],'match'=>['@audius\\.co/(?!v1/)(?\'user\'[-.\\w]+)/album/(?\'slug\'[%\\-.\\w]+)@'],'url'=>'https://discoveryprovider.audius.co/v1/resolve?app_name=s9e-textformatter&url=/{@user}/album/{@slug}'],['extract'=>['!"id"\\s*:\\s*"(?\'playlist_id\'\\w+)"!'],'match'=>['@audius\\.co/(?!v1/)(?\'user\'[-.\\w]+)/playlist/(?\'slug\'[%\\-.\\w]+)@'],'url'=>'https://discoveryprovider.audius.co/v1/resolve?app_name=s9e-textformatter&url=/{@user}/playlist/{@slug}']],'tags'=>['music']],
'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'=>['!"album_id":(?\'album_id\'\\d+)!','!"track_num":(?\'track_num\'\\d+)!','!/track=(?\'track_id\'\\d+)!'],'header'=>'User-agent: PHP (not Mozilla)','match'=>['!bandcamp\\.com/track/.!']]],'tags'=>['music']],
'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']],
'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']],
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/MediaEmbed/Configurator/sites/bandcamp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<scrape>
<header>User-agent: PHP (not Mozilla)</header>
<match>!bandcamp\.com/track/.!</match>
<extract>!"album_id":(?'album_id'\d+)!</extract>
<extract>!"track_num":(?'track_num'\d+)!</extract>
<extract>!(?:"|&amp;quot;)album_id(?:"|&amp;quot;):(?'album_id'\d+)!</extract>
<extract>!(?:"|&amp;quot;)track_num(?:"|&amp;quot;):(?'track_num'\d+)!</extract>
<extract>!/track=(?'track_id'\d+)!</extract>
</scrape>

Expand Down
10 changes: 10 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,16 @@ function ($configurator)
$configurator->MediaEmbed->add('audius');
}
],
[
'https://barefootheart.bandcamp.com/track/the-longing',
'<r><BANDCAMP album_id="1897537392" track_id="658250984" track_num="3">https://barefootheart.bandcamp.com/track/the-longing</BANDCAMP></r>',
[],
function ($configurator)
{
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
$configurator->MediaEmbed->add('bandcamp');
}
],
[
'https://decoding-the-gurus.captivate.fm/episode/sam-harris',
'<r><CAPTIVATE id="ec119d4f-acc4-464a-8976-1fafc3e2d23b">https://decoding-the-gurus.captivate.fm/episode/sam-harris</CAPTIVATE></r>',
Expand Down

0 comments on commit c30ea71

Please sign in to comment.