Skip to content

Commit

Permalink
Sync also audio files for new HLS
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Oct 28, 2024
1 parent 1015091 commit 58a2e13
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions plugin/CDN/Storage/CDNStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static function getStorageClient($try = 0)
{
$obj = AVideoPlugin::getDataObject('CDN');
if (empty($obj->storage_hostname)) {
//var_dump(debug_backtrace());
die('CDNStorage storage_hostname is empty ');
}
$CDNstorage = new \FtpClient\FtpClient();
Expand Down Expand Up @@ -201,8 +202,11 @@ public static function getRemoteDirectorySize($videos_id, $client = null)
public static function getFilesListInfo($local_path, $storage_pullzone, $videos_id, $skipDummyFiles = true)
{
global $global;
if ($skipDummyFiles && filesize($local_path) < 20) {
if ($skipDummyFiles && is_string($local_path) && filesize($local_path) < 20) {
return false;
}else if(!is_string($local_path)){
echo 'ERROR'.PHP_EOL;
var_dump($local_path, debug_backtrace());
}
if (empty($local_path)) {
return false;
Expand Down Expand Up @@ -1125,34 +1129,38 @@ public static function getFilesListLocal($videos_id, $skipDummyFiles = true)
if (!empty($_getFilesList_CDNSTORAGE[$videos_id])) {
return $_getFilesList_CDNSTORAGE[$videos_id];
}
$obj = AVideoPlugin::getDataObject('CDN');

$pz = self::getPZ();
$files = self::getLocalFolder($videos_id);
$video = Video::getVideoLight($videos_id);
$filesList = [];
$acumulative = 0;

// Iterate over root files or directories
foreach ($files as $value) {
if (is_array($value)) {
foreach ($value as $value2) {
$file = self::getFilesListInfo($value2, $pz, $videos_id, $skipDummyFiles);
if (!empty($file)) {
$acumulative += $file['local_filesize'];
$file['acumulativeFilesize'] = $acumulative;
$filesList[$file['relative']] = $file;
}
}
} else {
$file = self::getFilesListInfo($value, $pz, $videos_id, $skipDummyFiles);
if (!empty($file)) {
$acumulative += $file['local_filesize'];
$file['acumulativeFilesize'] = $acumulative;
$filesList[$file['relative']] = $file;
}
}
self::processFileOrDirectory($value, $filesList, $acumulative, $pz, $videos_id, $skipDummyFiles);
}

$_getFilesList_CDNSTORAGE[$videos_id] = $filesList;
return $filesList;
}

// Recursive function to process files and directories
private static function processFileOrDirectory($value, &$filesList, &$acumulative, $pz, $videos_id, $skipDummyFiles)
{
if (is_array($value)) {
foreach ($value as $subValue) {
self::processFileOrDirectory($subValue, $filesList, $acumulative, $pz, $videos_id, $skipDummyFiles);
}
} else {
$file = self::getFilesListInfo($value, $pz, $videos_id, $skipDummyFiles);
if (!empty($file)) {
$acumulative += $file['local_filesize'];
$file['acumulativeFilesize'] = $acumulative;
$filesList[$file['relative']] = $file;
}
}
}


public function getAddress($filename)
{
Expand Down

0 comments on commit 58a2e13

Please sign in to comment.