1
0
mirror of https://github.com/Rudloff/alltube.git synced 2024-06-20 06:46:40 +02:00

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
[![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/))
![Screenshot](img/screenshot.png "AllTube GUI screenshot")

View File

@ -39,7 +39,7 @@ class Config
*
* @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.

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)
{
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)
{
$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'])) {
throw new Exception(_('Conversion of M3U8 files is not supported.'));
} elseif ($video->protocol == 'http_dash_segments') {

View File

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

View File

@ -6,6 +6,7 @@
namespace Alltube\Controller;
use Alltube\Config;
use Alltube\EmptyUrlException;
use Alltube\Locale;
use Alltube\LocaleManager;
use Alltube\PasswordException;
@ -456,11 +457,19 @@ class FrontController
*/
private function getRedirectResponse($url, $format, Response $response, Request $request)
{
$videoUrls = $this->download->getURL(
$url,
$format,
$this->sessionSegment->getFlash($url)
);
try {
$videoUrls = $this->download->getURL(
$url,
$format,
$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) {
return $this->getRemuxStream($videoUrls, $format, $response, $request);
} elseif ($this->config->stream) {

View File

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

View File

@ -79,7 +79,6 @@
{/if}
{/foreach}
</optgroup>
<option value="{$format->format_id}">
</select><br/><br/>
{if $config->convertAdvanced}
<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');
}
/**
* 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.
*