Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Sep 20, 2024
1 parent 4aa9fea commit 47a23b9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions objects/aVideoEncoder.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$obj = new stdClass();
$obj->error = true;
$obj->lines = array();
$obj->errorMSG = array();

global $global, $config;
if (!isset($global['systemRootPath'])) {
Expand Down Expand Up @@ -276,21 +277,21 @@

function downloadVideoFromDownloadURL($downloadURL)
{
global $global;
global $global, $obj;
$downloadURL = trim($downloadURL);
_error_log("aVideoEncoder.json: Try to download " . $downloadURL);
__errlog("aVideoEncoder.json: Try to download " . $downloadURL);
$file = url_get_contents($downloadURL);
$strlen = strlen($file);
$minLen = 20000;
if (preg_match('/\.mp3$/', $downloadURL)) {
$minLen = 5000;
}
if ($strlen < $minLen) {
_error_log("aVideoEncoder.json: this is not a video " . $downloadURL . " strlen={$strlen} " . humanFileSize($strlen));
__errlog("aVideoEncoder.json: this is not a video " . $downloadURL . " strlen={$strlen} " . humanFileSize($strlen));
//it is not a video
return false;
}
_error_log("aVideoEncoder.json: Got the download " . $downloadURL . ' ' . humanFileSize($strlen));
__errlog("aVideoEncoder.json: Got the download " . $downloadURL . ' ' . humanFileSize($strlen));
if ($file) {
$_FILES['video']['name'] = basename($downloadURL);
//$temp = getTmpDir('zip') . $_FILES['video']['name'];
Expand All @@ -299,16 +300,22 @@ function downloadVideoFromDownloadURL($downloadURL)
$bytesSaved = file_put_contents($temp, $file);

if ($bytesSaved) {
_error_log("aVideoEncoder.json: saved " . $temp . ' ' . humanFileSize($bytesSaved));
__errlog("aVideoEncoder.json: saved " . $temp . ' ' . humanFileSize($bytesSaved));
return $temp;
} else {
$dir = dirname($temp);
if (!is_writable($dir)) {
_error_log("aVideoEncoder.json: ERROR on save file " . $temp . ". Directory is not writable. To make the directory writable and set www-data as owner, use the following commands: sudo chmod -R 775 " . $dir . " && sudo chown -R www-data:www-data " . $dir);
__errlog("aVideoEncoder.json: ERROR on save file " . $temp . ". Directory is not writable. To make the directory writable and set www-data as owner, use the following commands: sudo chmod -R 775 " . $dir . " && sudo chown -R www-data:www-data " . $dir);
} else {
_error_log("aVideoEncoder.json: ERROR on save file " . $temp . ". Directory is writable, but the file could not be saved. Possible causes could be disk space issues, file permission issues, or file system errors.");
__errlog("aVideoEncoder.json: ERROR on save file " . $temp . ". Directory is writable, but the file could not be saved. Possible causes could be disk space issues, file permission issues, or file system errors.");
}
}
}
return false;
}

function __errlog($txt){
global $global, $obj;
$obj->errorMSG[] = $txt;
_error_log($txt, AVideoLog::$ERROR);
}

0 comments on commit 47a23b9

Please sign in to comment.