Skip to content

Commit

Permalink
Merge pull request sonata-project#945 from clytemnestra/patch-1
Browse files Browse the repository at this point in the history
Possibility to create youtube videos Media from mobile
  • Loading branch information
OskarStark committed Feb 11, 2016
2 parents 975b104 + 957fa2a commit 84f51ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Provider/YouTubeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function fixBinaryContent(MediaInterface $media)
return;
}

if (preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\#\?&\"'>]+)/", $media->getBinaryContent(), $matches)) {
if (preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\#\?&\"'>]+)/", $media->getBinaryContent(), $matches)) {
$media->setBinaryContent($matches[1]);
}
}
Expand Down
18 changes: 11 additions & 7 deletions Tests/Provider/YouTubeProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ public function testTransformWithUrl($url)
public static function getUrls()
{
return array(
array('BDYAbAtaDzA'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA&feature=feedrec_grec_index'),
array('http://www.youtube.com/v/BDYAbAtaDzA?fs=1&hl=en_US&rel=0'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA#t=0m10s'),
array('http://www.youtube.com/embed/BDYAbAtaDzA?rel=0'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA'),
array('http://youtu.be/BDYAbAtaDzA'),
array('BDYAbAtaDzA'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA&feature=feedrec_grec_index'),
array('http://www.youtube.com/v/BDYAbAtaDzA?fs=1&hl=en_US&rel=0'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA#t=0m10s'),
array('http://www.youtube.com/embed/BDYAbAtaDzA?rel=0'),
array('http://www.youtube.com/watch?v=BDYAbAtaDzA'),
array('http://www.m.youtube.com/watch?v=BDYAbAtaDzA'),
array('http://m.youtube.com/watch?v=BDYAbAtaDzA'),
array('https://www.m.youtube.com/watch?v=BDYAbAtaDzA'),
array('https://m.youtube.com/watch?v=BDYAbAtaDzA'),
array('http://youtu.be/BDYAbAtaDzA'),
);
}

Expand Down

0 comments on commit 84f51ed

Please sign in to comment.