Bring audio conversion back (fixes #7)
This commit is contained in:
parent
4dd9d90858
commit
83cb546925
4 changed files with 46 additions and 96 deletions
|
@ -15,3 +15,4 @@ __Please use a different name and logo if you run it on a public server.__
|
||||||
|
|
||||||
##Other dependencies
|
##Other dependencies
|
||||||
You need [avconv](https://libav.org/avconv.html) and [rtmpdump](http://rtmpdump.mplayerhq.hu/) in order to enable conversions.
|
You need [avconv](https://libav.org/avconv.html) and [rtmpdump](http://rtmpdump.mplayerhq.hu/) in order to enable conversions.
|
||||||
|
If you don't want to enable conversions, you can disable it in *config.php*.
|
||||||
|
|
124
api.php
124
api.php
|
@ -12,7 +12,7 @@
|
||||||
* */
|
* */
|
||||||
require_once 'download.php';
|
require_once 'download.php';
|
||||||
if (isset($_GET["url"])) {
|
if (isset($_GET["url"])) {
|
||||||
if (isset($_GET["format"]) || isset($_GET['audio'])) {
|
if (isset($_GET['audio'])) {
|
||||||
$video = VideoDownload::getJSON($_GET["url"], $_GET["format"]);
|
$video = VideoDownload::getJSON($_GET["url"], $_GET["format"]);
|
||||||
|
|
||||||
if (isset($video->url)) {
|
if (isset($video->url)) {
|
||||||
|
@ -24,100 +24,40 @@ if (isset($_GET["url"])) {
|
||||||
);
|
);
|
||||||
$url_info = parse_url($video->url);
|
$url_info = parse_url($video->url);
|
||||||
if ($url_info['scheme'] == 'rtmp') {
|
if ($url_info['scheme'] == 'rtmp') {
|
||||||
if (isset($_GET['audio'])) {
|
header(
|
||||||
header(
|
'Content-Disposition: attachment; filename="'.
|
||||||
'Content-Disposition: attachment; filename="'.
|
html_entity_decode(
|
||||||
html_entity_decode(
|
pathinfo(
|
||||||
pathinfo(
|
|
||||||
VideoDownload::getFilename(
|
|
||||||
$video->webpage_url
|
|
||||||
), PATHINFO_FILENAME
|
|
||||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
|
||||||
).'"'
|
|
||||||
);
|
|
||||||
header("Content-Type: audio/mpeg");
|
|
||||||
passthru(
|
|
||||||
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
|
|
||||||
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
|
|
||||||
);
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
header(
|
|
||||||
'Content-Disposition: attachment; filename="'.
|
|
||||||
html_entity_decode(
|
|
||||||
VideoDownload::getFilename(
|
VideoDownload::getFilename(
|
||||||
$video->webpage_url, $video->format_id
|
$video->webpage_url
|
||||||
), ENT_COMPAT, 'ISO-8859-1'
|
), PATHINFO_FILENAME
|
||||||
).'"'
|
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||||
);
|
).'"'
|
||||||
header("Content-Type: application/octet-stream");
|
);
|
||||||
passthru(
|
header("Content-Type: audio/mpeg");
|
||||||
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url)
|
passthru(
|
||||||
);
|
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
|
||||||
exit;
|
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
|
||||||
}
|
);
|
||||||
|
exit;
|
||||||
} else {
|
} else {
|
||||||
if (isset($_GET['audio'])) {
|
header(
|
||||||
header(
|
'Content-Disposition: attachment; filename="'.
|
||||||
'Content-Disposition: attachment; filename="'.
|
html_entity_decode(
|
||||||
html_entity_decode(
|
pathinfo(
|
||||||
pathinfo(
|
|
||||||
VideoDownload::getFilename(
|
|
||||||
$video->webpage_url
|
|
||||||
), PATHINFO_FILENAME
|
|
||||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
|
||||||
).'"'
|
|
||||||
);
|
|
||||||
header("Content-Type: audio/mpeg");
|
|
||||||
passthru(
|
|
||||||
'/usr/bin/wget -q --user-agent='.escapeshellarg($UA).
|
|
||||||
' -O - '.escapeshellarg($video->url).
|
|
||||||
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
|
|
||||||
);
|
|
||||||
exit;
|
|
||||||
} else if (pathinfo($video->url, PATHINFO_EXTENSION) == 'm3u8') {
|
|
||||||
header(
|
|
||||||
'Content-Disposition: attachment; filename="'.
|
|
||||||
html_entity_decode(
|
|
||||||
pathinfo(
|
|
||||||
VideoDownload::getFilename(
|
|
||||||
$video->webpage_url
|
|
||||||
), PATHINFO_FILENAME
|
|
||||||
).'.mp4', ENT_COMPAT, 'ISO-8859-1'
|
|
||||||
).'"'
|
|
||||||
);
|
|
||||||
header("Content-Type: video/mp4");
|
|
||||||
passthru(
|
|
||||||
'/usr/bin/avconv -v quiet -i '.
|
|
||||||
escapeshellarg($video->url).' -f h264 pipe:1'
|
|
||||||
);
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$headers = get_headers($video->url, 1);
|
|
||||||
header(
|
|
||||||
'Content-Disposition: attachment; filename="'.
|
|
||||||
html_entity_decode(
|
|
||||||
VideoDownload::getFilename(
|
VideoDownload::getFilename(
|
||||||
$video->webpage_url, $video->format_id
|
$video->webpage_url
|
||||||
), ENT_COMPAT, 'ISO-8859-1'
|
), PATHINFO_FILENAME
|
||||||
).'"'
|
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||||
);
|
).'"'
|
||||||
if (is_string($headers['Content-Type'])
|
);
|
||||||
&& isset($headers['Content-Type'])
|
header("Content-Type: audio/mpeg");
|
||||||
) {
|
passthru(
|
||||||
header("Content-Type: ".$headers['Content-Type']);
|
'/usr/bin/wget -q --user-agent='.escapeshellarg($UA).
|
||||||
} else {
|
' -O - '.escapeshellarg($video->url).
|
||||||
header("Content-Type: application/octet-stream");
|
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
|
||||||
}
|
);
|
||||||
if (is_string($headers['Content-Length'])
|
exit;
|
||||||
&& isset($headers['Content-Length'])
|
|
||||||
) {
|
|
||||||
header("Content-Length: ".$headers['Content-Length']);
|
|
||||||
}
|
|
||||||
readfile($video->url);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error=true;
|
$error=true;
|
||||||
|
|
|
@ -14,4 +14,5 @@
|
||||||
define('YOUTUBE_DL', './youtube-dl');
|
define('YOUTUBE_DL', './youtube-dl');
|
||||||
define('PYTHON', '/usr/bin/python');
|
define('PYTHON', '/usr/bin/python');
|
||||||
define('PARAMS', '--no-playlist --no-warnings');
|
define('PARAMS', '--no-playlist --no-warnings');
|
||||||
|
define('CONVERT', true);
|
||||||
?>
|
?>
|
||||||
|
|
16
index.php
16
index.php
|
@ -19,6 +19,7 @@ require 'head.php';
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require 'header.php';
|
require 'header.php';
|
||||||
|
require 'config.php';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
@ -35,10 +36,17 @@ require 'head.php';
|
||||||
required placeholder="http://website.com/video" />
|
required placeholder="http://website.com/video" />
|
||||||
</span>
|
</span>
|
||||||
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||||
<div class="mp3">
|
<?php
|
||||||
<p><input type="checkbox" id="audio" class="audio" name="audio">
|
if (CONVERT) {
|
||||||
<label for="audio"><span class="ui"></span>Audio only (MP3)</label></p>
|
?>
|
||||||
</div>
|
<div class="mp3">
|
||||||
|
<p><input type="checkbox" id="audio" class="audio" name="audio">
|
||||||
|
<label for="audio"><span class="ui"></span>
|
||||||
|
Audio only (MP3)</label></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<a class="combatiblelink" href="extractors.php">See all supported websites</a>
|
<a class="combatiblelink" href="extractors.php">See all supported websites</a>
|
||||||
|
|
Loading…
Reference in a new issue