Skip to content

Commit

Permalink
MediaEmbed: updated 247Sports
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Apr 7, 2024
1 parent 487e3c4 commit bf99a93
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 89 deletions.
2 changes: 1 addition & 1 deletion docs/Plugins/MediaEmbed/Sites.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
</tr>
<tr title="247Sports" id="twentyfoursevensports">
<td><code>twentyfoursevensports</code></td>
<td>https://247sports.com/Player/LeSean-McCoy-25234/<br/>https://247sports.com/Video/FFT-Week-12-QBRB-Start-or-Sit-1122-8838631/</td>
<td>https://247sports.com/Player/LeSean-McCoy-25234/</td>
</tr>
<tr title="Twitch" id="twitch">
<td><code>twitch</code></td>
Expand Down
1 change: 1 addition & 0 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6864,6 +6864,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
132 changes: 66 additions & 66 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 @@ -119,7 +119,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
'traileraddict'=>['attributes'=>[],'example'=>'https://www.traileraddict.com/the-amazing-spider-man-2/super-bowl-tv-spot','extract'=>[],'homepage'=>'https://www.traileraddict.com/','host'=>['traileraddict.com'],'iframe'=>['src'=>'//v.traileraddict.com/{@id}'],'name'=>'Trailer Addict','scrape'=>[['extract'=>['@v\\.traileraddict\\.com/(?\'id\'\\d+)@'],'match'=>['@traileraddict\\.com/(?!tags/)[^/]+/.@']]],'tags'=>['movies']],
'trendingviews'=>['attributes'=>[],'example'=>'https://trendingviews.com/videos/2267/woman-sinks-suv-trying-to-help-a-guy-out/','extract'=>['!(?:mydailyfreedom\\.com|trendingviews\\.com?)/(?:tv/)?(?:embed|videos?)/(?:[^/]+-)?(?\'id\'\\d+)!'],'homepage'=>'https://trendingviews.com/','host'=>['mydailyfreedom.com','trendingviews.co','trendingviews.com'],'iframe'=>['src'=>'https://trendingviews.com/embed/{@id}'],'name'=>'Trending Views','scrape'=>[],'tags'=>['videos']],
'tumblr'=>['attributes'=>['did'=>['required'=>true],'key'=>['required'=>true],'name'=>['required'=>true]],'example'=>'https://staff.tumblr.com/post/180624227620/','extract'=>['!(?\'name\'[-\\w]+)\\.tumblr\\.com/post/(?\'id\'\\d+)!','!(?:at|www)\\.tumblr\\.com/(?\'name\'[-\\w]+)/(?\'id\'\\d+)!'],'homepage'=>'https://www.tumblr.com/','host'=>['tumblr.com'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>300,'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/tumblr.min.html#{@key}/{@id}','width'=>542],'name'=>'Tumblr','scrape'=>[['extract'=>['!did=(?:\\\\"|\\\\u0022)(?\'did\'[-\\w]+)!','!embed/post/t:(?\'key\'[-\\w]+)!'],'header'=>'User-agent: curl','match'=>['!\\w\\.tumblr\\.com/post/\\d!','!(?:at|www)\\.tumblr\\.com/[-\\w]+/\\d+!'],'url'=>'https://www.tumblr.com/oembed/1.0?url=https://{@name}.tumblr.com/post/{@id}']],'tags'=>['social']],
'twentyfoursevensports'=>['attributes'=>[],'choose'=>['otherwise'=>['iframe'=>['height'=>200,'onload'=>'window.addEventListener(\'message\',function(e){{if(e.source===this.contentWindow&&e.data.height)this.style.height=e.data.height+\'px\'}})','src'=>'https://247sports.com/PlayerSport/{@player_id}/Embed/','width'=>600]],'when'=>['iframe'=>['src'=>'https://www.cbssports.com/video/player/embed?args=player_id%3D{@video_id}%26channel%3Dmobilevideo%26pcid%3D{@video_id}%26width%3D640%26height%3D360%26autoplay%3Dfalse%26comp_ads_enabled%3Dfalse%26uvpc%3Dhttp%3A%2F%2Fsports.cbsimg.net%2Fvideo%2Fuvp%2Fconfig%2Fv4%2Fuvp_247sports.xml%26uvpc_m%3Dhttp%3A%2F%2Fsports.cbsimg.net%2Fvideo%2Fuvp%2Fconfig%2Fv4%2Fuvp_247sports_m.xml%26partner%3D247%26partner_m%3D247_mobile%26utag%3D247sportssite%26resizable%3Dtrue'],'test'=>'@video_id']],'example'=>['https://247sports.com/Player/LeSean-McCoy-25234/','https://247sports.com/Video/FFT-Week-12-QBRB-Start-or-Sit-1122-8838631/'],'extract'=>['!247sports\\.com/PlayerSport/[-\\w]*?(?\'player_id\'\\d+)/Embed!'],'homepage'=>'https://247sports.com/','host'=>['247sports.com'],'name'=>'247Sports','scrape'=>[['extract'=>['!247sports\\.com/PlayerSport/[-\\w]*?(?\'player_id\'\\d+)/Embed!'],'header'=>'User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36','match'=>['!247sports\\.com/Player/[-\\w]*?\\d!']],['extract'=>['!embedVideoContainer_(?\'video_id\'\\d+)!'],'header'=>'User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36','match'=>['!247sports\\.com/Video/.!']]],'tags'=>['sports']],
'twentyfoursevensports'=>['attributes'=>[],'example'=>'https://247sports.com/Player/LeSean-McCoy-25234/','extract'=>['!247sports\\.com/playersport/[-\\w]*?(?\'player_id\'\\d+)/embed!i'],'homepage'=>'https://247sports.com/','host'=>['247sports.com'],'iframe'=>['height'=>152,'onload'=>'let w=this.contentWindow;window.addEventListener(\'message\',e=>{{if(e.source===w&&e.data.height)this.style.height=e.data.height+\'px\'}});w.postMessage(\'\',\'*\')','src'=>'https://247sports.com/playersport/{@player_id}/embed/','width'=>600],'name'=>'247Sports','scrape'=>[['extract'=>['!247sports\\.com/playersport/[-\\w]*?(?\'player_id\'\\d+)/embed!i'],'header'=>'User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36','match'=>['!247sports\\.com/Player/[-\\w]*?\\d!i']]],'tags'=>['sports']],
'twitch'=>['attributes'=>[],'example'=>['https://www.twitch.tv/twitch','https://www.twitch.tv/twitch/v/29415830?t=17m17s','https://www.twitch.tv/videos/29415830?t=17m17s','https://www.twitch.tv/chess/clip/CrepuscularOptimisticEagleOhMyDog-9jMi4oqxK5MN0F0C'],'extract'=>['#twitch\\.tv/(?:videos|\\w+/v)/(?\'video_id\'\\d+)?#','#www\\.twitch\\.tv/(?!videos/)(?\'channel\'\\w+)(?:/clip/(?\'clip_id\'[-\\w]+))?#','#t=(?\'t\'(?:(?:\\d+h)?\\d+m)?\\d+s)#','#clips\\.twitch\\.tv/(?:(?\'channel\'\\w+)/)?(?\'clip_id\'[-\\w]+)#'],'homepage'=>'https://www.twitch.tv/','host'=>['twitch.tv'],'iframe'=>['onload'=>'this.contentWindow.postMessage(\'\',\'*\')','src'=>'https://s9e.github.io/iframe/2/twitch.min.html#channel={@channel};clip_id={@clip_id};t={@t};video_id={@video_id}'],'name'=>'Twitch','scrape'=>[],'source'=>'https://dev.twitch.tv/docs/embed/video-and-clips','tags'=>['gaming','livestreaming']],
'twitter'=>['amp'=>['custom-element'=>'amp-twitter','src'=>'https://cdn.ampproject.org/v0/amp-twitter-0.1.js','template'=>'<amp-twitter layout="responsive" width="550" height="273" data-tweetid="{@id}"><blockquote placeholder=""><a href="https://twitter.com/user/status/{@id}">X</a></blockquote></amp-twitter>'],'attributes'=>[],'example'=>['https://twitter.com/IJasonAlexander/statuses/1718435734942556494','https://mobile.twitter.com/DerekTVShow/status/463372588690202624','https://twitter.com/#!/IJasonAlexander/status/526635414338023424'],'extract'=>['@(?:twitter|x)\\.com/(?:#!/|i/)?\\w+/(?:status(?:es)?|tweet)/(?\'id\'\\d+)@'],'homepage'=>'https://twitter.com/','host'=>['twitter.com','x.com'],'iframe'=>['allow'=>'autoplay *','data-s9e-livepreview-ignore-attrs'=>'style','height'=>350,'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/twitter.min.html#<xsl:value-of select="@id"/><xsl:if test="$MEDIAEMBED_THEME=\'dark\'">#theme=dark</xsl:if>','width'=>550],'name'=>'X','oembed'=>['endpoint'=>'https://publish.twitter.com/oembed','scheme'=>'https://twitter.com/user/status/{@id}'],'scrape'=>[],'tags'=>['social']],
'ustream'=>['attributes'=>[],'choose'=>['otherwise'=>['iframe'=>['src'=>'//www.ustream.tv/embed/{@cid}?html5ui']],'when'=>['iframe'=>['src'=>'//www.ustream.tv/embed/recorded/{@vid}?html5ui'],'test'=>'@vid']],'example'=>['https://www.ustream.tv/channel/ps4-ustream-gameplay','https://www.ustream.tv/baja1000tv','https://www.ustream.tv/recorded/40688256'],'extract'=>['!ustream\\.tv/recorded/(?\'vid\'\\d+)!'],'homepage'=>'https://www.ustream.tv/','host'=>['ustream.tv'],'name'=>'Ustream','scrape'=>[['extract'=>['!embed/(?\'cid\'\\d+)!'],'match'=>['#ustream\\.tv/(?!explore/|platform/|recorded/|search\\?|upcoming$|user/)(?:channel/)?[-\\w]+#']]],'tags'=>['gaming']],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
<site name="247Sports" homepage="https://247sports.com/">
<example>https://247sports.com/Player/LeSean-McCoy-25234/</example>
<example>https://247sports.com/Video/FFT-Week-12-QBRB-Start-or-Sit-1122-8838631/</example>

<tags><tag>sports</tag></tags>

<host>247sports.com</host>
<extract>!247sports\.com/PlayerSport/[-\w]*?(?'player_id'\d+)/Embed!</extract>
<extract>!247sports\.com/playersport/[-\w]*?(?'player_id'\d+)/embed!i</extract>
<scrape>
<header>User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36</header>
<match>!247sports\.com/Player/[-\w]*?\d!</match>
<extract>!247sports\.com/PlayerSport/[-\w]*?(?'player_id'\d+)/Embed!</extract>
<header>User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36</header>
<match>!247sports\.com/Player/[-\w]*?\d!i</match>
<extract>!247sports\.com/playersport/[-\w]*?(?'player_id'\d+)/embed!i</extract>
</scrape>
<scrape>
<header>User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36</header>
<match>!247sports\.com/Video/.!</match>
<extract>!embedVideoContainer_(?'video_id'\d+)!</extract>
</scrape>
<choose>
<when test="@video_id">
<iframe src="https://www.cbssports.com/video/player/embed?args=player_id%3D{@video_id}%26channel%3Dmobilevideo%26pcid%3D{@video_id}%26width%3D640%26height%3D360%26autoplay%3Dfalse%26comp_ads_enabled%3Dfalse%26uvpc%3Dhttp%3A%2F%2Fsports.cbsimg.net%2Fvideo%2Fuvp%2Fconfig%2Fv4%2Fuvp_247sports.xml%26uvpc_m%3Dhttp%3A%2F%2Fsports.cbsimg.net%2Fvideo%2Fuvp%2Fconfig%2Fv4%2Fuvp_247sports_m.xml%26partner%3D247%26partner_m%3D247_mobile%26utag%3D247sportssite%26resizable%3Dtrue"/>
</when>
<otherwise>
<iframe width="600" height="200" src="https://247sports.com/PlayerSport/{@player_id}/Embed/" onload="window.addEventListener('message',function(e){{if(e.source===this.contentWindow&amp;&amp;e.data.height)this.style.height=e.data.height+'px'}})"/>
</otherwise>
</choose>
<iframe width="600" height="152" src="https://247sports.com/playersport/{@player_id}/embed/" onload="let w=this.contentWindow;window.addEventListener('message',e=&gt;{{if(e.source===w&amp;&amp;e.data.height)this.style.height=e.data.height+'px'}});w.postMessage('','*')"/>
</site>
10 changes: 10 additions & 0 deletions tests/Plugins/MediaEmbed/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,16 @@ function ($configurator)
$configurator->MediaEmbed->add('tumblr');
}
],
[
'https://247sports.com/Player/Donovan-Clingan-46086979/',
'<r><TWENTYFOURSEVENSPORTS player_id="298735">https://247sports.com/Player/Donovan-Clingan-46086979/</TWENTYFOURSEVENSPORTS></r>',
[],
function ($configurator)
{
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
$configurator->MediaEmbed->add('twentyfoursevensports');
}
],
[
'https://thoughtworks.wistia.com/medias/b6al55s35k',
'<r><WISTIA id="b6al55s35k">https://thoughtworks.wistia.com/medias/b6al55s35k</WISTIA></r>',
Expand Down

0 comments on commit bf99a93

Please sign in to comment.