Skip to content

Commit

Permalink
MediaEmbed: updated YouTube
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Nov 2, 2023
1 parent c5891a5 commit 6fb87d7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
2 changes: 2 additions & 0 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7242,6 +7242,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests with data set #334
[x] Parsing tests with data set #335
[x] Parsing tests with data set #336
[x] Parsing tests with data set #337
[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 @@ -7579,6 +7580,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
[x] Parsing tests (JavaScript) with data set #334
[x] Parsing tests (JavaScript) with data set #335
[x] Parsing tests (JavaScript) with data set #336
[x] Parsing tests (JavaScript) with data set #337
[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
18 changes: 9 additions & 9 deletions src/Bundles/Fatdown.php

Large diffs are not rendered by default.

16 changes: 8 additions & 8 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 @@ -144,6 +144,6 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
'xboxdvr'=>['attributes'=>[],'example'=>'https://gamerdvr.com/gamer/LOXITANE/video/12463958','extract'=>['!(?:gamer|xbox)dvr\\.com/gamer/(?\'user\'[^/]+)/video/(?\'id\'\\d+)!'],'homepage'=>'https://gamerdvr.com/','host'=>['gamerdvr.com','xboxdvr.com'],'iframe'=>['src'=>'//gamerdvr.com/gamer/{@user}/video/{@id}/embed'],'name'=>'Gamer DVR','scrape'=>[],'tags'=>['gaming']],
'youku'=>['attributes'=>[],'example'=>'https://v.youku.com/v_show/id_XMzY0NTMyMTgxMg==.html','extract'=>['!youku\\.com/v(?:_show|ideo)/id_(?\'id\'\\w+=*)!'],'homepage'=>'https://www.youku.com/','host'=>['youku.com'],'iframe'=>['src'=>'//player.youku.com/embed/{@id}'],'name'=>'Youku','scrape'=>[],'tags'=>['.cn']],
'youmaker'=>['attributes'=>[],'example'=>['https://www.youmaker.com/v/EnDXOWo8OOvQ','https://www.youmaker.com/video/b3ce8457-2cbe-4661-84ec-829fa8fe0754'],'extract'=>['!youmaker\\.com/(?:embed|v(?:ideo)?)/(?\'id\'[-a-z0-9]+)!i'],'homepage'=>'https://www.youmaker.com/','host'=>['youmaker.com'],'iframe'=>['src'=>'https://www.youmaker.com/embed/{@id}'],'name'=>'YouMaker','scrape'=>[],'tags'=>['videos']],
'youtube'=>['amp'=>['custom-element'=>'amp-youtube','src'=>'https://cdn.ampproject.org/v0/amp-youtube-0.1.js','template'=>'<amp-youtube layout="responsive" width="640" height="360" data-param-list="{@list}" data-param-start="{@t}" data-videoid="{@id}"/>'],'attributes'=>['id'=>['filterChain'=>['#identifier'],'required'=>false],'t'=>['filterChain'=>['#timestamp']]],'example'=>['https://www.youtube.com/watch?v=-cEzsCAzTak','https://youtu.be/-cEzsCAzTak','https://www.youtube.com/watch?feature=player_detailpage&v=jofNR_WkoCE#t=40','https://www.youtube.com/watch?v=pC35x6iIPmo&list=PLOU2XLYxmsIIxJrlMIY5vYXAFcO5g83gA'],'extract'=>['!youtube\\.com/(?:watch.*?v=|(?:embed|live|shorts|v)/|attribution_link.*?v%3D)(?\'id\'[-\\w]+)!','!youtube-nocookie\\.com/embed/(?\'id\'[-\\w]+)!','!youtu\\.be/(?\'id\'[-\\w]+)!','@[#&?]t=(?\'t\'\\d[\\dhms]*)@','![&?]list=(?\'list\'[-\\w]+)!'],'homepage'=>'https://www.youtube.com/','host'=>['youtube-nocookie.com','youtube.com','youtu.be'],'iframe'=>['src'=>'https://www.youtube.com/embed/<xsl:value-of select="@id"/><xsl:choose><xsl:when test="@clip">?clip=<xsl:value-of select="@clip"/>&amp;clipt=<xsl:value-of select="@clipt"/></xsl:when><xsl:otherwise><xsl:if test="@list">?list=<xsl:value-of select="@list"/></xsl:if><xsl:if test="@t"><xsl:choose><xsl:when test="@list">&amp;</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose>start=<xsl:value-of select="@t"/></xsl:if></xsl:otherwise></xsl:choose>','style'=>['background'=>'url(https://i.ytimg.com/vi/{@id}/hqdefault.jpg) 50% 50% / cover']],'name'=>'YouTube','oembed'=>['endpoint'=>'https://www.youtube.com/oembed','scheme'=>'https://www.youtube.com/watch?v={@id}'],'scrape'=>[['extract'=>['@/embed/(?\'id\'[-\\w]+)\\?clip=(?\'clip\'[-\\w]+)&amp;clipt=(?\'clipt\'[-\\w]+)@'],'match'=>['@youtube\\.com/clip/.@']]],'source'=>'https://support.google.com/youtube/bin/answer.py?hl=en&answer=171780','tags'=>['livestreaming','videos']]
'youtube'=>['amp'=>['custom-element'=>'amp-youtube','src'=>'https://cdn.ampproject.org/v0/amp-youtube-0.1.js','template'=>'<amp-youtube layout="responsive" width="640" height="360" data-param-list="{@list}" data-param-start="{@t}" data-videoid="{@id}"/>'],'attributes'=>['id'=>['filterChain'=>['#identifier'],'required'=>false],'t'=>['filterChain'=>['#timestamp']]],'example'=>['https://www.youtube.com/watch?v=-cEzsCAzTak','https://youtu.be/-cEzsCAzTak','https://www.youtube.com/watch?feature=player_detailpage&v=jofNR_WkoCE#t=40','https://www.youtube.com/watch?v=pC35x6iIPmo&list=PLOU2XLYxmsIIxJrlMIY5vYXAFcO5g83gA'],'extract'=>['!youtube\\.com/(?:watch.*?v=|(?:embed|live|shorts|v)/|attribution_link.*?v%3D)(?\'id\'[-\\w]+)!','!youtube-nocookie\\.com/embed/(?\'id\'[-\\w]+)!','!youtu\\.be/(?\'id\'[-\\w]+)!','@[#&?]t(?:ime_continue)?=(?\'t\'\\d[\\dhms]*)@','![&?]list=(?\'list\'[-\\w]+)!'],'homepage'=>'https://www.youtube.com/','host'=>['youtube-nocookie.com','youtube.com','youtu.be'],'iframe'=>['src'=>'https://www.youtube.com/embed/<xsl:value-of select="@id"/><xsl:choose><xsl:when test="@clip">?clip=<xsl:value-of select="@clip"/>&amp;clipt=<xsl:value-of select="@clipt"/></xsl:when><xsl:otherwise><xsl:if test="@list">?list=<xsl:value-of select="@list"/></xsl:if><xsl:if test="@t"><xsl:choose><xsl:when test="@list">&amp;</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose>start=<xsl:value-of select="@t"/></xsl:if></xsl:otherwise></xsl:choose>','style'=>['background'=>'url(https://i.ytimg.com/vi/{@id}/hqdefault.jpg) 50% 50% / cover']],'name'=>'YouTube','oembed'=>['endpoint'=>'https://www.youtube.com/oembed','scheme'=>'https://www.youtube.com/watch?v={@id}'],'scrape'=>[['extract'=>['@/embed/(?\'id\'[-\\w]+)\\?clip=(?\'clip\'[-\\w]+)&amp;clipt=(?\'clipt\'[-\\w]+)@'],'match'=>['@youtube\\.com/clip/.@']]],'source'=>'https://support.google.com/youtube/bin/answer.py?hl=en&answer=171780','tags'=>['livestreaming','videos']]
];
}
2 changes: 1 addition & 1 deletion src/Plugins/MediaEmbed/Configurator/sites/youtube.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<extract>!youtube\.com/(?:watch.*?v=|(?:embed|live|shorts|v)/|attribution_link.*?v%3D)(?'id'[-\w]+)!</extract>
<extract>!youtube-nocookie\.com/embed/(?'id'[-\w]+)!</extract>
<extract>!youtu\.be/(?'id'[-\w]+)!</extract>
<extract>@[#&amp;?]t=(?'t'\d[\dhms]*)@</extract>
<extract>@[#&amp;?]t(?:ime_continue)?=(?'t'\d[\dhms]*)@</extract>
<extract>![&amp;?]list=(?'list'[-\w]+)!</extract>
<scrape>
<match>@youtube\.com/clip/.@</match>
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 @@ -4405,6 +4405,15 @@ function ($configurator)
$configurator->MediaEmbed->add('youtube');
}
],
[
'https://www.youtube.com/watch?time_continue=149&v=dQw4w9WgXcQ',
'<r><YOUTUBE id="dQw4w9WgXcQ" t="149">https://www.youtube.com/watch?time_continue=149&amp;v=dQw4w9WgXcQ</YOUTUBE></r>',
[],
function ($configurator)
{
$configurator->MediaEmbed->add('youtube');
}
],
[
'http://www.youtube.com/watch?v=pC35x6iIPmo&list=PLOU2XLYxmsIIxJrlMIY5vYXAFcO5g83gA',
'<r><YOUTUBE id="pC35x6iIPmo" list="PLOU2XLYxmsIIxJrlMIY5vYXAFcO5g83gA">http://www.youtube.com/watch?v=pC35x6iIPmo&amp;list=PLOU2XLYxmsIIxJrlMIY5vYXAFcO5g83gA</YOUTUBE></r>',
Expand Down

0 comments on commit 6fb87d7

Please sign in to comment.