Skip to content

Commit

Permalink
Update Vbox7
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopetkov committed Nov 10, 2021
1 parent c0fa920 commit 2c83f23
Showing 1 changed file with 51 additions and 42 deletions.
93 changes: 51 additions & 42 deletions src/VideoEmbed/Internal/Providers/Vbox7.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,58 @@ final class Vbox7 extends \IvoPetkov\VideoEmbed\Internal\Provider

static function load($url, $result)
{
if (strpos($url, 'play:') !== false && strpos($url, '&') !== false) {
$url = substr($url, 0, strpos($url, '&'));
}
$response = parent::readUrl('http://www.vbox7.com/etc/oembed/?url=' . urlencode($url));
$result->rawResponse = $response;
$domDocument = new \DOMDocument();
$domDocument->loadXML($response);
if ($domDocument->childNodes->item(0)->nodeName === 'oembed') {
$properties = [];
$findProperty = function ($name) use ($domDocument, &$properties) {
$elements = $domDocument->getElementsByTagName($name);
if ($elements->length === 1) {
$properties[$name] = trim((string) $elements->item(0)->textContent);
}
};
$findProperty('title');
$findProperty('author_name');
$findProperty('author_url');
$findProperty('provider_name');
$findProperty('provider_url');
$findProperty('width');
$findProperty('height');
$findProperty('url');
$urlParts = explode('play:', $properties['url']);
if (isset($urlParts[1])) {
$result->width = parent::getIntValueOrNull($properties, 'width');
if (strlen($result->width) === 0) {
$result->width = 560;
}
$result->height = parent::getIntValueOrNull($properties, 'height');
if (strlen($result->height) === 0) {
$result->height = 319;
}
$result->html = '<iframe src="https://www.vbox7.com/emb/external.php?vid=' . $urlParts[1] . '" frameborder="0" allowfullscreen style="width:' . $result->width . 'px;height:' . $result->height . 'px;"></iframe>';
$result->title = parent::getStringValueOrNull($properties, 'title');
$result->thumbnail['url'] = parent::getStringValueOrNull($properties, 'thumbnail_url');
$result->thumbnail['width'] = parent::getIntValueOrNull($properties, 'thumbnail_width');
$result->thumbnail['height'] = parent::getIntValueOrNull($properties, 'thumbnail_height');
$result->author['name'] = parent::getStringValueOrNull($properties, 'author_name');
$result->author['url'] = parent::getStringValueOrNull($properties, 'author_url');
$result->provider['name'] = parent::getStringValueOrNull($properties, 'provider_name');
$result->provider['url'] = parent::getStringValueOrNull($properties, 'provider_url');
if (strpos($url, 'play:') !== false) {
$matches = null;
preg_match('/play:([a-z0-9]*)/', $url, $matches);
if (is_array($matches) && isset($matches[1])) {
$result->html = '<iframe src="https://www.vbox7.com/emb/external.php?vid=' . $matches[1] . '" frameborder="0" allowfullscreen style="width:400px;height:300px;"></iframe>';
$result->width = 560;
$result->height = 319;
}
}
// if (strpos($url, 'play:') !== false && strpos($url, '&') !== false) {
// $url = substr($url, 0, strpos($url, '&'));
// }
// $response = parent::readUrl('http://www.vbox7.com/etc/oembed/?url=' . urlencode($url));
// $result->rawResponse = $response;
// $domDocument = new \DOMDocument();
// $domDocument->loadXML($response);
// if ($domDocument->childNodes->item(0)->nodeName === 'oembed') {
// $properties = [];
// $findProperty = function ($name) use ($domDocument, &$properties) {
// $elements = $domDocument->getElementsByTagName($name);
// if ($elements->length === 1) {
// $properties[$name] = trim((string) $elements->item(0)->textContent);
// }
// };
// $findProperty('title');
// $findProperty('author_name');
// $findProperty('author_url');
// $findProperty('provider_name');
// $findProperty('provider_url');
// $findProperty('width');
// $findProperty('height');
// $findProperty('url');
// $urlParts = explode('play:', $properties['url']);
// if (isset($urlParts[1])) {
// $result->width = parent::getIntValueOrNull($properties, 'width');
// if (strlen($result->width) === 0) {
// $result->width = 560;
// }
// $result->height = parent::getIntValueOrNull($properties, 'height');
// if (strlen($result->height) === 0) {
// $result->height = 319;
// }
// $result->html = '<iframe src="https://www.vbox7.com/emb/external.php?vid=' . $urlParts[1] . '" frameborder="0" allowfullscreen style="width:' . $result->width . 'px;height:' . $result->height . 'px;"></iframe>';
// $result->title = parent::getStringValueOrNull($properties, 'title');
// $result->thumbnail['url'] = parent::getStringValueOrNull($properties, 'thumbnail_url');
// $result->thumbnail['width'] = parent::getIntValueOrNull($properties, 'thumbnail_width');
// $result->thumbnail['height'] = parent::getIntValueOrNull($properties, 'thumbnail_height');
// $result->author['name'] = parent::getStringValueOrNull($properties, 'author_name');
// $result->author['url'] = parent::getStringValueOrNull($properties, 'author_url');
// $result->provider['name'] = parent::getStringValueOrNull($properties, 'provider_name');
// $result->provider['url'] = parent::getStringValueOrNull($properties, 'provider_url');
// }
// }
}
}

0 comments on commit 2c83f23

Please sign in to comment.