Skip to content

Commit 309108d

Browse files
committed
MediaEmbed: updated Instagram
1 parent 4d84cce commit 309108d

File tree

6 files changed

+79
-63
lines changed

6 files changed

+79
-63
lines changed

docs/testdox.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6904,6 +6904,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
69046904
[x] Scraping tests with data set #57
69056905
[x] Scraping tests with data set #58
69066906
[x] Scraping tests with data set #59
6907+
[x] Scraping tests with data set #60
69076908
[x] Scraping+rendering tests with data set #0
69086909
[x] Scraping+rendering tests with data set #1
69096910
[x] Scraping+rendering tests with data set #2

src/Bundles/Forum.php

Lines changed: 18 additions & 17 deletions
Large diffs are not rendered by default.

src/Bundles/MediaPack.php

Lines changed: 43 additions & 43 deletions
Large diffs are not rendered by default.

src/Plugins/MediaEmbed/Configurator/Collections/CachedDefinitionCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
6060
'imdb'=>['attributes'=>[],'example'=>['https://www.imdb.com/video/imdb/vi2482677785/','https://www.imdb.com/title/tt2294629/videoplayer/vi2482677785'],'extract'=>[],'homepage'=>'https://www.imdb.com/trailers/','host'=>['imdb.com'],'iframe'=>['src'=>'https://www.imdb.com/video/embed/vi{@id}/?autoplay=false&width=640'],'name'=>'IMDb trailers','scrape'=>[['extract'=>['!imdb\\.com/[/\\w]+?/vi(?\'id\'\\d+)!'],'match'=>['!imdb\\.com/[/\\w]+?/vi(?\'id\'\\d+)!'],'url'=>'https://www.imdb.com/video/embed/vi{@id}/']],'tags'=>['movies']],
6161
'imgur'=>['amp'=>['custom-element'=>'amp-imgur','src'=>'https://cdn.ampproject.org/v0/amp-imgur-0.1.js','template'=>'<amp-imgur layout="responsive" width="542" height="400" data-imgur-id="{@id}"/>'],'attributes'=>[],'example'=>['https://imgur.com/AsQ0K3P','https://imgur.com/a/9UGCL','https://imgur.com/gallery/9UGCL','https://i.imgur.com/u7Yo0Vy.gifv','https://i.imgur.com/UO1UrIx.mp4'],'extract'=>['@imgur\\.com/(?\'id\'a/\\w+)@','@i\\.imgur\\.com/(?\'id\'\\w{5,7})[lms]?\\.@','@imgur\\.com/(?!upload\\b)(?\'id\'\\w+)(?![\\w./])@'],'homepage'=>'https://imgur.com/','host'=>['imgur.com'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>400,'onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>{{let s=this.style,d=e.data.split(\' \');s.height=d[0]+\'px\';s.width=d[1]+\'px\'}};this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/imgur.min.html#<xsl:if test="@type=\'album\'">a/</xsl:if><xsl:value-of select="@id"/>','width'=>542],'name'=>'Imgur','oembed'=>['endpoint'=>'https://api.imgur.com/oembed.json','scheme'=>'https://imgur.com/{@id}'],'scrape'=>[['extract'=>['@data-id="(?\'id\'[\\w/]+)"@'],'match'=>['@imgur\\.com/(?![art]/|user/)(?\'path\'(?:gallery/)?\\w+)(?![\\w.])@'],'url'=>'https://api.imgur.com/oembed.xml?url=/{@path}']],'tags'=>['images']],
6262
'indiegogo'=>['attributes'=>[],'example'=>'https://www.indiegogo.com/projects/gameheart-redesigned','extract'=>['!indiegogo\\.com/projects/(?\'id\'[-\\w]+)!'],'homepage'=>'https://www.indiegogo.com/','host'=>['indiegogo.com'],'iframe'=>['height'=>445,'src'=>'//www.indiegogo.com/project/{@id}/embedded','width'=>222],'name'=>'Indiegogo','scrape'=>[],'tags'=>['fundraising']],
63-
'instagram'=>['amp'=>['custom-element'=>'amp-instagram','src'=>'https://cdn.ampproject.org/v0/amp-instagram-0.1.js','template'=>'<amp-instagram layout="responsive" width="540" height="540" data-captioned="" data-shortcode="{@id}"/>'],'attributes'=>[],'example'=>['https://instagram.com/p/gbGaIXBQbn/','https://www.instagram.com/tv/BkQjCfsBIzi/'],'extract'=>['!instagram\\.com/(?:[.\\w]+/)?(?:p|reel|tv)/(?\'id\'[-\\w]+)!'],'homepage'=>'https://instagram.com/','host'=>['instagram.com'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>542,'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/instagram.min.html#<xsl:value-of select="@id"/><xsl:if test="$MEDIAEMBED_THEME">#theme=<xsl:value-of select="$MEDIAEMBED_THEME"/></xsl:if>','width'=>542],'name'=>'Instagram','scrape'=>[],'source'=>'http://help.instagram.com/513918941996087','tags'=>['social'],'tracking_policy'=>'https://help.instagram.com/1896641480634370'],
63+
'instagram'=>['amp'=>['custom-element'=>'amp-instagram','src'=>'https://cdn.ampproject.org/v0/amp-instagram-0.1.js','template'=>'<amp-instagram layout="responsive" width="540" height="540" data-captioned="" data-shortcode="{@id}"/>'],'attributes'=>[],'example'=>['https://instagram.com/p/gbGaIXBQbn/','https://www.instagram.com/tv/BkQjCfsBIzi/'],'extract'=>['#instagram\\.com/(?!share/)(?:[.\\w]+/)?(?:p|reel|tv)/(?\'id\'[-\\w]+)#'],'homepage'=>'https://instagram.com/','host'=>['instagram.com'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>542,'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/instagram.min.html#<xsl:value-of select="@id"/><xsl:if test="$MEDIAEMBED_THEME">#theme=<xsl:value-of select="$MEDIAEMBED_THEME"/></xsl:if>','width'=>542],'name'=>'Instagram','scrape'=>[['extract'=>['#instagram\\.com/(?:p|reel|tv)/(?\'id\'[-\\w]+)#'],'header'=>'User-agent: PHP','match'=>['#instagram.com/share/\\w+/\\w#']]],'source'=>'http://help.instagram.com/513918941996087','tags'=>['social'],'tracking_policy'=>'https://help.instagram.com/1896641480634370'],
6464
'internetarchive'=>['attributes'=>['height'=>['defaultValue'=>360,'filterChain'=>['#uint']],'id'=>['filterChain'=>['htmlspecialchars_decode']],'width'=>['defaultValue'=>640,'filterChain'=>['#uint']]],'choose'=>['otherwise'=>['iframe'=>['height'=>'{@height}','src'=>'https://archive.org/embed/{@id}','width'=>'{@width}']],'when'=>['iframe'=>['height'=>170,'max-width'=>640,'src'=>'https://archive.org/embed/{@id}&list_height=150','width'=>'100%'],'test'=>'contains(@id,\'playlist=1\')']],'example'=>['https://archive.org/details/BillGate99','https://archive.org/details/DFTS2014-05-30'],'extract'=>[],'homepage'=>'https://archive.org/','host'=>['archive.org'],'name'=>'Internet Archive','scrape'=>[['extract'=>['!meta property="twitter:player" content="https://archive.org/embed/(?\'id\'[^/"]+)!','!meta property="og:video:width" content="(?\'width\'\\d+)!','!meta property="og:video:height" content="(?\'height\'\\d+)!'],'match'=>['!archive\\.org/(?:details|embed)/!']]]],
6565
'izlesene'=>['amp'=>['custom-element'=>'amp-izlesene','src'=>'https://cdn.ampproject.org/v0/amp-izlesene-0.1.js','template'=>'<amp-izlesene layout="responsive" width="640" height="360" data-videoid="{@id}"/>'],'attributes'=>[],'example'=>'https://www.izlesene.com/video/kardan-adamin-salincak-keyfi/10553555','extract'=>['!izlesene\\.com/video/[-\\w]+/(?\'id\'\\d+)!'],'homepage'=>'https://www.izlesene.com/','host'=>['izlesene.com'],'iframe'=>['src'=>'//www.izlesene.com/embedplayer/{@id}?autoplay=0'],'name'=>'İzlesene','scrape'=>[],'tags'=>['.tr']],
6666
'jsfiddle'=>['attributes'=>[],'example'=>'https://jsfiddle.net/1v03Lqnu/','extract'=>['@jsfiddle.net/(?:(?\'user\'\\w+)/)?(?!\\d+\\b|embedded\\b|show\\b)(?\'id\'\\w+)\\b(?:/(?\'revision\'\\d+)\\b)?@'],'homepage'=>'https://jsfiddle.net/','host'=>['jsfiddle.net'],'iframe'=>['height'=>400,'src'=>'//jsfiddle.net/<xsl:value-of select="@id"/>/<xsl:value-of select="@revision"/>/embedded/<xsl:if test="$MEDIAEMBED_THEME=\'light\'or$MEDIAEMBED_THEME=\'dark\'"><xsl:value-of select="$MEDIAEMBED_THEME"/>/</xsl:if>','width'=>'100%'],'name'=>'JSFiddle','scrape'=>[],'tags'=>['programming']],

src/Plugins/MediaEmbed/Configurator/sites/instagram.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
<tags><tag>social</tag></tags>
77

88
<host>instagram.com</host>
9-
<extract>!instagram\.com/(?:[.\w]+/)?(?:p|reel|tv)/(?'id'[-\w]+)!</extract>
9+
<extract>#instagram\.com/(?!share/)(?:[.\w]+/)?(?:p|reel|tv)/(?'id'[-\w]+)#</extract>
10+
<scrape>
11+
<header>User-agent: PHP</header>
12+
<match>#instagram.com/share/\w+/\w#</match>
13+
<extract>#instagram\.com/(?:p|reel|tv)/(?'id'[-\w]+)#</extract>
14+
</scrape>
1015
<iframe width="542" height="542" onload="let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])" data-s9e-livepreview-ignore-attrs="style">
1116
<src><![CDATA[
1217
<xsl:text>https://s9e.github.io/iframe/2/instagram.min.html#</xsl:text>

tests/Plugins/MediaEmbed/ParserTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,16 @@ function ($configurator)
861861
$configurator->MediaEmbed->add('imgur');
862862
}
863863
],
864+
[
865+
'https://www.instagram.com/share/p/BAtwjtaqSm',
866+
'<r><INSTAGRAM id="DE511VjSTD2">https://www.instagram.com/share/p/BAtwjtaqSm</INSTAGRAM></r>',
867+
[],
868+
function ($configurator)
869+
{
870+
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
871+
$configurator->MediaEmbed->add('instagram');
872+
}
873+
],
864874
[
865875
'https://archive.org/details/BillGate99',
866876
'<r><INTERNETARCHIVE height="480" id="BillGate99" width="640">https://archive.org/details/BillGate99</INTERNETARCHIVE></r>',
@@ -871,7 +881,6 @@ function ($configurator)
871881
$configurator->MediaEmbed->add('internetarchive');
872882
}
873883
],
874-
875884
[
876885
'https://archive.org/details/DFTS2014-05-30',
877886
'<r><INTERNETARCHIVE height="50" id="DFTS2014-05-30&amp;playlist=1&amp;twitterv=01" width="300">https://archive.org/details/DFTS2014-05-30</INTERNETARCHIVE></r>',

0 commit comments

Comments
 (0)