Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudloff committed May 26, 2018
2 parents 4539a11 + 2fc1cd3 commit 106c08e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions classes/EmptyUrlException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* EmptyUrlException class.
*/

namespace Alltube;

use Exception;

/**
* Exception thrown when youtube-dl returns an empty URL.
*/
class EmptyUrlException extends Exception
{
}
13 changes: 12 additions & 1 deletion classes/VideoDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ public function getJSON($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;
}

/**
Expand Down Expand Up @@ -325,6 +331,11 @@ private function getAvconvProcess(stdClass $video, $audioBitrate, $filetype = 'm
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') {
Expand Down
1 change: 1 addition & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ params:
- --ignore-errors
- --flat-playlist
- --restrict-filenames
- --no-playlist

# True to enable audio conversion
convert: false
Expand Down
19 changes: 14 additions & 5 deletions controllers/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Alltube\Controller;

use Alltube\Config;
use Alltube\EmptyUrlException;
use Alltube\Locale;
use Alltube\LocaleManager;
use Alltube\PasswordException;
Expand Down Expand Up @@ -456,11 +457,19 @@ private function getFormat(Request $request)
*/
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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 0 additions & 1 deletion templates/video.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
14 changes: 14 additions & 0 deletions tests/VideoDownloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,20 @@ public function testGetAudioStreamDashError()
$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.
*
Expand Down

0 comments on commit 106c08e

Please sign in to comment.