Skip to content

Commit

Permalink
Add option to set filename of downloaded file for HTTP/FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
e-alfred committed Sep 19, 2017
1 parent 7432dcf commit 22b0068
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions controller/ftpdownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public function add()
if (isset ($_POST['OPTIONS']['FTPUseragent']) && strlen (trim ($_POST['OPTIONS']['FTPUseragent'])) > 0) {
$OPTIONS['user-agent'] = $_POST['OPTIONS']['FTPUseragent'];
}
if (isset ($_POST['OPTIONS']['FTPOutfilename']) && strlen (trim ($_POST['OPTIONS']['FTPOutfilename'])) > 0) {
$OPTIONS['out'] = $_POST['OPTIONS']['FTPOutfilename'];
}
if (isset($_POST['OPTIONS']['FTPPasv']) && strlen(trim($_POST['OPTIONS']['FTPPasv'])) > 0) {
$OPTIONS['ftp-pasv'] = strcmp($_POST['OPTIONS']['FTPPasv'], "true") == 0 ? true : false;
}
Expand Down
5 changes: 4 additions & 1 deletion controller/httpdownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ public function add()
if (isset ($_POST['OPTIONS']['HTTPReferer']) && strlen (trim ($_POST['OPTIONS']['HTTPReferer'])) > 0) {
$OPTIONS['referer'] = $_POST['OPTIONS']['HTTPReferer'];
}
if (isset ($_POST['OPTIONS']['HTTPUseragent']) && strlen (trim ($_POST['OPTIONS']['HTTPUseragent'])) > 0) {
if (isset ($_POST['OPTIONS']['HTTPUseragent']) && strlen (trim ($_POST['OPTIONS']['HTTPUseragent'])) > 0) {
$OPTIONS['user-agent'] = $_POST['OPTIONS']['HTTPUseragent'];
}
if (isset ($_POST['OPTIONS']['HTTPOutfilename']) && strlen (trim ($_POST['OPTIONS']['HTTPOutfilename'])) > 0) {
$OPTIONS['out'] = $_POST['OPTIONS']['HTTPOutfilename'];
}
if (!$this->ProxyOnlyWithYTDL && !is_null($this->ProxyAddress)
&& $this->ProxyPort > 0 && $this->ProxyPort <= 65536) {
$OPTIONS['all-proxy'] = rtrim($this->ProxyAddress, '/') . ':' . $this->ProxyPort;
Expand Down
7 changes: 5 additions & 2 deletions js/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ $(document).ready (function ()
HTTPUser: $('#option-http-user').val (),
HTTPPasswd: $('#option-http-pwd').val (),
HTTPReferer: $('#option-http-referer').val (),
HTTPUseragent: $('#option-http-useragent').val ()
HTTPUseragent: $('#option-http-useragent').val (),
HTTPOutfilename: $('#option-http-outfilename').val ()
});
}
else
Expand All @@ -81,6 +82,7 @@ $(document).ready (function ()
$('#option-http-pwd').val ('');
$('#option-http-referer').val ('');
$('#option-http-useragent').val ('');
$('#option-http-outfilename').val ('');
});

// Launch FTP download
Expand All @@ -96,7 +98,8 @@ $(document).ready (function ()
FTPPasswd: $('#option-ftp-pwd').val (),
FTPPasv: $('#option-ftp-pasv').prop ('checked'),
FTPReferer: $('#option-ftp-referer').val (),
FTPUseragent: $('#option-ftp-useragent').val ()
FTPUseragent: $('#option-ftp-useragent').val (),
FTPOutfilename: $('#option-ftp-outfilename').val ()
});
}
else
Expand Down
2 changes: 1 addition & 1 deletion js/add.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions templates/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<label for="option-http-pwd"><?php print ($l->t ('Basic Auth Password')); ?> :</label><input type="password" id="option-http-pwd" placeholder="<?php print ($l->t ('Password')); ?>" />
<label for="option-http-referer"><?php print ($l->t ('HTTP Referer')); ?> :</label><input type="text" id="option-http-referer" placeholder="<?php print ($l->t ('Referer')); ?>" />
<label for="option-http-useragent"><?php print ($l->t ('HTTP User Agent')); ?> :</label><input type="text" id="option-http-useragent" placeholder="<?php print ($l->t ('Useragent')); ?>" />
<label for="option-http-outfilename"><?php print ($l->t ('HTTP Output Filename')); ?> :</label><input type="text" id="option-http-outfilename" placeholder="<?php print ($l->t ('Filename')); ?>" />
</div>
</div>
</div>
Expand All @@ -88,6 +89,7 @@
<label for="option-ftp-pwd"><?php print ($l->t ('FTP Password')); ?> :</label><input type="password" id="option-ftp-pwd" placeholder="<?php print ($l->t ('Password')); ?>" />
<label for="option-ftp-referer"><?php print ($l->t ('FTP Referer')); ?> :</label><input type="text" id="option-ftp-referer" placeholder="<?php print ($l->t ('Referer')); ?>" />
<label for="option-ftp-useragent"><?php print ($l->t ('FTP User Agent')); ?> :</label><input type="text" id="option-ftp-useragent" placeholder="<?php print ($l->t ('Useragent')); ?>" />
<label for="option-ftp-outfilename"><?php print ($l->t ('FTP Output Filename')); ?> :</label><input type="text" id="option-ftp-outfilename" placeholder="<?php print ($l->t ('Filename')); ?>" />
</div>
<div class="group-option">
<label for="option-ftp-pasv"><?php print ($l->t ('Passive Mode')); ?> :</label><input type="checkbox" id="option-ftp-pasv" checked />
Expand Down

0 comments on commit 22b0068

Please sign in to comment.