Merge branch 'release-1.1.2'

This commit is contained in:
Pierre Rudloff 2018-05-26 14:46:37 +02:00
commit 106c08e562
9 changed files with 60 additions and 9 deletions

View file

@ -1,5 +1,7 @@
# AllTube Download # AllTube Download
[![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/Rudloff/donate)
HTML GUI for youtube-dl ([alltubedownload.net](http://alltubedownload.net/)) HTML GUI for youtube-dl ([alltubedownload.net](http://alltubedownload.net/))
![Screenshot](img/screenshot.png "AllTube GUI screenshot") ![Screenshot](img/screenshot.png "AllTube GUI screenshot")

View file

@ -39,7 +39,7 @@ class Config
* *
* @var array * @var array
*/ */
public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames']; public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist'];
/** /**
* Enable audio conversion. * Enable audio conversion.

View file

@ -0,0 +1,15 @@
<?php
/**
* EmptyUrlException class.
*/
namespace Alltube;
use Exception;
/**
* Exception thrown when youtube-dl returns an empty URL.
*/
class EmptyUrlException extends Exception
{
}

View file

@ -152,7 +152,13 @@ class VideoDownload
* */ * */
public function getURL($url, $format = null, $password = null) public function getURL($url, $format = null, $password = null)
{ {
return explode("\n", $this->getProp($url, $format, 'get-url', $password)); $urls = explode("\n", $this->getProp($url, $format, 'get-url', $password));
if (empty($urls[0])) {
throw new EmptyUrlException(_('youtube-dl returned an empty URL.'));
}
return $urls;
} }
/** /**
@ -325,6 +331,11 @@ class VideoDownload
public function getAudioStream($url, $format, $password = null) public function getAudioStream($url, $format, $password = null)
{ {
$video = $this->getJSON($url, $format, $password); $video = $this->getJSON($url, $format, $password);
if (isset($video->_type) && $video->_type == 'playlist') {
throw new Exception(_('Conversion of playlists is not supported.'));
}
if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) { if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) {
throw new Exception(_('Conversion of M3U8 files is not supported.')); throw new Exception(_('Conversion of M3U8 files is not supported.'));
} elseif ($video->protocol == 'http_dash_segments') { } elseif ($video->protocol == 'http_dash_segments') {

View file

@ -11,6 +11,7 @@ params:
- --ignore-errors - --ignore-errors
- --flat-playlist - --flat-playlist
- --restrict-filenames - --restrict-filenames
- --no-playlist
# True to enable audio conversion # True to enable audio conversion
convert: false convert: false

View file

@ -6,6 +6,7 @@
namespace Alltube\Controller; namespace Alltube\Controller;
use Alltube\Config; use Alltube\Config;
use Alltube\EmptyUrlException;
use Alltube\Locale; use Alltube\Locale;
use Alltube\LocaleManager; use Alltube\LocaleManager;
use Alltube\PasswordException; use Alltube\PasswordException;
@ -456,11 +457,19 @@ class FrontController
*/ */
private function getRedirectResponse($url, $format, Response $response, Request $request) private function getRedirectResponse($url, $format, Response $response, Request $request)
{ {
try {
$videoUrls = $this->download->getURL( $videoUrls = $this->download->getURL(
$url, $url,
$format, $format,
$this->sessionSegment->getFlash($url) $this->sessionSegment->getFlash($url)
); );
} catch (EmptyUrlException $e) {
/*
If this happens it is probably a playlist
so it will either be handle by getStream() or throw an exception anyway.
*/
$videoUrls = [];
}
if (count($videoUrls) > 1) { if (count($videoUrls) > 1) {
return $this->getRemuxStream($videoUrls, $format, $response, $request); return $this->getRemuxStream($videoUrls, $format, $response, $request);
} elseif ($this->config->stream) { } elseif ($this->config->stream) {

View file

@ -1,7 +1,7 @@
{ {
"name": "alltube", "name": "alltube",
"description": "HTML GUI for youtube-dl", "description": "HTML GUI for youtube-dl",
"version": "1.1.1", "version": "1.1.2",
"author": "Pierre Rudloff", "author": "Pierre Rudloff",
"bugs": "https://github.com/Rudloff/alltube/issues", "bugs": "https://github.com/Rudloff/alltube/issues",
"dependencies": { "dependencies": {

View file

@ -79,7 +79,6 @@
{/if} {/if}
{/foreach} {/foreach}
</optgroup> </optgroup>
<option value="{$format->format_id}">
</select><br/><br/> </select><br/><br/>
{if $config->convertAdvanced} {if $config->convertAdvanced}
<input type="checkbox" name="customConvert" id="customConvert"/> <input type="checkbox" name="customConvert" id="customConvert"/>

View file

@ -417,6 +417,20 @@ class VideoDownloadTest extends TestCase
$this->download->getAudioStream('https://vimeo.com/251997032', 'bestaudio/best'); $this->download->getAudioStream('https://vimeo.com/251997032', 'bestaudio/best');
} }
/**
* Test getAudioStream function with a playlist.
*
* @return void
* @expectedException Exception
*/
public function testGetAudioStreamPlaylistError()
{
$this->download->getAudioStream(
'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC',
'best'
);
}
/** /**
* Assert that a stream is valid. * Assert that a stream is valid.
* *