Skip to content
This repository has been archived by the owner on Jul 15, 2018. It is now read-only.

Commit

Permalink
Add support for Youtube embed video URL
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jun 29, 2012
1 parent 9c2da86 commit 9da82a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/TubeLink/Service/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function parse($url)
&& preg_match('#^/?\w{11}/?$#', $data['path'])
) {
$id = trim($data['path'], '/');
} elseif (false !== strpos($data['host'], 'youtube.com')
&& preg_match('{^/embed/(\w{11})}', $data['path'], $matches)
) {
$id = $matches[1];
} else {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/TubeLink/Tests/Service/YoutubeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function dataForTestParse()
array('http://youtu.be/gHYfY9lZaRE', 'gHYfY9lZaRE'),
array('http://www.youtu.be/gHYfY9lZaRE', 'gHYfY9lZaRE'),
array('http://www.youtu.be/gHYfY9lZaRE/?feature=g-vrec', 'gHYfY9lZaRE'),
array('http://www.youtube.com/embed/gHYfY9lZaRE', 'gHYfY9lZaRE'),
);
}

Expand Down

0 comments on commit 9da82a5

Please sign in to comment.