From dfab9c33b499bc5d50730c7ab080b656d53d9cba Mon Sep 17 00:00:00 2001 From: hashworks Date: Mon, 15 Jun 2015 11:35:12 +0200 Subject: [PATCH 1/2] Add test for embed urls --- tests/PluginTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/PluginTest.php b/tests/PluginTest.php index ed200c1..5569aa5 100644 --- a/tests/PluginTest.php +++ b/tests/PluginTest.php @@ -147,6 +147,8 @@ public function dataProviderHandleUrl() { return array( array('http://www.youtube.com/watch?v=HFuTvTVAO-M'), + array('https://www.youtube.com/embed/HFuTvTVAO-M'), + array('https://youtube.com/embed/HFuTvTVAO-M'), array('http://youtube.com/watch?v=HFuTvTVAO-M'), array('http://youtu.be/HFuTvTVAO-M'), ); From 570d51d88ac73cc5f83614b8d8bca5ffa1cd4b8a Mon Sep 17 00:00:00 2001 From: hashworks Date: Mon, 15 Jun 2015 11:49:47 +0200 Subject: [PATCH 2/2] Add parser for embed URLs --- src/Plugin.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Plugin.php b/src/Plugin.php index 782ba02..7282808 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -110,6 +110,12 @@ protected function getVideoId($url) if (!empty($query['v'])) { return $query['v']; } + } elseif (isset($parsed['path']) && substr($parsed['path'], 0, 7) == '/embed/') { + $logger->debug('getVideoId', array('url' => $url, 'path' => $parsed['path'])); + $vId = substr($parsed['path'], 7); + if (!empty($vId)) { + return $vId; + } } } return null;