File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Adapter to fix the embed code from marca.com
4+ */
5+ namespace Embed \Adapters ;
6+
7+ use Embed \Url ;
8+ use Embed \Viewers ;
9+
10+ class Marca extends Webpage implements AdapterInterface {
11+
12+ static public function check (Url $ Url ) {
13+ return $ Url ->match (array (
14+ 'http://www.marca.com/* '
15+ ));
16+ }
17+
18+ public function getCode () {
19+ if (($ code = parent ::getCode ())) {
20+ $ errors = libxml_use_internal_errors (true );
21+ $ html = new \DOMDocument ();
22+ $ result = $ html ->loadHtml ($ code );
23+ libxml_use_internal_errors ($ errors );
24+
25+ if ($ result ) {
26+ $ startValue = 'http://cachevideos.marca.com/multimedia/reproductores/v2/reproductor_video.swf ' ;
27+ $ startValueLength = strlen ($ startValue );
28+
29+ foreach ($ html ->getElementsByTagName ('param ' ) as $ param ) {
30+ if ($ param ->getAttribute ('name ' ) === 'movie ' ) {
31+ $ value = $ param ->getAttribute ('value ' );
32+
33+ if (substr ($ value , 0 , $ startValueLength ) === $ startValue ) {
34+ $ value = substr ($ value , $ startValueLength );
35+ }
36+
37+ return Viewers::videoHtml ($ this ->getImage (), $ value );
38+ }
39+ }
40+ }
41+ }
42+
43+ return $ code ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments