1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 02:09:22 +02:00

Fix og tags

This commit is contained in:
DanielnetoDotCom 2021-01-07 13:49:25 -03:00
parent 8b9a27bb64
commit fbb4a9c0e4
4 changed files with 46 additions and 45 deletions

View file

@ -60,19 +60,18 @@ $description = _substr(html2plainText($video['description']), 0,155);
<meta property="og:type" content="video.other" /> <meta property="og:type" content="video.other" />
<?php <?php
$sourceMP4 = Video::getSourceFile($video['filename'], ".mp4"); $source = Video::getSourceFile($video['filename'], ".mp4");
if(preg_match("/.m3u8/i", $sourceMP4['url'])){ if(empty($source['url']) && CustomizeUser::canDownloadVideos()){
if(CustomizeUser::canDownloadVideos()){ $source = Video::getSourceFile($video['filename'], ".m3u8");
$sourceMP4['url'] = addQueryStringParameter($sourceMP4['url'], "download", 1); if(!empty($source['url'])){
$sourceMP4['url'] = addQueryStringParameter($sourceMP4['url'], "mp4", 1); $source['url'] = addQueryStringParameter($source['url'], "download", 1);
}else{ $source['url'] = addQueryStringParameter($source['url'], "mp4", 1);
$sourceMP4['url'] = '';
} }
} }
if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($sourceMP4['url'])) { if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) {
?> ?>
<meta property="og:video" content="<?php echo $sourceMP4['url']; ?>" /> <meta property="og:video" content="<?php echo $source['url']; ?>" />
<meta property="og:video:secure_url" content="<?php echo $sourceMP4['url']; ?>" /> <meta property="og:video:secure_url" content="<?php echo $source['url']; ?>" />
<meta property="og:video:type" content="video/mp4" /> <meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="<?php echo $imgw; ?>" /> <meta property="og:video:width" content="<?php echo $imgw; ?>" />
<meta property="og:video:height" content="<?php echo $imgh; ?>" /> <meta property="og:video:height" content="<?php echo $imgh; ?>" />
@ -90,13 +89,13 @@ if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($sourceMP4
<!-- Twitter cards --> <!-- Twitter cards -->
<?php <?php
if (!empty($advancedCustom->twitter_player)) { if (!empty($advancedCustom->twitter_player)) {
if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($sourceMP4['url'])) { if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) {
?> ?>
<meta name="twitter:card" content="player" /> <meta name="twitter:card" content="player" />
<meta name="twitter:player" content=<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" /> <meta name="twitter:player" content=<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" />
<meta name="twitter:player:width" content="<?php echo $imgw; ?>" /> <meta name="twitter:player:width" content="<?php echo $imgw; ?>" />
<meta name="twitter:player:height" content="<?php echo $imgh; ?>" /> <meta name="twitter:player:height" content="<?php echo $imgh; ?>" />
<meta name="twitter:player:stream" content="<?php echo $sourceMP4['url']; ?>" /> <meta name="twitter:player:stream" content="<?php echo $source['url']; ?>" />
<meta name="twitter:player:stream:content_type" content="video/mp4" /> <meta name="twitter:player:stream:content_type" content="video/mp4" />
<?php <?php
} else { } else {

View file

@ -4970,20 +4970,15 @@ function downloadHLS($filepath) {
_error_log("downloadHLS: file NOT found: {$filepath}"); _error_log("downloadHLS: file NOT found: {$filepath}");
return false; return false;
} }
$output = m3u8ToMP4($filepath);
$videosDir = Video::getStoragePath().""; if(empty($output)){
die("downloadHLS was not possible");
$outputfilename = str_replace($videosDir, "", $filepath);
$parts = explode("/", $outputfilename);
$resolution = Video::getResolutionFromFilename($filepath);
$outputfilename = $parts[0] . "_{$resolution}_.mp4";
$outputpath = "{$videosDir}cache/downloads/{$outputfilename}";
make_path($outputpath);
if (empty($outputfilename)) {
_error_log("downloadHLS: empty outputfilename {$outputfilename}");
return false;
} }
$outputpath = $output['path'];
$outputfilename = $output['filename'];
if (!empty($_REQUEST['title'])) { if (!empty($_REQUEST['title'])) {
$quoted = sprintf('"%s"', addcslashes(basename($_REQUEST['title']), '"\\')); $quoted = sprintf('"%s"', addcslashes(basename($_REQUEST['title']), '"\\'));
} elseif (!empty($_REQUEST['file'])) { } elseif (!empty($_REQUEST['file'])) {
@ -4992,7 +4987,31 @@ function downloadHLS($filepath) {
$quoted = $outputfilename; $quoted = $outputfilename;
} }
$filepath = escapeshellcmd($filepath); header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . $quoted);
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("X-Sendfile: {$outputpath}");
exit;
}
function m3u8ToMP4($input){
$videosDir = Video::getStoragePath();
$outputfilename = str_replace($videosDir, "", $input);
$parts = explode("/", $outputfilename);
$resolution = Video::getResolutionFromFilename($input);
$outputfilename = $parts[0] . "_{$resolution}_.mp4";
$outputpath = "{$videosDir}cache/downloads/{$outputfilename}";
make_path($outputpath);
if (empty($outputfilename)) {
_error_log("downloadHLS: empty outputfilename {$outputfilename}");
return false;
}
$filepath = escapeshellcmd($input);
$outputpath = escapeshellcmd($outputpath); $outputpath = escapeshellcmd($outputpath);
if (!file_exists($outputpath)) { if (!file_exists($outputpath)) {
$command = get_ffmpeg() . " -allowed_extensions ALL -y -i {$filepath} -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$outputpath}"; $command = get_ffmpeg() . " -allowed_extensions ALL -y -i {$filepath} -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$outputpath}";
@ -5010,17 +5029,7 @@ function downloadHLS($filepath) {
} }
} }
} }
//var_dump($outputfilename, $command, $_GET, $filepath, $quoted);exit; return array('path'=>$outputpath, 'filename'=>$outputfilename);
//var_dump($command, $outputpath);exit;
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . $quoted);
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("X-Sendfile: {$outputpath}");
exit;
} }
function getSocialModal($videos_id, $url = "", $title = "") { function getSocialModal($videos_id, $url = "", $title = "") {

View file

@ -2866,18 +2866,10 @@ if (!class_exists('Video')) {
} }
if (!file_exists($source['path']) || ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10))) { if (!file_exists($source['path']) || ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10))) {
if ($type != "_thumbsV2.jpg" && $type != "_thumbsSmallV2.jpg" && $type != "_portrait_thumbsV2.jpg" && $type != "_portrait_thumbsSmallV2.jpg") { if ($type != "_thumbsV2.jpg" && $type != "_thumbsSmallV2.jpg" && $type != "_portrait_thumbsV2.jpg" && $type != "_portrait_thumbsSmallV2.jpg") {
$VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false);
if($type == ".mp4" || $type == ".webm" || $type == ".m3u8"){
$video = Video::getHigestResolution($filename);
}
if(file_exists(@$video['path'])){
$source = array('path' => $video['path'], 'url' => $video['url']);
}else{
$VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false); $VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false);
return $VideoGetSourceFile[$cacheName]; return $VideoGetSourceFile[$cacheName];
} }
} }
}
$videosPaths[$filename][$type][intval($includeS3)] = $source; $videosPaths[$filename][$type][intval($includeS3)] = $source;
} else { } else {

View file

@ -6,6 +6,7 @@ if (empty($backURL)) {
// if back URL is another video send it to the main page // if back URL is another video send it to the main page
$videos_id = getVideoIDFromURL($backURL); $videos_id = getVideoIDFromURL($backURL);
if(!empty($videos_id)){ if(!empty($videos_id)){
echo "<!-- backURL videos_id detected {$videos_id} -->";
$backURL = $global['webSiteRootURL']; $backURL = $global['webSiteRootURL'];
} }
} }