1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
This commit is contained in:
Daniel Neto 2025-02-11 21:54:12 -03:00
parent 894f3292d3
commit 8392310423
2 changed files with 31 additions and 3 deletions

View file

@ -4179,38 +4179,48 @@ if (!class_exists('Video')) {
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
//$source['url'] = addQueryStringParameter($source['url'], 'cache', uniqid()); //$source['url'] = addQueryStringParameter($source['url'], 'cache', uniqid());
$source['url_noCDN'] = $source['url']; $source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
} elseif (!empty($yptStorage) && !empty($site) && $isValidType && $fsize < 20) { } elseif (!empty($yptStorage) && !empty($site) && $isValidType && $fsize < 20) {
$siteURL = getCDNOrURL($site->getUrl(), 'CDN_YPTStorage', $video['sites_id']); $siteURL = getCDNOrURL($site->getUrl(), 'CDN_YPTStorage', $video['sites_id']);
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
$source['url'] = "{$siteURL}{$paths['relative']}{$filename}{$type}"; $source['url'] = "{$siteURL}{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = $site->getUrl() . "{$paths['relative']}{$filename}{$type}"; $source['url_noCDN'] = $site->getUrl() . "{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) { if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = "{$siteURL}videos/{$filename}/index{$type}"; $source['url'] = "{$siteURL}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) { }else if ($indexMP4Exits) {
$source['url'] = "{$siteURL}videos/{$filename}/index{$type}"; $source['url'] = "{$siteURL}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
} }
} elseif (!empty($advancedCustom->videosCDN) && $canUseCDN) { } elseif (!empty($advancedCustom->videosCDN) && $canUseCDN) {
$advancedCustom->videosCDN = addLastSlash($advancedCustom->videosCDN); $advancedCustom->videosCDN = addLastSlash($advancedCustom->videosCDN);
$source['url'] = "{$advancedCustom->videosCDN}{$paths['relative']}{$filename}{$type}"; $source['url'] = "{$advancedCustom->videosCDN}{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) { if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}"; $source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) { }else if ($indexMP4Exits) {
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}"; $source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
} }
} else { } else {
$source['url'] = getCDN() . "{$paths['relative']}{$filename}{$type}"; $source['url'] = getCDN() . "{$paths['relative']}{$filename}{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}{$paths['relative']}{$filename}{$type}";
$source['line'] = __LINE__;
if ($type == ".m3u8" || $indexMP3Exits) { if ($type == ".m3u8" || $indexMP3Exits) {
$source['url'] = getCDN() . "videos/{$filename}/index{$type}"; $source['url'] = getCDN() . "videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
}else if ($indexMP4Exits) { }else if ($indexMP4Exits) {
$source['url'] = getCDN() . "videos/{$filename}/index{$type}"; $source['url'] = getCDN() . "videos/{$filename}/index{$type}";
$source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}"; $source['url_noCDN'] = "{$global['webSiteRootURL']}videos/{$filename}/index{$type}";
$source['line'] = __LINE__;
} }
} }
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
@ -4221,24 +4231,31 @@ if (!class_exists('Video')) {
if (!empty($cdn_obj->enable_storage)) { if (!empty($cdn_obj->enable_storage)) {
if ($type === '.m3u8') { if ($type === '.m3u8') {
$source['url'] = CDNStorage::getURL("{$filename}/index.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 { } else {
$source['url'] = CDNStorage::getURL("{$filename}{$type}"); $source['url'] = CDNStorage::getURL("{$filename}{$type}");
} }
$source['url_noCDN'] = $source['url']; $source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($aws_s3)) { } elseif (!empty($aws_s3)) {
$source = $aws_s3->getAddress("{$filename}{$type}"); $source = $aws_s3->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url']; $source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_S3'); $source['url'] = replaceCDNIfNeed($source['url'], 'CDN_S3');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($bb_b2)) { } elseif (!empty($bb_b2)) {
$source = $bb_b2->getAddress("{$filename}{$type}"); $source = $bb_b2->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url']; $source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_B2'); $source['url'] = replaceCDNIfNeed($source['url'], 'CDN_B2');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} elseif (!empty($ftp)) { } elseif (!empty($ftp)) {
$source = $ftp->getAddress("{$filename}{$type}"); $source = $ftp->getAddress("{$filename}{$type}");
$source['url_noCDN'] = $source['url']; $source['url_noCDN'] = $source['url'];
$source['line'] = __LINE__;
$source['url'] = replaceCDNIfNeed($source['url'], 'CDN_FTP'); $source['url'] = replaceCDNIfNeed($source['url'], 'CDN_FTP');
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
} }
@ -4272,6 +4289,7 @@ if (!class_exists('Video')) {
} }
$source['url'] = addQueryStringParameter($source['url'], 'cache', $x); $source['url'] = addQueryStringParameter($source['url'], 'cache', $x);
$source['url_noCDN'] = addQueryStringParameter($source['url_noCDN'], 'cache', $x); $source['url_noCDN'] = addQueryStringParameter($source['url_noCDN'], 'cache', $x);
$source['line'] = __LINE__;
} }
/* /*
if($filename == "video_230813150408_va39e" && $type == '.m3u8'){ if($filename == "video_230813150408_va39e" && $type == '.m3u8'){
@ -4288,6 +4306,7 @@ if (!class_exists('Video')) {
} }
$source['url'] = $secure->addToken($source['url'], $filename); $source['url'] = $secure->addToken($source['url'], $filename);
$source['url_noCDN'] = $secure->addToken($source['url_noCDN'], $filename); $source['url_noCDN'] = $secure->addToken($source['url_noCDN'], $filename);
$source['line'] = __LINE__;
} }
TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit); TimeLogEnd($timeLog1, __LINE__, $timeLog1Limit);
@ -4336,7 +4355,6 @@ if (!class_exists('Video')) {
return $__getPaths[$videoFilename]; return $__getPaths[$videoFilename];
} }
$cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename); $cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename);
//var_dump('--'.$cleanVideoFilename, '++'.$videoFilename);
$videosDir = self::getStoragePath(); $videosDir = self::getStoragePath();
$path = addLastSlash("{$videosDir}{$cleanVideoFilename}"); $path = addLastSlash("{$videosDir}{$cleanVideoFilename}");
@ -4345,13 +4363,23 @@ if (!class_exists('Video')) {
if ($createDir) { if ($createDir) {
make_path(addLastSlash($path)); make_path(addLastSlash($path));
} }
$relative = addLastSlash("videos/{$cleanVideoFilename}"); $relative = addLastSlash("videos/{$cleanVideoFilename}");
if (preg_match('/\.vtt$/', $videoFilename)) { if (preg_match('/\.vtt$/', $videoFilename)) {
$url = $global['webSiteRootURL'] . "{$relative}"; $url = $global['webSiteRootURL'] . "{$relative}";
} else { } else {
$url = getCDN() . "{$relative}"; $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]; return $__getPaths[$videoFilename];
} }

View file

@ -604,7 +604,7 @@ class CDNStorage
$remote_file = CDNStorage::filenameToRemotePath($value); $remote_file = CDNStorage::filenameToRemotePath($value);
_error_log("CDNStorage::putUsingAPI {$remote_file} "); _error_log("CDNStorage::putUsingAPI {$remote_file} ");
$client->upload($value, $remote_file); $client->upload($value, $remote_file);
$totalBytesTransferred += $filesize; // Update remaining size $totalBytesTransferred += $filesize; // Update remaining size
} else { } else {
_error_log("CDNStorage::putUsingAPI invalid filesize [$filesize] " . json_encode($value)); _error_log("CDNStorage::putUsingAPI invalid filesize [$filesize] " . json_encode($value));
} }