moved settings button to bottom and made it collapsible;use nc's built-in filepicker to set download and torrents folders;fixed issues of youtube-dl filenames exceeding the maximum length
This commit is contained in:
@@ -33,6 +33,7 @@ class MainController extends Controller
|
||||
OC_Util::setupFS();
|
||||
$this->aria2 = $aria2;
|
||||
$this->aria2->init();
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->dbconn = new DbHelper();
|
||||
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
|
||||
}
|
||||
@@ -51,7 +52,9 @@ class MainController extends Controller
|
||||
$params['aria2_installed'] = $this->aria2->isInstalled();
|
||||
$params['youtube_installed'] = (bool) Helper::findBinaryPath('youtube-dl');
|
||||
$params['counter'] = $this->counters->getCounters();
|
||||
|
||||
$params['settings_url'] = $this->urlGenerator->linkToRoute("settings.PersonalSettings.index", ['section' => 'ncdownloader']);
|
||||
$params['admin_settings_url'] = $this->urlGenerator->linkToRoute("settings.AdminSettings.index", ['section' => 'ncdownloader']);
|
||||
$params['is_admin'] = \OC_User::isAdminUser($this->uid);
|
||||
$response = new TemplateResponse($this->appName, 'Index', $params);
|
||||
|
||||
return $response;
|
||||
|
||||
@@ -9,6 +9,7 @@ class Helper
|
||||
{
|
||||
public const DOWNLOADTYPE = ['ARIA2' => 1, 'YOUTUBE-DL' => 2, 'OTHERS' => 3];
|
||||
public const STATUS = ['ACTIVE' => 1, 'PAUSED' => 2, 'COMPLETE' => 3, 'WAITING' => 4, 'ERROR' => 5];
|
||||
const MAXLEN = 255;
|
||||
|
||||
public static function isUrl($URL)
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class Helper
|
||||
public static function isGetUrlSite($url)
|
||||
{
|
||||
$host = parse_url($url, PHP_URL_HOST);
|
||||
$sites = ['twitter.com', 'www.twitter.com'];
|
||||
//$sites = ['twitter.com', 'www.twitter.com'];
|
||||
return (bool) (in_array($host, $sites));
|
||||
}
|
||||
public static function parseUrl($url)
|
||||
@@ -66,10 +67,11 @@ class Helper
|
||||
public static function getFilename($url)
|
||||
{
|
||||
if (self::isMagnet($url)) {
|
||||
return self::parseUrl($url)['dn'];
|
||||
$filename = self::parseUrl($url)['dn'];
|
||||
} else {
|
||||
return self::getUrlPath($url);
|
||||
$filename = self::getUrlPath($url);
|
||||
}
|
||||
return substr($filename, 0, self::MAXLEN);
|
||||
}
|
||||
public static function formatBytes($size, $precision = 2)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class Youtube
|
||||
private $options = [];
|
||||
private $downloadDir;
|
||||
private $timeout = 60 * 60 * 10; //10 hours
|
||||
private $outTpl = "%(id)s-%(title)s.%(ext)s";
|
||||
private $outTpl = "%(id)s-%(title).64s.%(ext)s";
|
||||
private $defaultDir = "/tmp/downloads";
|
||||
private $env = [];
|
||||
|
||||
@@ -66,7 +66,7 @@ class Youtube
|
||||
if (Helper::ffmpegInstalled()) {
|
||||
$this->addOption('--prefer-ffmpeg');
|
||||
$this->addOption('--add-metadata');
|
||||
$this->setOption('--metadata-from-title', "%(artist)s-%(title)s");
|
||||
$this->setOption('--metadata-from-title', "%(artist)s-%(title).64s");
|
||||
$this->addOption('--extract-audio');
|
||||
}
|
||||
$pos = strrpos($this->outTpl, '.');
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"stylelint:fix": "stylelint src --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"toastr": "^2.1.4",
|
||||
"v-tooltip": "^4.0.0-alpha.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -63,6 +64,7 @@
|
||||
"vue": "^3.2.20",
|
||||
"vue-loader": "^16.0.0-beta.10",
|
||||
"vue-svg-loader": "^0.17.0-beta.2",
|
||||
"webpack": "^5.69.0",
|
||||
"webpack-cli": "^4.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#ncdownloader-settings-collapsible-container {
|
||||
padding-left: 4%;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
position: relative;
|
||||
}
|
||||
@@ -114,7 +118,7 @@ div .number {
|
||||
padding-top: 0.3em;
|
||||
}
|
||||
|
||||
.app-ncdownloader #app-content-wrapper {
|
||||
.app-ncdownloader #app-content-wrapper {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,6 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||
helper.aria2Toggle(data);
|
||||
}).send();
|
||||
})
|
||||
eventHandler.add("click", '#ncdownloader-user-settings button', function (e) {
|
||||
let link = helper.generateUrl(e.target.getAttribute('path'));
|
||||
window.location.href = link;
|
||||
})
|
||||
eventHandler.add("click", "#app-navigation", "#search-download", helper.showDownload);
|
||||
delegate('#ncdownloader-table-wrapper',
|
||||
{ target: '[data-tippy-content]' }
|
||||
|
||||
@@ -126,4 +126,20 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
settingsForm.getInstance().setParent("custom-youtube-dl-settings-container").render(input);
|
||||
}).send();
|
||||
const filepicker = function (event) {
|
||||
let element = event.target;
|
||||
OC.dialogs.filepicker(
|
||||
t('ncdownloader', 'Select a directory'),
|
||||
function (path) {
|
||||
if (element.value !== path) {
|
||||
element.value = path;
|
||||
}
|
||||
},
|
||||
false,
|
||||
'httpd/unix-directory',
|
||||
true
|
||||
);
|
||||
}
|
||||
eventHandler.add('click', "#ncd_downloader_dir", filepicker);
|
||||
eventHandler.add('click', "#ncd_torrents_dir", filepicker);
|
||||
});
|
||||
@@ -23,11 +23,6 @@ $aria2_installed = $_['aria2_installed'];
|
||||
</button>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<div class="app-navigation-new" id="ncdownloader-user-settings">
|
||||
<button type="button" class="icon-settings" path="/settings/user/ncdownloader">
|
||||
<?php print $l->t('Settings');?>
|
||||
</button>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="active-downloads">
|
||||
<div class="app-navigation-entry-bullet"></div>
|
||||
@@ -95,4 +90,5 @@ $aria2_installed = $_['aria2_installed'];
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<?php print_unescaped($this->inc('settings/Settings'));?>
|
||||
</div>
|
||||
28
templates/settings/Settings.php
Normal file
28
templates/settings/Settings.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
extract($_);
|
||||
?>
|
||||
<div id="app-settings">
|
||||
<div id="app-settings-header">
|
||||
<button name="app settings"
|
||||
class="settings-button"
|
||||
data-apps-slide-toggle="#app-settings-content">
|
||||
<?php p($l->t('Settings'));?>
|
||||
</button>
|
||||
</div>
|
||||
<div id="app-settings-content">
|
||||
<ul id="ncdownloader-settings-collapsible-container">
|
||||
<li class="ncdownloader-settings-item">
|
||||
<a href="<?php p($l->t($settings_url));?>" title="<?php p($l->t('Personal Settings'));?>" >
|
||||
<?php p($l->t('Personal Settings'));?>
|
||||
</a>
|
||||
</li>
|
||||
<?php if ($is_admin): ?>
|
||||
<li class="ncdownloader-settings-item">
|
||||
<a href="<?php p($l->t($admin_settings_url));?>" title="<?php p($l->t('Admin Settings'));?>" >
|
||||
<?php p($l->t('Admin Settings'));?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif;?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,9 +4,9 @@ const { VueLoaderPlugin } = require('vue-loader')
|
||||
|
||||
|
||||
module.exports = {
|
||||
experiments: {
|
||||
/* experiments: {
|
||||
asset: true
|
||||
},
|
||||
},*/
|
||||
entry: {
|
||||
app: './src/index.js',
|
||||
appSettings: './src/settings.js'
|
||||
@@ -72,5 +72,9 @@ module.exports = {
|
||||
jquery: "jQuery",
|
||||
"window.jQuery": "jquery"
|
||||
}),
|
||||
]
|
||||
],
|
||||
externals: {
|
||||
jquery: 'jQuery',
|
||||
OC: "OC"
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user