Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion class/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private function check_outuput_folder()

}

private function do_download($audio_only)
/* private function do_download($audio_only)
{
$cmd = $this->config["bin"];
$cmd .= " --ignore-error -o ".$this->download_path."/";
Expand Down Expand Up @@ -302,6 +302,54 @@ private function do_download($audio_only)
$cmd .= " & echo $!";

shell_exec($cmd);
} */

// Modify the command to use POT
private function do_download($audio_only)
{
$cmd = $this->config["bin"];
$cmd .= " --ignore-error -o ".$this->download_path."/";
$cmd .= escapeshellarg($this->outfilename);

if ($this->vformat)
{
$cmd .= " --format ";
$cmd .= escapeshellarg($this->vformat);
}
if($audio_only)
{
$cmd .= " -x ";
}
$cmd .= " --restrict-filenames"; // --restrict-filenames is for specials chars

// Prepare generate_once.js path in the same directory as bin
$binPath = $this->config["bin"];
$binDir = dirname($binPath);
$generateOnceJSPath = $binDir . '/bgutil-ytdlp-pot-provider/server/build/generate_once.js';

foreach($this->urls as $url)
{
$cmdForUrl = $cmd;
if (strpos($url, 'youtube.com') !== false || strpos($url, 'youtu.be') !== false) {
$cmdForUrl .= ' --extractor-args ';
$cmdForUrl .= '"youtube:getpot_bgutil_script=' . $generateOnceJSPath . '"';
}
$cmdForUrl .= " ".escapeshellarg($url);

if($this->config["log"])
{
$cmdForUrl = "{ echo Command: ".escapeshellarg($cmdForUrl)."; ".$cmdForUrl." ; }";
$cmdForUrl .= " > ".$this->log_path."/$(date +\"%Y-%m-%d_%H-%M-%S-%N\").txt";
}
else
{
$cmdForUrl .= " > /dev/null ";
}

$cmdForUrl .= " & echo $!";

shell_exec($cmdForUrl);
}
}

private function do_info()
Expand Down