Skip to content

Commit

Permalink
Adapt the hulu pass to ensure its just running on amp-hulu
Browse files Browse the repository at this point in the history
  • Loading branch information
dawehner committed Feb 13, 2017
1 parent d10e691 commit b2fc1fa
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/Pass/IframeHuluTagTransformPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,21 @@ function pass()
/** @var \DOMElement $dom_el */
$dom_el = $el->get(0);
$lineno = $this->getLineNo($dom_el);
$query = $this->getQueryArray($el);
// If we can't get the videoid, abort
if (empty($query['eid'])) {
continue;
}
$eid = $query['eid'];
$width = $el->attr('width') ?: 800;
$height = $el->attr('height') ?: 600;

$context_string = $this->getContextString($dom_el);
if ($eid = $this->getArtifactId($el, '&(*UTF8)hulu\.com/embed\.html\?edit=(\d+)&i')) {
$width = $el->attr('width') ?: 800;
$height = $el->attr('height') ?: 600;

// width and height are intended to be aspect ratios here
$el->after('<amp-hulu width="' . $width . '" height="' . $height . '" layout="responsive" data-eid="' . $eid . '"></amp-hulu>');
$new_dom_el = $el->next()->get(0);
$context_string = $this->getContextString($dom_el);

$el->removeChildren()->remove();
$this->addActionTaken(new ActionTakenLine('iframe', ActionTakenType::HULU_CONVERTED, $lineno, $context_string));
// width and height are intended to be aspect ratios here
$el->after('<amp-hulu width="' . $width . '" height="' . $height . '" layout="responsive" data-eid="' . $eid . '"></amp-hulu>');
$new_dom_el = $el->next()->get(0);

$this->context->addLineAssociation($new_dom_el, $lineno);
$el->removeChildren()->remove();
$this->addActionTaken(new ActionTakenLine('iframe', ActionTakenType::HULU_CONVERTED, $lineno, $context_string));
$this->context->addLineAssociation($new_dom_el, $lineno);
}
}

return $this->transformations;
Expand Down

0 comments on commit b2fc1fa

Please sign in to comment.