From 6dc3f5b4ebb14f2c5edce48f34e6bf641e9e544a Mon Sep 17 00:00:00 2001 From: Timendum Date: Tue, 23 Feb 2016 15:45:24 +0100 Subject: [PATCH] add format and output --- class/Downloader.php | 23 ++++++++++++++++++--- index.php | 49 ++++++++++++++++++++++++++++++++++++-------- views/footer.php | 4 ++-- views/header.php | 2 +- 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/class/Downloader.php b/class/Downloader.php index af921bc..76d14eb 100644 --- a/class/Downloader.php +++ b/class/Downloader.php @@ -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 "; diff --git a/index.php b/index.php index 68ac273..9642454 100644 --- a/index.php +++ b/index.php @@ -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 @@ } ?> -
+
-
- +
+ URLs: + +
+
+
+
+
-
- +
+
+ +
+
+
+
+
+ Filename: + +
+
+
+
+ Format: +
- +
diff --git a/views/footer.php b/views/footer.php index a4c68ed..5adbc56 100644 --- a/views/footer.php +++ b/views/footer.php @@ -3,8 +3,8 @@

Fork on Github

- - + +