add format and output

This commit is contained in:
Timendum 2016-02-23 15:45:24 +01:00
parent 4fe46d802f
commit 6dc3f5b4eb
4 changed files with 63 additions and 15 deletions

View file

@ -8,8 +8,10 @@ class Downloader
private $errors = [];
private $download_path = "";
private $log_path = "";
private $outfilename = "%(title)s-%(uploader)s.%(ext)s";
private $vformat = false;
public function __construct($post, $audio_only)
public function __construct($post, $audio_only, $outfilename=False, $vformat=False)
{
$this->config = require dirname(__DIR__).'/config/config.php';
@ -35,6 +37,15 @@ class Downloader
{
return;
}
if ($outfilename)
{
$this>outfilename = $outfilename;
}
if ($vformat)
{
$this>vformat = $vformat;
}
foreach ($this->urls as $url)
{
@ -217,8 +228,14 @@ class Downloader
{
$cmd = "youtube-dl";
$cmd .= " -o ".$this->config["outputFolder"]."/";
$cmd .= escapeshellarg("%(title)s-%(uploader)s.%(ext)s");
$cmd .= escapeshellarg($this->outfilename);
if ($this->vformat)
{
$cmd .= " --format ";
$cmd .= escapeshellarg($this->vformat);
}
if($this->audio_only)
{
$cmd .= " -x ";

View file

@ -22,11 +22,22 @@
if(isset($_POST['urls']) && !empty($_POST['urls']))
{
$audio_only = false;
if(isset($_POST['audio']) && !empty($_POST['audio']))
{
$audio_only = true;
}
$outfilename = ''
if(isset($_POST['outfilename']) && !empty($_POST['outfilename']))
{
$outfilename = $_POST['outfilename'];
}
$vformat = ''
if(isset($_POST['vformat']) && !empty($_POST['vformat']))
{
$vformat = $_POST['vformat'];
}
$downloader = new Downloader($_POST['urls'], $audio_only);
@ -50,20 +61,40 @@
}
?>
<form id="download-form" class="form-horizontal" action="index.php" method="post">
<form id="download-form" action="index.php" method="post">
<div class="form-group">
<div class="col-md-10">
<input class="form-control" id="url" name="urls" placeholder="Link(s) separated by a comma" type="text">
<div class="input-group">
<span class="input-group-addon" id="urls-addon">URLs:</span>
<input class="form-control" id="url" name="urls" placeholder="Link(s) separated by a comma" type="text" aria-describedby="urls-addon" />
</div>
</div>
<div class="row">
<div class="col-md-2">
<button type="submit" class="btn btn-primary">Download</button>
</div>
<div class="col-md-2">
<div class="checkbox">
<label>
<input type="checkbox" name="audio"> Audio Only
</label>
<div class="input-group">
<div class="checkbox">
<label>
<input type="checkbox" name="audio" /> Audio Only
</label>
</div>
</div>
</div>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon" id="outfilename-addon">Filename:</span>
<input class="form-control" id="outfilename" name="outfilename" placeholder="Output filename template" type="text" aria-describedby="outfilename-addon" />
</div>
</div>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon" id="vformat-addon">Format:</span>
<input class="form-control" id="vformat" name="vformat" placeholder="Video format code" type="text" aria-describedby="vformat-addon" />
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Download</button>
</form>
<br>
<div class="row">

View file

@ -3,8 +3,8 @@
<p><a href="https://github.com/timendum/Youtube-dl-WebUI" target="_blank">Fork on Github</a></p>
</div>
</footer>
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#url").focus();

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Youtube-dl WebUI</title>
<link rel="stylesheet" href="css/bootstrap.min.css" media="screen">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" media="screen">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>