Skip to content

Commit 425d209

Browse files
committed
MediaEmbed: updated VK
Fixes #243
1 parent 9288d08 commit 425d209

File tree

5 files changed

+94
-76
lines changed

5 files changed

+94
-76
lines changed

docs/testdox.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,6 +6906,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
69066906
[x] Scraping tests with data set #59
69076907
[x] Scraping tests with data set #60
69086908
[x] Scraping tests with data set #61
6909+
[x] Scraping tests with data set #62
69096910
[x] Scraping+rendering tests with data set #0
69106911
[x] Scraping+rendering tests with data set #1
69116912
[x] Scraping+rendering tests with data set #2

src/Bundles/MediaPack.php

Lines changed: 72 additions & 72 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
@@ -131,7 +131,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
131131
'videodetective'=>['attributes'=>[],'example'=>'https://www.videodetective.com/movies/zootopia/658596','extract'=>['!videodetective\\.com/\\w+/[-\\w]+/(?:trailer/P0*)?(?\'id\'\\d+)!'],'homepage'=>'https://www.videodetective.com/','host'=>['videodetective.com'],'iframe'=>['src'=>'//www.videodetective.com/embed/video/?options=false&autostart=false&playlist=none&publishedid={@id}'],'name'=>'Video Detective','scrape'=>[]],
132132
'vimeo'=>['amp'=>['custom-element'=>'amp-vimeo','src'=>'https://cdn.ampproject.org/v0/amp-vimeo-0.1.js','template'=>'<amp-vimeo layout="responsive" width="640" height="360" data-videoid="{@id}"/>'],'attributes'=>['t'=>['filterChain'=>['#timestamp']]],'example'=>['https://vimeo.com/67207222','https://vimeo.com/channels/staffpicks/67207222'],'extract'=>['!vimeo\\.com/(?:channels/[^/]+/|video/)?(?\'id\'\\d+)(?:/(?\'h\'\\w+))?\\b!','!#t=(?\'t\'[\\dhms]+)!'],'homepage'=>'https://vimeo.com/','host'=>['vimeo.com'],'iframe'=>['src'=>'//player.vimeo.com/video/<xsl:value-of select="@id"/><xsl:if test="@h">?h=<xsl:value-of select="@h"/></xsl:if><xsl:if test="@t">#t=<xsl:value-of select="@t"/></xsl:if>'],'name'=>'Vimeo','oembed'=>['endpoint'=>'https://vimeo.com/api/oembed.json','scheme'=>'https://vimeo.com/{@id}'],'scrape'=>[],'source'=>'http://developer.vimeo.com/player/embedding','tags'=>['videos']],
133133
'vine'=>['amp'=>['custom-element'=>'amp-vine','src'=>'https://cdn.ampproject.org/v0/amp-vine-0.1.js','template'=>'<amp-vine layout="responsive" width="400" height="400" data-vineid="{@id}"/>'],'attributes'=>[],'example'=>'https://vine.co/v/bYwPIluIipH','extract'=>['!vine\\.co/v/(?\'id\'[^/]+)!'],'homepage'=>'https://vine.co/','host'=>['vine.co'],'iframe'=>['height'=>480,'src'=>'https://vine.co/v/{@id}/embed/simple?audio=1','width'=>480],'name'=>'Vine','scrape'=>[],'tags'=>['social','videos']],
134-
'vk'=>['attributes'=>[],'example'=>['https://vk.com/video121599878_165723901?hash=e06b0878046e1d32','https://vk.com/video_ext.php?oid=121599878&id=165723901&hash=e06b0878046e1d32'],'extract'=>['!vk(?:\\.com|(?:ontakte|video)\\.ru)/(?:[\\w.]+\\?z=)?video(?\'oid\'-?\\d+)_(?\'vid\'\\d+).*?hash=(?\'hash\'[0-9a-f]+)!','!vk(?:\\.com|(?:ontakte|video)\\.ru)/video_ext\\.php\\?oid=(?\'oid\'-?\\d+)&id=(?\'vid\'\\d+)(?:&hash=(?\'hash\'[0-9a-f]+))?!'],'homepage'=>'https://vk.com/','host'=>['vk.com','vkontakte.ru','vkvideo.ru'],'iframe'=>['src'=>'//vk.com/video_ext.php?oid={@oid}&id={@vid}&hash={@hash}&hd=1'],'name'=>'VK','scrape'=>[['extract'=>['#meta property="og:video" content=".*?oid=(?\'oid\'-?\\d+).*?id=(?\'vid\'\\d+).*?hash=(?\'hash\'[0-9a-f]+)#'],'header'=>['User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36','Cookie: _ignoreAutoLogin=1'],'match'=>['#^(?!.*?hash=)#']]],'tags'=>['.ru']],
134+
'vk'=>['attributes'=>['oid'=>['required'=>true],'vid'=>['required'=>true]],'example'=>['https://vk.com/video121599878_165723901?hash=e06b0878046e1d32','https://vk.com/video_ext.php?oid=121599878&id=165723901&hash=e06b0878046e1d32'],'extract'=>['!video(?\'oid\'-?\\d+)_(?\'vid\'\\d+)!','!/video_ext\\.php\\?oid=(?\'oid\'-?\\d+)&id=(?\'vid\'\\d+)!','!hash=(?\'hash\'[0-9a-f]+)!'],'homepage'=>'https://vk.com/','host'=>['vk.com','vkontakte.ru','vkvideo.ru'],'iframe'=>['src'=>'//vk.com/video_ext.php?oid={@oid}&id={@vid}&hash={@hash}&hd=1'],'name'=>'VK','scrape'=>[['extract'=>['#meta property="og:video" content=".*?oid=(?\'oid\'-?\\d+).*?id=(?\'vid\'\\d+)#','#meta property="og:video" content=".*?hash=(?\'hash\'[0-9a-f]+)#'],'header'=>['User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36','Cookie: _ignoreAutoLogin=1'],'match'=>['#^(?!.*?hash=)#']]],'tags'=>['.ru']],
135135
'vocaroo'=>['attributes'=>[],'example'=>'https://vocaroo.com/3OlvdB6eiiK','extract'=>['!voca(?:\\.ro|roo\\.com)/(?:i/)?(?\'id\'\\w+)!'],'homepage'=>'https://vocaroo.com/','host'=>['voca.ro','vocaroo.com'],'iframe'=>['height'=>80,'max-width'=>900,'src'=>'https://vocaroo.com/embed/{@id}','width'=>'100%'],'name'=>'Vocaroo','scrape'=>[]],
136136
'vox'=>['attributes'=>[],'example'=>'https://www.vox.com/2015/7/21/9005857/ant-man-marvel-apology-review#ooid=ltbzJkdTpKpE-O6hOfD3YJew3t3MppXb','extract'=>['!vox.com/.*#ooid=(?\'id\'[-\\w]+)!'],'homepage'=>'https://www.vox.com/','host'=>['vox.com'],'iframe'=>['src'=>'//player.ooyala.com/iframe.html#pbid=a637d53c5c0a43c7bf4e342886b9d8b0&ec={@id}'],'name'=>'Vox','scrape'=>[]],
137137
'washingtonpost'=>['attributes'=>[],'example'=>['https://www.washingtonpost.com/video/c/video/df229384-9216-11e6-bc00-1a9756d4111b','https://www.washingtonpost.com/video/world/aurora-display-lights-up-the-night-sky-over-finland/2016/10/14/df229384-9216-11e6-bc00-1a9756d4111b_video.html'],'extract'=>['#washingtonpost\\.com/video/c/\\w+/(?\'id\'[-0-9a-f]+)#','#washingtonpost\\.com/video/[-/\\w]+/(?\'id\'[-0-9a-f]+)_video\\.html#'],'homepage'=>'https://www.washingtonpost.com/video/','host'=>['washingtonpost.com'],'iframe'=>['src'=>'//www.washingtonpost.com/video/c/embed/{@id}'],'name'=>'Washington Post Video','scrape'=>[],'tags'=>['news']],

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44

55
<tags><tag>.ru</tag></tags>
66

7+
<attributes>
8+
<oid required="true"/>
9+
<vid required="true"/>
10+
</attributes>
11+
712
<host>vk.com</host>
813
<host>vkontakte.ru</host>
914
<host>vkvideo.ru</host>
10-
<extract>!vk(?:\.com|(?:ontakte|video)\.ru)/(?:[\w.]+\?z=)?video(?'oid'-?\d+)_(?'vid'\d+).*?hash=(?'hash'[0-9a-f]+)!</extract>
11-
<extract>!vk(?:\.com|(?:ontakte|video)\.ru)/video_ext\.php\?oid=(?'oid'-?\d+)&amp;id=(?'vid'\d+)(?:&amp;hash=(?'hash'[0-9a-f]+))?!</extract>
15+
<extract>!video(?'oid'-?\d+)_(?'vid'\d+)!</extract>
16+
<extract>!/video_ext\.php\?oid=(?'oid'-?\d+)&amp;id=(?'vid'\d+)!</extract>
17+
<extract>!hash=(?'hash'[0-9a-f]+)!</extract>
1218
<scrape>
1319
<header>User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36</header>
1420
<header>Cookie: _ignoreAutoLogin=1</header>
1521
<match>#^(?!.*?hash=)#</match>
16-
<extract>#meta property="og:video" content=".*?oid=(?'oid'-?\d+).*?id=(?'vid'\d+).*?hash=(?'hash'[0-9a-f]+)#</extract>
22+
<extract>#meta property="og:video" content=".*?oid=(?'oid'-?\d+).*?id=(?'vid'\d+)#</extract>
23+
<extract>#meta property="og:video" content=".*?hash=(?'hash'[0-9a-f]+)#</extract>
1724
</scrape>
1825
<iframe src="//vk.com/video_ext.php?oid={@oid}&amp;id={@vid}&amp;hash={@hash}&amp;hd=1"/>
1926
</site>

tests/Plugins/MediaEmbed/ParserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,16 @@ function ($configurator)
11591159
$configurator->MediaEmbed->add('vk');
11601160
}
11611161
],
1162+
[
1163+
'https://vk.com/video75380313_456242434',
1164+
'<r><VK oid="75380313" vid="456242434">https://vk.com/video75380313_456242434</VK></r>',
1165+
[],
1166+
function ($configurator)
1167+
{
1168+
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
1169+
$configurator->MediaEmbed->add('vk');
1170+
}
1171+
],
11621172
[
11631173
'https://thoughtworks.wistia.com/medias/b6al55s35k',
11641174
'<r><WISTIA id="b6al55s35k">https://thoughtworks.wistia.com/medias/b6al55s35k</WISTIA></r>',

0 commit comments

Comments
 (0)