2015-08-29 19:46:57 +00:00
|
|
|
<?php
|
2019-10-03 19:24:12 +00:00
|
|
|
|
2015-08-29 19:46:57 +00:00
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* VideoTest class.
|
2016-08-01 11:29:13 +00:00
|
|
|
*/
|
2016-12-05 12:12:27 +00:00
|
|
|
|
2016-03-29 23:49:08 +00:00
|
|
|
namespace Alltube\Test;
|
|
|
|
|
2016-10-18 08:45:16 +00:00
|
|
|
use Alltube\Config;
|
2019-04-21 16:30:02 +00:00
|
|
|
use Alltube\Video;
|
2015-08-29 19:46:57 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Unit tests for the Video class.
|
2016-08-01 11:29:13 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
class VideoTest extends BaseTest
|
2015-08-29 19:46:57 +00:00
|
|
|
{
|
2017-11-11 12:58:55 +00:00
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getExtractors function.
|
2016-10-18 08:45:16 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testGetExtractors()
|
2016-10-18 08:45:16 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$this->assertContains('youtube', Video::getExtractors());
|
2016-10-18 08:45:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getUrl function.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2017-01-02 22:08:51 +00:00
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
* @param string $filename Filename
|
|
|
|
* @param string $extension File extension
|
|
|
|
* @param string $domain Domain
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2015-10-29 17:40:22 +00:00
|
|
|
* @dataProvider urlProvider
|
2017-04-24 22:48:10 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
|
|
|
* @dataProvider remuxUrlProvider
|
2015-09-04 20:45:55 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testgetUrl(
|
2017-12-05 13:52:20 +00:00
|
|
|
$url,
|
|
|
|
$format,
|
|
|
|
/* @scrutinizer ignore-unused */ $filename,
|
|
|
|
/* @scrutinizer ignore-unused */ $extension,
|
|
|
|
$domain
|
|
|
|
) {
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
foreach ($video->getUrl() as $videoURL) {
|
|
|
|
$this->assertContains($domain, $videoURL);
|
|
|
|
}
|
2015-09-04 20:45:55 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 21:01:31 +00:00
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getUrl function with a protected video.
|
2016-10-20 21:01:31 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testgetUrlWithPassword()
|
2016-10-20 21:01:31 +00:00
|
|
|
{
|
2019-04-19 21:26:03 +00:00
|
|
|
if (getenv('CI')) {
|
|
|
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
|
|
|
}
|
2019-04-21 16:30:02 +00:00
|
|
|
|
|
|
|
$video = new Video('http://vimeo.com/68375962', 'best', 'youtube-dl');
|
|
|
|
foreach ($video->getUrl() as $videoURL) {
|
|
|
|
$this->assertContains('vimeocdn.com', $videoURL);
|
|
|
|
}
|
2016-10-20 21:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getUrl function with a protected video and no password.
|
2016-10-20 21:01:31 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2019-04-22 19:13:57 +00:00
|
|
|
* @expectedException Alltube\Exception\PasswordException
|
2016-10-20 21:01:31 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testgetUrlWithMissingPassword()
|
2016-10-20 21:01:31 +00:00
|
|
|
{
|
2019-04-19 21:26:03 +00:00
|
|
|
if (getenv('CI')) {
|
|
|
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
|
|
|
}
|
2019-04-21 16:30:02 +00:00
|
|
|
|
|
|
|
$video = new Video('http://vimeo.com/68375962');
|
|
|
|
$video->getUrl();
|
2016-10-20 21:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getUrl function with a protected video and a wrong password.
|
2016-10-20 21:01:31 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testgetUrlWithWrongPassword()
|
2016-10-20 21:01:31 +00:00
|
|
|
{
|
2019-04-19 21:26:03 +00:00
|
|
|
if (getenv('CI')) {
|
|
|
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
|
|
|
}
|
2019-04-21 16:30:02 +00:00
|
|
|
|
|
|
|
$video = new Video('http://vimeo.com/68375962', 'best', 'foo');
|
|
|
|
$video->getUrl();
|
2016-10-20 21:01:31 +00:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:45:55 +00:00
|
|
|
/**
|
2019-04-21 16:30:02 +00:00
|
|
|
* Test getUrl function errors.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2015-09-04 20:45:55 +00:00
|
|
|
* @param string $url URL
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2015-09-04 20:45:55 +00:00
|
|
|
* @expectedException Exception
|
2015-10-29 20:23:02 +00:00
|
|
|
* @dataProvider ErrorUrlProvider
|
2015-09-04 20:45:55 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testgetUrlError($url)
|
2015-09-04 20:45:55 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url);
|
|
|
|
$video->getUrl();
|
2015-09-04 20:45:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Provides URLs for tests.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-08-01 11:29:13 +00:00
|
|
|
* @return array[]
|
2015-09-04 20:45:55 +00:00
|
|
|
*/
|
2015-10-29 17:40:22 +00:00
|
|
|
public function urlProvider()
|
2015-09-04 20:45:55 +00:00
|
|
|
{
|
2019-04-19 21:26:03 +00:00
|
|
|
$videos = [
|
2016-09-07 22:28:28 +00:00
|
|
|
[
|
2017-01-16 10:29:56 +00:00
|
|
|
'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'best[protocol^=http]',
|
2017-05-30 22:57:39 +00:00
|
|
|
'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU',
|
2017-01-02 22:08:51 +00:00
|
|
|
'mp4',
|
2016-07-29 22:47:46 +00:00
|
|
|
'googlevideo.com',
|
2016-09-07 22:28:28 +00:00
|
|
|
],
|
|
|
|
[
|
2018-09-18 17:01:14 +00:00
|
|
|
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 18,
|
2019-10-03 19:24:12 +00:00
|
|
|
'Heart_Attack_-_Demi_Lovato_' .
|
2017-05-30 22:48:50 +00:00
|
|
|
'Sam_Tsui_Against_The_Current-RJJ6FCAXvKg',
|
2017-01-02 22:08:51 +00:00
|
|
|
'mp4',
|
2016-07-29 22:47:46 +00:00
|
|
|
'googlevideo.com',
|
2016-09-07 22:28:28 +00:00
|
|
|
],
|
|
|
|
[
|
2016-07-30 12:01:00 +00:00
|
|
|
'http://www.bbc.co.uk/programmes/b039g8p7', 'bestaudio/best',
|
2018-09-03 08:42:20 +00:00
|
|
|
'Kaleidoscope_Leonard_Cohen-b039d07m',
|
2017-01-02 22:08:51 +00:00
|
|
|
'flv',
|
2016-07-30 12:01:00 +00:00
|
|
|
'bbcodspdns.fcod.llnwd.net',
|
2016-09-07 22:28:28 +00:00
|
|
|
],
|
|
|
|
[
|
2016-07-30 12:01:00 +00:00
|
|
|
'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0', 'bestaudio/best',
|
2017-05-30 22:48:50 +00:00
|
|
|
'GRIP_sucht_den_Sommerkonig-folge-203-0',
|
2017-01-02 22:08:51 +00:00
|
|
|
'f4v',
|
2016-07-30 12:01:00 +00:00
|
|
|
'edgefcs.net',
|
2016-09-07 22:28:28 +00:00
|
|
|
],
|
2018-01-25 14:10:11 +00:00
|
|
|
[
|
2018-02-21 18:16:50 +00:00
|
|
|
'https://openload.co/f/kUEfGclsU9o', 'best[protocol^=http]',
|
|
|
|
'skyrim_no-audio_1080.mp4-kUEfGclsU9o',
|
2018-01-25 14:10:11 +00:00
|
|
|
'mp4',
|
2018-01-25 14:13:13 +00:00
|
|
|
'openload.co',
|
|
|
|
],
|
2016-12-26 23:10:18 +00:00
|
|
|
];
|
2019-04-19 21:26:03 +00:00
|
|
|
|
|
|
|
if (!getenv('CI')) {
|
|
|
|
// Travis is blacklisted by Vimeo.
|
|
|
|
$videos[] = [
|
|
|
|
'https://vimeo.com/24195442', 'best[protocol^=http]',
|
|
|
|
'Carving_the_Mountains-24195442',
|
|
|
|
'mp4',
|
|
|
|
'vimeocdn.com',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $videos;
|
2016-12-26 23:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-05-08 17:46:37 +00:00
|
|
|
* Provides URLs for remux tests.
|
2016-12-26 23:10:18 +00:00
|
|
|
*
|
|
|
|
* @return array[]
|
|
|
|
*/
|
2017-04-24 22:40:24 +00:00
|
|
|
public function remuxUrlProvider()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'bestvideo+bestaudio',
|
2017-05-30 22:57:39 +00:00
|
|
|
'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU',
|
2017-04-24 22:40:24 +00:00
|
|
|
'mp4',
|
|
|
|
'googlevideo.com',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-05-08 17:46:37 +00:00
|
|
|
* Provides M3U8 URLs for tests.
|
2017-04-24 22:40:24 +00:00
|
|
|
*
|
|
|
|
* @return array[]
|
|
|
|
*/
|
2017-01-16 12:47:29 +00:00
|
|
|
public function m3uUrlProvider()
|
2016-12-26 23:10:18 +00:00
|
|
|
{
|
2019-04-20 09:30:16 +00:00
|
|
|
$videos = [];
|
|
|
|
|
|
|
|
if (!getenv('CI')) {
|
|
|
|
// Twitter returns a 429 error when the test is ran too many times.
|
|
|
|
$videos[] = [
|
2017-12-10 17:47:42 +00:00
|
|
|
'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176',
|
2017-05-30 22:48:50 +00:00
|
|
|
'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576',
|
2017-01-16 10:23:47 +00:00
|
|
|
'mp4',
|
2016-12-26 14:50:26 +00:00
|
|
|
'video.twimg.com',
|
2019-04-20 09:30:16 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $videos;
|
2015-09-04 20:45:55 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 16:31:14 +00:00
|
|
|
/**
|
|
|
|
* Provides RTMP URLs for tests.
|
|
|
|
*
|
|
|
|
* @return array[]
|
|
|
|
*/
|
|
|
|
public function rtmpUrlProvider()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
2018-03-20 10:37:47 +00:00
|
|
|
'http://www.rtvnh.nl/video/131946', 'rtmp-264',
|
|
|
|
'Ketting_van_strandgasten-131946',
|
2017-05-04 21:28:29 +00:00
|
|
|
'flv',
|
2018-03-20 10:37:47 +00:00
|
|
|
'lb-nh-vod.cdn.streamgate.nl',
|
2017-04-24 16:31:14 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-09-04 20:45:55 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Provides incorrect URLs for tests.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-08-01 11:29:13 +00:00
|
|
|
* @return array[]
|
2015-09-04 20:45:55 +00:00
|
|
|
*/
|
2015-10-29 17:40:22 +00:00
|
|
|
public function errorUrlProvider()
|
2015-09-04 20:45:55 +00:00
|
|
|
{
|
2016-09-07 22:28:28 +00:00
|
|
|
return [
|
|
|
|
['http://example.com/video'],
|
|
|
|
];
|
2015-09-04 20:45:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getJSON function.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2015-09-04 20:45:55 +00:00
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2017-04-24 22:48:10 +00:00
|
|
|
* @dataProvider urlProvider
|
2017-01-16 12:47:29 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
2015-09-04 20:45:55 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testGetJson($url, $format)
|
2015-09-04 20:45:55 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$info = $video->getJson();
|
2015-09-04 20:45:55 +00:00
|
|
|
$this->assertObjectHasAttribute('webpage_url', $info);
|
|
|
|
$this->assertObjectHasAttribute('url', $info);
|
|
|
|
$this->assertObjectHasAttribute('ext', $info);
|
|
|
|
$this->assertObjectHasAttribute('title', $info);
|
2017-01-16 10:29:56 +00:00
|
|
|
$this->assertObjectHasAttribute('extractor_key', $info);
|
2018-01-25 14:10:11 +00:00
|
|
|
$this->assertObjectHasAttribute('format', $info);
|
2015-09-04 20:45:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getJSON function errors.
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2015-09-04 20:45:55 +00:00
|
|
|
* @param string $url URL
|
2015-10-29 17:40:22 +00:00
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2015-09-04 20:45:55 +00:00
|
|
|
* @expectedException Exception
|
2015-10-29 20:23:02 +00:00
|
|
|
* @dataProvider ErrorURLProvider
|
2015-08-29 19:46:57 +00:00
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
public function testGetJsonError($url)
|
2015-08-29 19:46:57 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url);
|
|
|
|
$video->getJson();
|
2015-08-29 19:46:57 +00:00
|
|
|
}
|
2016-07-29 22:47:46 +00:00
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getFilename function.
|
2016-07-29 22:47:46 +00:00
|
|
|
*
|
2017-01-02 22:08:51 +00:00
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
* @param string $filename Filename
|
|
|
|
* @param string $extension File extension
|
2016-07-29 22:47:46 +00:00
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2016-07-29 22:47:46 +00:00
|
|
|
* @dataProvider urlProvider
|
2017-01-16 12:47:29 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
2017-04-24 22:48:10 +00:00
|
|
|
* @dataProvider remuxUrlProvider
|
2016-07-29 22:47:46 +00:00
|
|
|
*/
|
2017-01-02 22:08:51 +00:00
|
|
|
public function testGetFilename($url, $format, $filename, $extension)
|
2016-07-29 22:47:46 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
2019-10-03 19:24:12 +00:00
|
|
|
$this->assertEquals($video->getFilename(), $filename . '.' . $extension);
|
2016-07-29 22:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getFilename function errors.
|
2016-07-29 22:47:46 +00:00
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2016-07-29 22:47:46 +00:00
|
|
|
* @expectedException Exception
|
|
|
|
* @dataProvider ErrorUrlProvider
|
|
|
|
*/
|
|
|
|
public function testGetFilenameError($url)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url);
|
|
|
|
$video->getFilename();
|
2016-07-29 22:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getAudioStream function.
|
2016-07-29 22:47:46 +00:00
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2016-07-29 22:47:46 +00:00
|
|
|
* @dataProvider urlProvider
|
|
|
|
*/
|
|
|
|
public function testGetAudioStream($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$this->assertStream($video->getAudioStream());
|
2016-07-29 22:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Test getAudioStream function without avconv.
|
2016-07-29 22:47:46 +00:00
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
2016-09-07 22:28:28 +00:00
|
|
|
* @return void
|
2016-07-29 22:47:46 +00:00
|
|
|
* @expectedException Exception
|
|
|
|
* @dataProvider urlProvider
|
|
|
|
*/
|
|
|
|
public function testGetAudioStreamAvconvError($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
Config::setOptions(['avconv' => 'foobar']);
|
|
|
|
|
|
|
|
$video = new Video($url, $format);
|
|
|
|
$video->getAudioStream();
|
2016-07-29 22:47:46 +00:00
|
|
|
}
|
2016-07-30 12:01:00 +00:00
|
|
|
|
2016-12-26 23:01:42 +00:00
|
|
|
/**
|
|
|
|
* Test getAudioStream function with a M3U8 file.
|
|
|
|
*
|
2016-12-26 23:36:30 +00:00
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
2017-01-16 12:47:29 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
2016-12-26 23:36:30 +00:00
|
|
|
*/
|
|
|
|
public function testGetAudioStreamM3uError($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$video->getAudioStream();
|
2016-12-26 23:36:30 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 14:28:33 +00:00
|
|
|
/**
|
|
|
|
* Test getAudioStream function with a DASH URL.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
|
|
|
*/
|
|
|
|
public function testGetAudioStreamDashError()
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
if (getenv('CI')) {
|
|
|
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$video = new Video('https://vimeo.com/251997032', 'bestaudio/best');
|
|
|
|
$video->getAudioStream();
|
2018-05-01 14:28:33 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 20:52:15 +00:00
|
|
|
/**
|
|
|
|
* Test getAudioStream function with a playlist.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
|
|
|
*/
|
|
|
|
public function testGetAudioStreamPlaylistError()
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video(
|
2018-05-26 12:38:42 +00:00
|
|
|
'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC',
|
|
|
|
'best'
|
|
|
|
);
|
2019-04-21 16:30:02 +00:00
|
|
|
$video->getAudioStream();
|
2018-05-23 20:52:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 22:08:35 +00:00
|
|
|
/**
|
2017-04-25 22:10:00 +00:00
|
|
|
* Assert that a stream is valid.
|
2017-04-25 22:08:35 +00:00
|
|
|
*
|
|
|
|
* @param resource $stream Stream
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function assertStream($stream)
|
|
|
|
{
|
|
|
|
$this->assertInternalType('resource', $stream);
|
|
|
|
$this->assertFalse(feof($stream));
|
|
|
|
}
|
|
|
|
|
2016-12-26 23:36:30 +00:00
|
|
|
/**
|
|
|
|
* Test getM3uStream function.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
2017-01-16 12:47:29 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
2016-12-26 23:36:30 +00:00
|
|
|
*/
|
|
|
|
public function testGetM3uStream($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$this->assertStream($video->getM3uStream());
|
2016-12-26 23:36:30 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 22:40:24 +00:00
|
|
|
/**
|
|
|
|
* Test getRemuxStream function.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @dataProvider remuxUrlProvider
|
|
|
|
*/
|
|
|
|
public function testGetRemuxStream($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$this->assertStream($video->getRemuxStream());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test getRemuxStream function with a video with only one URL.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @dataProvider urlProvider
|
|
|
|
* @expectedException Exception
|
|
|
|
*/
|
|
|
|
public function testGetRemuxStreamWithWrongVideo($url, $format)
|
|
|
|
{
|
|
|
|
$video = new Video($url, $format);
|
|
|
|
$video->getRemuxStream();
|
2017-04-24 22:40:24 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 16:31:14 +00:00
|
|
|
/**
|
|
|
|
* Test getRtmpStream function.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @dataProvider rtmpUrlProvider
|
|
|
|
*/
|
|
|
|
public function testGetRtmpStream($url, $format)
|
|
|
|
{
|
2019-01-15 10:25:49 +00:00
|
|
|
$this->markTestIncomplete('We need to find another RTMP video.');
|
|
|
|
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
|
|
|
|
$this->assertStream($video->getRtmpStream());
|
2017-04-24 16:31:14 +00:00
|
|
|
}
|
|
|
|
|
2016-12-26 23:36:30 +00:00
|
|
|
/**
|
|
|
|
* Test getM3uStream function without avconv.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
2016-12-26 23:01:42 +00:00
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
2017-01-16 12:47:29 +00:00
|
|
|
* @dataProvider m3uUrlProvider
|
2016-12-26 23:01:42 +00:00
|
|
|
*/
|
2016-12-26 23:36:30 +00:00
|
|
|
public function testGetM3uStreamAvconvError($url, $format)
|
2016-12-26 23:01:42 +00:00
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
Config::setOptions(['avconv' => 'foobar']);
|
|
|
|
|
|
|
|
$video = new Video($url, $format);
|
|
|
|
$video->getM3uStream();
|
2016-12-26 23:01:42 +00:00
|
|
|
}
|
2017-05-02 15:04:55 +00:00
|
|
|
|
2018-01-24 22:30:24 +00:00
|
|
|
/**
|
|
|
|
* Test getConvertedStream function without avconv.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @dataProvider urlProvider
|
|
|
|
*/
|
|
|
|
public function testGetConvertedStream($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$this->assertStream($video->getConvertedStream(32, 'flv'));
|
2018-01-24 22:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test getConvertedStream function with a M3U8 file.
|
|
|
|
*
|
|
|
|
* @param string $url URL
|
|
|
|
* @param string $format Format
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @expectedException Exception
|
|
|
|
* @dataProvider m3uUrlProvider
|
|
|
|
*/
|
|
|
|
public function testGetConvertedStreamM3uError($url, $format)
|
|
|
|
{
|
2019-04-21 16:30:02 +00:00
|
|
|
$video = new Video($url, $format);
|
|
|
|
$video->getConvertedStream(32, 'flv');
|
2018-01-24 22:30:24 +00:00
|
|
|
}
|
2015-08-29 19:46:57 +00:00
|
|
|
}
|