fixed #47;some cleaning up and bugfixes;
This commit is contained in:
@@ -11,11 +11,10 @@ use OCA\NCDownloader\Tools\Youtube;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
//use OCP\Files\IRootFolder;
|
||||
use OCP\IL10N;
|
||||
//use OCP\Files\IRootFolder;
|
||||
use OCP\IRequest;
|
||||
use OC_Util;
|
||||
use OC\Files\Filesystem;
|
||||
|
||||
class MainController extends Controller
|
||||
{
|
||||
@@ -57,7 +56,6 @@ class MainController extends Controller
|
||||
// OC_Util::addStyle($this->appName, 'table');
|
||||
$params = $this->buildParams();
|
||||
$response = new TemplateResponse($this->appName, 'Index', $params);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -125,6 +123,10 @@ class MainController extends Controller
|
||||
*/
|
||||
public function Download()
|
||||
{
|
||||
$dlDir = $this->aria2->getDownloadDir();
|
||||
if (!is_writable($dlDir)) {
|
||||
return new JSONResponse(['error' => sprintf("%s is not writable", $dlDir)]);
|
||||
}
|
||||
$url = trim($this->request->getParam('text-input-value'));
|
||||
if (Helper::isMagnet($url)) {
|
||||
if ($this->disable_bt_nonadmin && !($this->isAdmin)) {
|
||||
|
||||
@@ -76,7 +76,10 @@ class YoutubeController extends Controller
|
||||
*/
|
||||
public function Download()
|
||||
{
|
||||
$params = array();
|
||||
$dlDir = $this->youtube->getDownloadDir();
|
||||
if (!is_writable($dlDir)) {
|
||||
return new JSONResponse(['error' => sprintf("%s is not writable", $dlDir)]);
|
||||
}
|
||||
$url = trim($this->request->getParam('text-input-value'));
|
||||
$yt = $this->youtube;
|
||||
$yt->audioOnly = (bool) $this->request->getParam('audio-only');
|
||||
@@ -117,7 +120,7 @@ class YoutubeController extends Controller
|
||||
}
|
||||
|
||||
$row = $this->dbconn->getByGid($gid);
|
||||
$data = $this->dbconn->getExtra($value["data"]);;
|
||||
$data = $this->dbconn->getExtra($row["data"]);
|
||||
if (!isset($data['pid'])) {
|
||||
if ($this->dbconn->deleteByGid($gid)) {
|
||||
$msg = sprintf("%s is deleted from database!", $gid);
|
||||
@@ -193,9 +196,9 @@ class YoutubeController extends Controller
|
||||
private function installYTD()
|
||||
{
|
||||
try {
|
||||
$filename = Helper::getFileName($yt->installUrl());
|
||||
$yt->setDownloadDir($this->dataDir . "/bin");
|
||||
$resp = $this->Save($yt->installUrl(), $filename);
|
||||
$filename = Helper::getFileName($this->installUrl());
|
||||
$this->setDownloadDir($this->dataDir . "/bin");
|
||||
$resp = $this->Save($this->installUrl(), $filename);
|
||||
return $resp;
|
||||
} catch (\Exception $e) {
|
||||
return ['error' => $e->getMessage()];
|
||||
|
||||
Reference in New Issue
Block a user