tidying up
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Aria2;
|
||||
|
||||
//use Symfony\Component\Process\ExecutableFinder;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
|
||||
class Aria2
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Aria2;
|
||||
|
||||
class aria2Options
|
||||
class Options
|
||||
{
|
||||
|
||||
public static function get()
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace OCA\NCDownloader\Command;
|
||||
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OC\Core\Command\Base;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Controller;
|
||||
|
||||
use OCA\NCDownloader\Tools\Aria2;
|
||||
use OCA\NCDownloader\Aria2\Aria2;
|
||||
use OCA\NCDownloader\Tools\Counters;
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
use OCA\NCDownloader\Tools\folderScan;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace OCA\NCDownloader\Controller;
|
||||
|
||||
use OCA\NCDownloader\Tools\Aria2;
|
||||
use OCA\NCDownloader\Aria2\Aria2;
|
||||
use OCA\NCDownloader\Tools\Counters;
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
use OCA\NCDownloader\Tools\folderScan;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCA\NCDownloader\Tools\Settings;
|
||||
use OCA\NCDownloader\Tools\Youtube;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCA\NCDownloader\Ytdl\Ytdl;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
@@ -26,7 +26,7 @@ class MainController extends Controller
|
||||
private $aria2Opts;
|
||||
private $l10n;
|
||||
|
||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube)
|
||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
|
||||
{
|
||||
|
||||
parent::__construct($appName, $request);
|
||||
@@ -39,7 +39,7 @@ class MainController extends Controller
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->dbconn = new DbHelper();
|
||||
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
|
||||
$this->youtube = $youtube;
|
||||
$this->ytdl = $ytdl;
|
||||
$this->isAdmin = \OC_User::isAdminUser($this->uid);
|
||||
$this->hideError = Helper::getSettings("ncd_hide_errors", false);
|
||||
$this->disable_bt_nonadmin = Helper::getSettings("ncd_disable_bt", false, Settings::TYPE["SYSTEM"]);
|
||||
@@ -67,9 +67,9 @@ class MainController extends Controller
|
||||
$params['aria2_installed'] = $aria2_installed = $this->aria2->isInstalled();
|
||||
$params['aria2_bin'] = $aria2_bin = $this->aria2->getBin();
|
||||
$params['aria2_executable'] = $aria2_executable = $this->aria2->isExecutable();
|
||||
$params['youtube_installed'] = $youtube_installed = $this->youtube->isInstalled();
|
||||
$params['youtube_bin'] = $youtube_bin = $this->youtube->getBin();
|
||||
$params['youtube_executable'] = $youtube_executable = $this->youtube->isExecutable();
|
||||
$params['ytdlinstalled'] = $ytdlinstalled = $this->ytdl->isInstalled();
|
||||
$params['ytdlbin'] = $ytdlbin = $this->ytdl->getBin();
|
||||
$params['ytdlexecutable'] = $ytdlexecutable = $this->ytdl->isExecutable();
|
||||
$params['ncd_hide_errors'] = $this->hideError;
|
||||
$params['counter'] = $this->counters->getCounters();
|
||||
$params['python_installed'] = Helper::pythonInstalled();
|
||||
@@ -92,8 +92,8 @@ class MainController extends Controller
|
||||
$this->aria2->start();
|
||||
}
|
||||
}
|
||||
if ($youtube_installed && (!$youtube_executable || !@is_readable($youtube_bin))) {
|
||||
array_push($errors, sprintf("youtube-dl is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $youtube_bin));
|
||||
if ($ytdlinstalled && (!$ytdlexecutable || !@is_readable($ytdlbin))) {
|
||||
array_push($errors, sprintf("ytdl is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $ytdlbin));
|
||||
}
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace OCA\NCDownloader\Controller;
|
||||
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCA\NCDownloader\Tools\Settings;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IRequest;
|
||||
@@ -101,33 +101,33 @@ class SettingsController extends Controller
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function youtubeGet()
|
||||
public function ytdlGet()
|
||||
{
|
||||
$data = json_decode($this->settings->get("custom_youtube_dl_settings"));
|
||||
$data = json_decode($this->settings->get("custom_ytdl_settings"));
|
||||
return new JSONResponse($data);
|
||||
}
|
||||
|
||||
public function youtubeSave()
|
||||
public function ytdlSave()
|
||||
{
|
||||
$params = $this->request->getParams();
|
||||
$data = array_filter($params, function ($key) {
|
||||
return (bool) (!in_array(substr($key, 0, 1), ['_']));
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
$resp = $this->settings->save("custom_youtube_dl_settings", json_encode($data));
|
||||
$resp = $this->settings->save("custom_ytdl_settings", json_encode($data));
|
||||
return new JSONResponse($resp);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function youtubeDelete()
|
||||
public function ytdlDelete()
|
||||
{
|
||||
$saved = json_decode($this->settings->get("custom_youtube_dl_settings"), 1);
|
||||
$saved = json_decode($this->settings->get("custom_ytdl_settings"), 1);
|
||||
$params = $this->request->getParams();
|
||||
foreach ($params as $key => $value) {
|
||||
unset($saved[$key]);
|
||||
}
|
||||
$resp = $this->settings->save("custom_youtube_dl_settings", json_encode($saved));
|
||||
$resp = $this->settings->save("custom_ytdl_settings", json_encode($saved));
|
||||
return new JSONResponse($resp);
|
||||
}
|
||||
public function save($key, $value)
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Controller;
|
||||
|
||||
use OCA\NCDownloader\Tools\Aria2;
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Aria2\Aria2;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
use OCA\NCDownloader\Tools\folderScan;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCA\NCDownloader\Tools\Youtube;
|
||||
use OCA\NCDownloader\Ytdl\Ytdl;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
||||
class YoutubeController extends Controller
|
||||
class YtdlController extends Controller
|
||||
{
|
||||
//@config OC\AppConfig
|
||||
private $l10n;
|
||||
private $audio_extensions = array("mp3", "m4a", "vorbis");
|
||||
|
||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube)
|
||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
|
||||
{
|
||||
parent::__construct($appName, $request);
|
||||
$this->appName = $appName;
|
||||
@@ -26,7 +26,7 @@ class YoutubeController extends Controller
|
||||
$this->l10n = $IL10N;
|
||||
$this->downloadDir = Helper::getDownloadDir();
|
||||
$this->dbconn = new DbHelper();
|
||||
$this->youtube = $youtube;
|
||||
$this->ytdl = $ytdl;
|
||||
$this->aria2 = $aria2;
|
||||
$this->aria2->init();
|
||||
$this->tablename = $this->dbconn->queryBuilder->getTableName("ncdownloader_info");
|
||||
@@ -37,7 +37,7 @@ class YoutubeController extends Controller
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
$data = $this->dbconn->getYoutubeByUid($this->uid);
|
||||
$data = $this->dbconn->getYtdlByUid($this->uid);
|
||||
if (is_array($data) && count($data) < 1) {
|
||||
return [];
|
||||
}
|
||||
@@ -54,9 +54,9 @@ class YoutubeController extends Controller
|
||||
$tmp['speed'] = explode("|", $value['speed']);
|
||||
$tmp['progress'] = $value['progress'];
|
||||
|
||||
$path = $this->urlGenerator->linkToRoute('ncdownloader.Youtube.Delete');
|
||||
$path = $this->urlGenerator->linkToRoute('ncdownloader.Ytdl.Delete');
|
||||
$tmp['actions'][] = ['name' => 'delete', 'path' => $path];
|
||||
$path = $this->urlGenerator->linkToRoute('ncdownloader.Youtube.Redownload');
|
||||
$path = $this->urlGenerator->linkToRoute('ncdownloader.Ytdl.Redownload');
|
||||
$tmp['actions'][] = ['name' => 'refresh', 'path' => $path];
|
||||
|
||||
$tmp['data_gid'] = $value['gid'] ?? 0;
|
||||
@@ -64,7 +64,7 @@ class YoutubeController extends Controller
|
||||
}
|
||||
|
||||
$resp['title'] = ['filename', 'speed', 'progress', 'actions'];
|
||||
$resp['counter'] = ['youtube-dl' => count($data)];
|
||||
$resp['counter'] = ['ytdl' => count($data)];
|
||||
folderScan::sync();
|
||||
return new JSONResponse($resp);
|
||||
}
|
||||
@@ -74,12 +74,12 @@ class YoutubeController extends Controller
|
||||
*/
|
||||
public function Download()
|
||||
{
|
||||
$dlDir = $this->youtube->getDownloadDir();
|
||||
$dlDir = $this->ytdl->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 = $this->ytdl;
|
||||
if (in_array($this->request->getParam('extension'), $this->audio_extensions)) {
|
||||
$yt->audioOnly = true;
|
||||
$yt->audioFormat = $this->request->getParam('extension');
|
||||
@@ -87,7 +87,7 @@ class YoutubeController extends Controller
|
||||
$yt->videoFormat = $this->request->getParam('extension');
|
||||
}
|
||||
if (!$yt->isInstalled()) {
|
||||
return new JSONResponse(["error" => "Please install the latest youtube-dl or make the bundled binary file executable in ncdownloader/bin"]);
|
||||
return new JSONResponse(["error" => "Please install the latest yt-dlp or make the bundled binary file executable in ncdownloader/bin"]);
|
||||
}
|
||||
if (Helper::isGetUrlSite($url)) {
|
||||
return new JSONResponse($this->downloadUrlSite($url));
|
||||
@@ -99,7 +99,7 @@ class YoutubeController extends Controller
|
||||
}
|
||||
private function downloadUrlSite($url)
|
||||
{
|
||||
$yt = $this->youtube;
|
||||
$yt = $this->ytdl;
|
||||
if ($data = $yt->forceIPV4()->getDownloadUrl($url)) {
|
||||
return $this->_download($data['url'], $data['filename']);
|
||||
} else {
|
||||
@@ -157,16 +157,16 @@ class YoutubeController extends Controller
|
||||
if (!empty($data['link'])) {
|
||||
if (isset($data['ext'])) {
|
||||
if (in_array($data['ext'], $this->audio_extensions)) {
|
||||
$this->youtube->audioOnly = true;
|
||||
$this->youtube->audioFormat = $data['ext'];
|
||||
$this->ytdl->audioOnly = true;
|
||||
$this->ytdl->audioFormat = $data['ext'];
|
||||
} else {
|
||||
$this->youtube->audioOnly = false;
|
||||
$this->youtube->videoFormat = $data['ext'];
|
||||
$this->ytdl->audioOnly = false;
|
||||
$this->ytdl->videoFormat = $data['ext'];
|
||||
}
|
||||
}
|
||||
//$this->dbconn->deleteByGid($gid);
|
||||
$this->youtube->dbDlPath = Helper::getDownloadDir();
|
||||
$resp = $this->youtube->forceIPV4()->download($data['link']);
|
||||
$this->ytdl->dbDlPath = Helper::getDownloadDir();
|
||||
$resp = $this->ytdl->forceIPV4()->download($data['link']);
|
||||
folderScan::sync();
|
||||
return new JSONResponse($resp);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Db;
|
||||
use OCA\NCDownloader\Tools\Helper as ToolsHelper;
|
||||
|
||||
class DbHelper
|
||||
class Helper
|
||||
{
|
||||
//@var OC\DB\ConnectionAdapter
|
||||
private $conn;
|
||||
@@ -13,7 +14,7 @@ class DbHelper
|
||||
$this->queryBuilder = $this->conn->getQueryBuilder();
|
||||
$this->prefixedTable = $this->queryBuilder->getTableName($this->table);
|
||||
//$container = \OC::$server->query(\OCP\IServerContainer::class);
|
||||
//Helper::debug(get_class($container->query(\OCP\RichObjectStrings\IValidator::class)));
|
||||
//ToolsHelper::debug(get_class($container->query(\OCP\RichObjectStrings\IValidator::class)));
|
||||
//$this->conn = \OC::$server->query(Connection::class);//working only with 22
|
||||
//$this->connAdapter = \OC::$server->getDatabaseConnection();
|
||||
//$this->conn = $this->connAdapter->getInner();
|
||||
@@ -58,7 +59,7 @@ class DbHelper
|
||||
return $queryBuilder->fetchColumn();
|
||||
}
|
||||
|
||||
public function getYoutubeByUid($uid)
|
||||
public function getYtdlByUid($uid)
|
||||
{
|
||||
$qb = $this->queryBuilder
|
||||
->select('*')
|
||||
@@ -66,7 +67,7 @@ class DbHelper
|
||||
->where('uid = :uid')
|
||||
->andWhere('type = :type')
|
||||
->setParameter('uid', $uid)
|
||||
->setParameter('type', Helper::DOWNLOADTYPE['YOUTUBE-DL'])
|
||||
->setParameter('type', ToolsHelper::DOWNLOADTYPE['YOUTUBE-DL'])
|
||||
->orderBy('id', 'DESC')
|
||||
->execute();
|
||||
return $qb->fetchAll();
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Db;
|
||||
|
||||
use OC\AllConfig;
|
||||
|
||||
@@ -60,9 +60,9 @@ class Settings extends AllConfig
|
||||
return json_decode($settings, 1);
|
||||
}
|
||||
|
||||
public function getYoutube()
|
||||
public function getYtdl()
|
||||
{
|
||||
$settings = $this->get("custom_youtube_dl_settings");
|
||||
$settings = $this->get("custom_ytdl_settings");
|
||||
return json_decode($settings, 1);
|
||||
}
|
||||
public function getAll()
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\http;
|
||||
|
||||
//require __DIR__ . "/../../vendor/autoload.php";
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
@@ -7,7 +7,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCA\NCDownloader\Tools\Settings;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
|
||||
class Admin implements ISettings {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCA\NCDownloader\Tools\Settings;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
|
||||
class Personal implements ISettings {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
|
||||
use OCA\NCDownloader\Tools\Aria2;
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Aria2\Aria2;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
|
||||
class Counters
|
||||
{
|
||||
@@ -22,13 +22,13 @@ class Counters
|
||||
'waiting' => $this->getCounter('tellWaiting'),
|
||||
'complete' => $this->getCounter('tellStopped'),
|
||||
'fail' => $this->getCounter('tellFail'),
|
||||
'youtube-dl' => $this->getCounter('youtube-dl'),
|
||||
'ytdl' => $this->getCounter('ytdl'),
|
||||
];
|
||||
}
|
||||
private function getCounter($action = 'tellActive')
|
||||
{
|
||||
if ($action === 'youtube-dl') {
|
||||
$data = $this->dbconn->getYoutubeByUid($this->uid);
|
||||
if ($action === 'ytdl') {
|
||||
$data = $this->dbconn->getYtdlByUid($this->uid);
|
||||
} else if ($action === 'tellActive') {
|
||||
$data = $this->aria2->{$action}([]);
|
||||
} else {
|
||||
@@ -38,7 +38,7 @@ class Counters
|
||||
if (!is_array($data) && count($data) < 1) {
|
||||
return 0;
|
||||
}
|
||||
if ($action !== 'youtube-dl') {
|
||||
if ($action !== 'ytdl') {
|
||||
$data = $this->filterData($data);
|
||||
}
|
||||
return count($data);
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace OCA\NCDownloader\Tools;
|
||||
|
||||
use Exception;
|
||||
use OCA\NCDownloader\Search\Sites\searchInterface;
|
||||
use OCA\NCDownloader\Tools\aria2Options;
|
||||
use OCA\NCDownloader\Tools\Settings;
|
||||
use OCA\NCDownloader\Aria2\Options as aria2Options;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCP\IUser;
|
||||
use OC\Files\Filesystem;
|
||||
use OC_Util;
|
||||
@@ -108,7 +108,7 @@ class Helper
|
||||
|
||||
public static function isYoutubeType($url)
|
||||
{
|
||||
$regex = '%^(?:(?:https?)://)(?:[a-z0-9_]*\.)?(?:twitter|youtube)\.com/%i';
|
||||
$regex = '%^(?:(?:https?)://)(?:[a-z0-9_]*\.)?(?:twitter|ytdl)\.com/%i';
|
||||
return (bool) preg_match($regex, $url);
|
||||
}
|
||||
|
||||
@@ -435,12 +435,12 @@ class Helper
|
||||
return Settings::create($uid);
|
||||
}
|
||||
|
||||
public static function getYoutubeConfig($uid = null): array
|
||||
public static function getYtdlConfig($uid = null): array
|
||||
{
|
||||
$config = [
|
||||
'binary' => self::getSettings("ncd_yt_binary", null, Settings::TYPE['SYSTEM']),
|
||||
'downloadDir' => Helper::getRealDownloadDir(),
|
||||
'settings' => self::newSettings()->getYoutube(),
|
||||
'settings' => self::newSettings()->getYtdl(),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Ytdl;
|
||||
|
||||
use OCA\NCDownloader\Tools\DbHelper;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCA\NCDownloader\Db\Helper as DbHelper;
|
||||
use OCA\NCDownloader\Tools\Helper as ToolsHelper;
|
||||
|
||||
class YoutubeHelper
|
||||
class Helper
|
||||
{
|
||||
public $file = null;
|
||||
protected $pid = 0;
|
||||
@@ -67,7 +67,7 @@ class YoutubeHelper
|
||||
}
|
||||
public function log($message)
|
||||
{
|
||||
Helper::debug($message);
|
||||
ToolsHelper::debug($message);
|
||||
}
|
||||
public function updateStatus($status = null)
|
||||
{
|
||||
@@ -84,10 +84,10 @@ class YoutubeHelper
|
||||
{
|
||||
$info = $this->getSiteInfo($buffer);
|
||||
if (isset($info["id"])) {
|
||||
$this->gid = Helper::generateGID($info["id"]);
|
||||
$this->gid = ToolsHelper::generateGID($info["id"]);
|
||||
}
|
||||
if (!$this->gid) {
|
||||
$this->gid = Helper::generateGID($extra["link"]);
|
||||
$this->gid = ToolsHelper::generateGID($extra["link"]);
|
||||
}
|
||||
$downloadInfo = $this->getDownloadInfo($buffer);
|
||||
if ($downloadInfo) {
|
||||
@@ -116,9 +116,9 @@ class YoutubeHelper
|
||||
$data = [
|
||||
'uid' => $this->user,
|
||||
'gid' => $this->gid,
|
||||
'type' => Helper::DOWNLOADTYPE['YOUTUBE-DL'],
|
||||
'type' => ToolsHelper::DOWNLOADTYPE['YOUTUBE-DL'],
|
||||
'filename' => basename($file),
|
||||
'status' => Helper::STATUS['ACTIVE'],
|
||||
'status' => ToolsHelper::STATUS['ACTIVE'],
|
||||
'timestamp' => time(),
|
||||
'data' => $extra,
|
||||
];
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Ytdl;
|
||||
|
||||
class youtubedlOptions
|
||||
class Options
|
||||
{
|
||||
|
||||
public static function get()
|
||||
@@ -65,7 +65,7 @@ class youtubedlOptions
|
||||
'http-chunk-size' => 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). May be useful for',
|
||||
'playlist-reverse' => 'playlist videos in reverse order',
|
||||
'playlist-random' => 'playlist videos in random order',
|
||||
'xattr-set-filesize' => 'file xattribute ytdl.filesize with expected file size',
|
||||
'xattr-set-filesize' => 'file xattribute youtube-dl.filesize with expected file size',
|
||||
'hls-prefer-native' => 'the native HLS downloader instead of ffmpeg',
|
||||
'hls-prefer-ffmpeg' => 'ffmpeg instead of the native HLS downloader',
|
||||
'hls-use-mpegts' => 'the mpegts container for HLS videos; allowing some players to play the video while downloading, and reducing the',
|
||||
@@ -130,7 +130,7 @@ class youtubedlOptions
|
||||
'all-formats' => 'all available video formats',
|
||||
'prefer-free-formats' => 'video formats with free containers over non-free ones of same quality. Use with "-S ext" to strictly prefer',
|
||||
'list-formats' => 'available formats of each video. Simulate unless --no-simulate is used',
|
||||
'youtube-skip-dash-manifest' => 'not download the DASH manifests and related data on YouTube videos',
|
||||
'youtube-dl-skip-dash-manifest' => 'not download the DASH manifests and related data on YouTube videos',
|
||||
'merge-output-format' => 'If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm,',
|
||||
'write-sub' => 'subtitle file',
|
||||
'write-auto-sub' => 'automatically generated subtitle file (YouTube only)',
|
||||
@@ -173,7 +173,7 @@ class youtubedlOptions
|
||||
'no-live-from-start' => 'livestreams from the current time (default)',
|
||||
'no-wait-for-video' => 'not wait for scheduled streams (default)',
|
||||
'no-colors' => 'not emit color codes in output',
|
||||
'compat-options' => 'Options that can help keep compatibility with youtube-dl or youtube-dlc configurations by reverting some of the',
|
||||
'compat-options' => 'Options that can help keep compatibility with youtube-dl or youtube-dl-dlc configurations by reverting some of the',
|
||||
'no-match-filter' => 'not use generic video filter (default)',
|
||||
'no-download-archive' => 'not use archive file (default)',
|
||||
'break-on-existing' => 'the download process when encountering a file that is in the archive',
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
namespace OCA\NCDownloader\Ytdl;
|
||||
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OCA\NCDownloader\Tools\YoutubeHelper;
|
||||
use OCA\NCDownloader\Ytdl\Helper as YtdHelper;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class Youtube
|
||||
class Ytdl
|
||||
{
|
||||
public $audioOnly = 0;
|
||||
public $audioFormat = 'm4a', $videoFormat = null;
|
||||
@@ -32,7 +32,7 @@ class Youtube
|
||||
if (isset($binary) && $this->isExecutable($binary)) {
|
||||
$this->bin = $binary;
|
||||
} else {
|
||||
$this->bin = __DIR__ . "/../../bin/yt-dlp"; //Helper::findBinaryPath('youtube-dl', __DIR__ . "/../../bin/yt-dlp");
|
||||
$this->bin = __DIR__ . "/../../bin/yt-dlp"; //Helper::findBinaryPath('ytdl', __DIR__ . "/../../bin/yt-dlp");
|
||||
}
|
||||
if ($this->isInstalled() && !$this->isExecutable()) {
|
||||
chmod($this->bin, 0744);
|
||||
@@ -138,7 +138,7 @@ class Youtube
|
||||
$this->setOption('--format', $this->format);
|
||||
}
|
||||
}
|
||||
$this->helper = YoutubeHelper::create();
|
||||
$this->helper = YtdHelper::create();
|
||||
$this->downloadDir = $this->downloadDir ?? $this->defaultDir;
|
||||
$this->setOption("--output", $this->downloadDir . "/" . $this->outTpl);
|
||||
$this->setUrl($url);
|
||||
Reference in New Issue
Block a user