Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Aug 12, 2024
1 parent 2a79878 commit 1b9ba0d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions objects/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public static function getYoutubeDl($videoURL, $queue_id, $destinationFile, $add
$videoURL = escapeshellarg($videoURL);
$tmpfname = _get_temp_file('youtubeDl');
//$cmd = "youtube-dl -o {$tmpfname}.mp4 -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' {$videoURL}";
$cmd = self::getYouTubeDLCommand($addOauthFromProvider) . " --no-check-certificate --force-ipv4 --no-playlist -k -o {$tmpfname}.mp4 -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' {$videoURL}";
$cmd = self::getYouTubeDLCommand($addOauthFromProvider, $queue_id) . " --no-check-certificate --force-ipv4 --no-playlist -k -o {$tmpfname}.mp4 -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' {$videoURL}";
//echo "\n**Trying Youtube DL **".$cmd;
$progressFile = "{$global['systemRootPath']}videos/{$queue_id}_tmpFile_downloadProgress.txt";
_error_log("getYoutubeDl: Getting from Youtube DL {$cmd} progressFile={$progressFile} " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
Expand All @@ -607,7 +607,7 @@ public static function getYoutubeDl($videoURL, $queue_id, $destinationFile, $add
$error = $cmd . PHP_EOL . print_r($output, true);
_error_log($error);
self::setStreamerLog($queue_id, 'Fail to download line=' . __LINE__ . ' ' . $error, Encoder::LOG_TYPE_ERROR);
$cmd = self::getYouTubeDLCommand($addOauthFromProvider) . " --no-check-certificate --force-ipv4 --no-playlist -k -o {$tmpfname}.mp4 {$videoURL}";
$cmd = self::getYouTubeDLCommand($addOauthFromProvider, $queue_id) . " --no-check-certificate --force-ipv4 --no-playlist -k -o {$tmpfname}.mp4 {$videoURL}";
//echo "\n**Trying Youtube DL **".$cmd;
_error_log("getYoutubeDl: Getting from Youtube other option DL {$cmd}");
exec($cmd . " 1> {$global['systemRootPath']}videos/{$queue_id}_tmpFile_downloadProgress.txt 2>&1", $output, $return_val);
Expand All @@ -616,7 +616,7 @@ public static function getYoutubeDl($videoURL, $queue_id, $destinationFile, $add
$error = $cmd . PHP_EOL . print_r($output, true);
_error_log($error);
self::setStreamerLog($queue_id, 'Fail to download line=' . __LINE__ . ' ' . $error, Encoder::LOG_TYPE_ERROR);
$cmd = self::getYouTubeDLCommand($addOauthFromProvider) . " --no-check-certificate --no-playlist -k -o {$tmpfname}.mp4 {$videoURL}";
$cmd = self::getYouTubeDLCommand($addOauthFromProvider, $queue_id) . " --no-check-certificate --no-playlist -k -o {$tmpfname}.mp4 {$videoURL}";
//echo "\n**Trying Youtube DL **".$cmd;
_error_log("getYoutubeDl: Getting from Youtube other option DL {$cmd}");
exec($cmd . " 1> {$global['systemRootPath']}videos/{$queue_id}_tmpFile_downloadProgress.txt 2>&1", $output, $return_val);
Expand All @@ -625,7 +625,7 @@ public static function getYoutubeDl($videoURL, $queue_id, $destinationFile, $add
$error = $cmd . PHP_EOL . print_r($output, true);
_error_log($error);
self::setStreamerLog($queue_id, 'Fail to download line=' . __LINE__ . ' ' . $error, Encoder::LOG_TYPE_ERROR);
$cmd = self::getYouTubeDLCommand($addOauthFromProvider) . " --no-check-certificate --force-ipv4 --no-playlist -k -o '{$tmpfname}.%(ext)s' {$videoURL}";
$cmd = self::getYouTubeDLCommand($addOauthFromProvider, $queue_id) . " --no-check-certificate --force-ipv4 --no-playlist -k -o '{$tmpfname}.%(ext)s' {$videoURL}";
//echo "\n**Trying Youtube DL **".$cmd;
_error_log("getYoutubeDl: Getting from Youtube other option DL {$cmd}");
exec($cmd . " 1> {$global['systemRootPath']}videos/{$queue_id}_tmpFile_downloadProgress.txt 2>&1", $output, $return_val);
Expand Down Expand Up @@ -2664,7 +2664,7 @@ public static function getDescriptionFromLink($link, $addOauthFromProvider = '')
}
}

public static function getYouTubeDLCommand($addOauthFromProvider = '', $forceYoutubeDL = false)
public static function getYouTubeDLCommand($addOauthFromProvider = '', $streamers_id = 0, $forceYoutubeDL = false)
{
global $global;
$ytdl = "youtube-dl ";
Expand All @@ -2676,7 +2676,13 @@ public static function getYouTubeDLCommand($addOauthFromProvider = '', $forceYou
$ytdl = "/usr/local/bin/youtube-dl ";
}
if(!empty($addOauthFromProvider) || !empty($global['usingOauth'])){
$streamers_id = Login::getStreamerId();
if(empty($streamers_id)){
$streamers_id = Login::getStreamerId();
}
if(empty($streamers_id)){
_error_log('streamers_id not found');
return $ytdl;
}
$accessToken = Streamer::getAccessToken($streamers_id, $addOauthFromProvider);
if(!empty($accessToken)){
$global['usingOauth'] = 1;
Expand Down

0 comments on commit 1b9ba0d

Please sign in to comment.