Skip to content

Commit

Permalink
Fix path
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Feb 12, 2025
1 parent 894f329 commit 8392310
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 additions & 2 deletions objects/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -4179,38 +4179,48 @@ public static function getSourceFile($filename, $type = ".jpg", $includeS3 = fal
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
//$source['url'] = addQueryStringParameter($source['url'], 'cache', uniqid());
$source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
} elseif (!empty($yptStorage) && !empty($site) && $isValidType && $fsize < 20) {
$siteURL = getCDNOrURL($site->getUrl(), 'CDN_YPTStorage', $video['sites_id']);
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
$source['url'] = "{$siteURL}{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = $site->getUrl() . "{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = "{$siteURL}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) {
$source['url'] = "{$siteURL}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}
} elseif (!empty($advancedCustom->videosCDN) && $canUseCDN) {
$advancedCustom->videosCDN = addLastSlash($advancedCustom->videosCDN);
$source['url'] = "{$advancedCustom->videosCDN}{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) {
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}
} else {
$source['url'] = getCDN() . "{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = getCDN() . "videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) {
$source['url'] = getCDN() . "videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}
}
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
Expand All @@ -4221,24 +4231,31 @@ public static function getSourceFile($filename, $type = ".jpg", $includeS3 = fal
if (!empty($cdn_obj->enable_storage)) {
if ($type === '.m3u8') {
$source['url'] = CDNStorage::getURL("{$filename}/index.m3u8");
} else if($type === '.mp4' && $indexMP4Exits) {
//var_dump("{$filename}/index.mp4");
$source['url'] = CDNStorage::getURL("{$filename}/index.mp4");
} else {
$source['url'] = CDNStorage::getURL("{$filename}{$type}");
}
$source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($aws_s3)) {
$source = $aws_s3->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_S3');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($bb_b2)) {
$source = $bb_b2->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_B2');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($ftp)) {
$source = $ftp->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_FTP');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
}
Expand Down Expand Up @@ -4272,6 +4289,7 @@ public static function getSourceFile($filename, $type = ".jpg", $includeS3 = fal
}
$source['url'] = addQueryStringParameter($source['url'], 'cache', $x);
$source['url_noCDN'] = addQueryStringParameter($source['url_noCDN'], 'cache', $x);
$source['line'] = __LINE__;
}
/*
if($filename == "video_230813150408_va39e" && $type == '.m3u8'){
Expand All @@ -4288,6 +4306,7 @@ public static function getSourceFile($filename, $type = ".jpg", $includeS3 = fal
}
$source['url'] = $secure->addToken($source['url'], $filename);
$source['url_noCDN'] = $secure->addToken($source['url_noCDN'], $filename);
$source['line'] = __LINE__;
}

TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
Expand Down Expand Up @@ -4336,7 +4355,6 @@ public static function getPaths($videoFilename, $createDir = false)
return $__getPaths[$videoFilename];
}
$cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename);
//var_dump('--'.$cleanVideoFilename, '++'.$videoFilename);
$videosDir = self::getStoragePath();

$path = addLastSlash("{$videosDir}{$cleanVideoFilename}");
Expand All @@ -4345,13 +4363,23 @@ public static function getPaths($videoFilename, $createDir = false)
if ($createDir) {
make_path(addLastSlash($path));
}

$relative = addLastSlash("videos/{$cleanVideoFilename}");
if (preg_match('/\.vtt$/', $videoFilename)) {
$url = $global['webSiteRootURL'] . "{$relative}";
} else {
$url = getCDN() . "{$relative}";
}
$__getPaths[$videoFilename] = ['filename' => $cleanVideoFilename, 'path' => $path, 'url' => $url, 'relative' => $relative];
if($cleanVideoFilename == 'index' && preg_match('/index.mp4$/', $videoFilename)){
$folder = str_replace('/index.mp4', '', $videoFilename);
$cleanVideoFilename = "$folder/index.mp4";
$relative = ("videos/{$cleanVideoFilename}");
$path = ("{$videosDir}{$cleanVideoFilename}");
$url = getCDN() . "{$cleanVideoFilename}";
$__getPaths[$videoFilename] = ['filename' => $cleanVideoFilename, 'path' => $path, 'url' => $url, 'relative' => $relative];
}else{
$__getPaths[$videoFilename] = ['filename' => $cleanVideoFilename, 'path' => $path, 'url' => $url, 'relative' => $relative];
}
return $__getPaths[$videoFilename];
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/CDN/Storage/CDNStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public static function putUsingAPI($filesToUpload)
$remote_file = CDNStorage::filenameToRemotePath($value);
_error_log("CDNStorage::putUsingAPI {$remote_file} ");
$client->upload($value, $remote_file);
$totalBytesTransferred += $filesize; // Update remaining size
$totalBytesTransferred += $filesize; // Update remaining size
} else {
_error_log("CDNStorage::putUsingAPI invalid filesize [$filesize] " . json_encode($value));
}
Expand Down

0 comments on commit 8392310

Please sign in to comment.