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();
|
OC_Util::setupFS();
|
||||||
$this->aria2 = $aria2;
|
$this->aria2 = $aria2;
|
||||||
$this->aria2->init();
|
$this->aria2->init();
|
||||||
|
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||||
$this->dbconn = new DbHelper();
|
$this->dbconn = new DbHelper();
|
||||||
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
|
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,9 @@ class MainController extends Controller
|
|||||||
$params['aria2_installed'] = $this->aria2->isInstalled();
|
$params['aria2_installed'] = $this->aria2->isInstalled();
|
||||||
$params['youtube_installed'] = (bool) Helper::findBinaryPath('youtube-dl');
|
$params['youtube_installed'] = (bool) Helper::findBinaryPath('youtube-dl');
|
||||||
$params['counter'] = $this->counters->getCounters();
|
$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);
|
$response = new TemplateResponse($this->appName, 'Index', $params);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Helper
|
|||||||
{
|
{
|
||||||
public const DOWNLOADTYPE = ['ARIA2' => 1, 'YOUTUBE-DL' => 2, 'OTHERS' => 3];
|
public const DOWNLOADTYPE = ['ARIA2' => 1, 'YOUTUBE-DL' => 2, 'OTHERS' => 3];
|
||||||
public const STATUS = ['ACTIVE' => 1, 'PAUSED' => 2, 'COMPLETE' => 3, 'WAITING' => 4, 'ERROR' => 5];
|
public const STATUS = ['ACTIVE' => 1, 'PAUSED' => 2, 'COMPLETE' => 3, 'WAITING' => 4, 'ERROR' => 5];
|
||||||
|
const MAXLEN = 255;
|
||||||
|
|
||||||
public static function isUrl($URL)
|
public static function isUrl($URL)
|
||||||
{
|
{
|
||||||
@@ -41,7 +42,7 @@ class Helper
|
|||||||
public static function isGetUrlSite($url)
|
public static function isGetUrlSite($url)
|
||||||
{
|
{
|
||||||
$host = parse_url($url, PHP_URL_HOST);
|
$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));
|
return (bool) (in_array($host, $sites));
|
||||||
}
|
}
|
||||||
public static function parseUrl($url)
|
public static function parseUrl($url)
|
||||||
@@ -66,10 +67,11 @@ class Helper
|
|||||||
public static function getFilename($url)
|
public static function getFilename($url)
|
||||||
{
|
{
|
||||||
if (self::isMagnet($url)) {
|
if (self::isMagnet($url)) {
|
||||||
return self::parseUrl($url)['dn'];
|
$filename = self::parseUrl($url)['dn'];
|
||||||
} else {
|
} else {
|
||||||
return self::getUrlPath($url);
|
$filename = self::getUrlPath($url);
|
||||||
}
|
}
|
||||||
|
return substr($filename, 0, self::MAXLEN);
|
||||||
}
|
}
|
||||||
public static function formatBytes($size, $precision = 2)
|
public static function formatBytes($size, $precision = 2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Youtube
|
|||||||
private $options = [];
|
private $options = [];
|
||||||
private $downloadDir;
|
private $downloadDir;
|
||||||
private $timeout = 60 * 60 * 10; //10 hours
|
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 $defaultDir = "/tmp/downloads";
|
||||||
private $env = [];
|
private $env = [];
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ class Youtube
|
|||||||
if (Helper::ffmpegInstalled()) {
|
if (Helper::ffmpegInstalled()) {
|
||||||
$this->addOption('--prefer-ffmpeg');
|
$this->addOption('--prefer-ffmpeg');
|
||||||
$this->addOption('--add-metadata');
|
$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');
|
$this->addOption('--extract-audio');
|
||||||
}
|
}
|
||||||
$pos = strrpos($this->outTpl, '.');
|
$pos = strrpos($this->outTpl, '.');
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"stylelint:fix": "stylelint src --fix"
|
"stylelint:fix": "stylelint src --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"toastr": "^2.1.4",
|
||||||
"v-tooltip": "^4.0.0-alpha.1"
|
"v-tooltip": "^4.0.0-alpha.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
"vue": "^3.2.20",
|
"vue": "^3.2.20",
|
||||||
"vue-loader": "^16.0.0-beta.10",
|
"vue-loader": "^16.0.0-beta.10",
|
||||||
"vue-svg-loader": "^0.17.0-beta.2",
|
"vue-svg-loader": "^0.17.0-beta.2",
|
||||||
|
"webpack": "^5.69.0",
|
||||||
"webpack-cli": "^4.9.0"
|
"webpack-cli": "^4.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
#ncdownloader-settings-collapsible-container {
|
||||||
|
padding-left: 4%;
|
||||||
|
}
|
||||||
|
|
||||||
.action-item {
|
.action-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -114,7 +118,7 @@ div .number {
|
|||||||
padding-top: 0.3em;
|
padding-top: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-ncdownloader #app-content-wrapper {
|
.app-ncdownloader #app-content-wrapper {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ window.addEventListener('DOMContentLoaded', function () {
|
|||||||
helper.aria2Toggle(data);
|
helper.aria2Toggle(data);
|
||||||
}).send();
|
}).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);
|
eventHandler.add("click", "#app-navigation", "#search-download", helper.showDownload);
|
||||||
delegate('#ncdownloader-table-wrapper',
|
delegate('#ncdownloader-table-wrapper',
|
||||||
{ target: '[data-tippy-content]' }
|
{ target: '[data-tippy-content]' }
|
||||||
|
|||||||
@@ -126,4 +126,20 @@ window.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
settingsForm.getInstance().setParent("custom-youtube-dl-settings-container").render(input);
|
settingsForm.getInstance().setParent("custom-youtube-dl-settings-container").render(input);
|
||||||
}).send();
|
}).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>
|
</button>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
</div>
|
</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>
|
<ul>
|
||||||
<li class="active-downloads">
|
<li class="active-downloads">
|
||||||
<div class="app-navigation-entry-bullet"></div>
|
<div class="app-navigation-entry-bullet"></div>
|
||||||
@@ -95,4 +90,5 @@ $aria2_installed = $_['aria2_installed'];
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<?php print_unescaped($this->inc('settings/Settings'));?>
|
||||||
</div>
|
</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 = {
|
module.exports = {
|
||||||
experiments: {
|
/* experiments: {
|
||||||
asset: true
|
asset: true
|
||||||
},
|
},*/
|
||||||
entry: {
|
entry: {
|
||||||
app: './src/index.js',
|
app: './src/index.js',
|
||||||
appSettings: './src/settings.js'
|
appSettings: './src/settings.js'
|
||||||
@@ -72,5 +72,9 @@ module.exports = {
|
|||||||
jquery: "jQuery",
|
jquery: "jQuery",
|
||||||
"window.jQuery": "jquery"
|
"window.jQuery": "jquery"
|
||||||
}),
|
}),
|
||||||
]
|
],
|
||||||
|
externals: {
|
||||||
|
jquery: 'jQuery',
|
||||||
|
OC: "OC"
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user