I have a system that captures the information of the video of Google drive through the id, and with that I can mount the structure of my video player. I can capture the video thumbnail, and title.
look at the following code.
index.php
<?php
error_reporting(0);
include "drive.php";
$id = $_GET['id'];
$l = $_GET['l'];
$URL = "https://drive.google.com/file/d/".$id."/view?pli=1";
$legenda = "file:'".$l."', label:'PT-BR', kind:'captions', default:'true'";
$linkdown = Drive($URL);
$URL = "https://drive.google.com/get_video_info?docid=$id";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response_data = urldecode(urldecode(curl_exec($curl)));
curl_close($curl);
//status
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http";
$shot = "https://drive.google.com/vt?".$_SERVER["QUERY_STRING"];
$sharing = $protocol."://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
if(preg_match("/errorcode=100/", $response_data) && strlen($_SERVER["QUERY_STRING"])!= "28"){
$title = "Digite o codigo de ID do video corretamente.";
} elseif(preg_match("/errorcode=100/", $response_data)) {
$title = "Esse video esta protegido";
} elseif(preg_match("/errorcode=150/", $response_data)) {
$title = "O video esta sendo processado, Aperte o player para reproduzir.";
} else {
$title = preg_replace("/&BASE_URL.*/", Null, preg_replace("/.*title=/", Null, $response_data));
}
$file = '[{file: "'.$linkdown.'",type: "video/mp4"}]';
?>
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
<?php
if($title != ''){ echo '<title>'.$title.'</title>'; }
?>
<link href="./jw7/skins/thin.min.css" rel="stylesheet" type="text/css" />
<link href="./jw7/skins/jw-logo-bar.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="./drive_favicon.ico">
<meta name="robots" content="noindex" />
<META NAME="GOOGLEBOT" CONTENT="NOINDEX" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<script type="text/javascript" src="./jw7/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="./jw7/jwplayer-7.3.6/jwplayer.js"></script>
<script type="text/javascript">jwplayer.key="Ywok59g9j93GtuSU7+axNzjIp/TBfiK4s0vvYg==";</script>
<script type="text/javascript" src="./jw7/skins/jw-logo-bar.js"></script>
<style>*{margin:0px;}html{overflow:hidden;}#player{position:absolute;width:100%!important;height:100%!important}</style>
<style>
.jw-captions-text {
color: #FFEB3B !important;
font-size: 20pt !important;
background-color: transparent !important;
}
.jw-skin-thin .jw-volume-tip {
border-color:transparent !important;
border-radius:3px !important;
}
.jw-skin-thin .jw-slider-vertical .jw-progress {
cursor: row-resize !important;
background-color: #ef3123 !important;
border-size:3px;
}
.jwplayer .jw-preview, .jw-error .jw-preview, .jw-stretch-uniform .jw-preview {
background-size: cover !important;
}
</style>
</head>
<body>
<div id="player" class="player"></div>
<script type="text/javascript">
var encrpytplay = jwplayer("player");
encrpytplay.setup({
width: "100%",
height: "100%",
skin: { name: "thin" },
title: "<?php echo $title;?>",
controls: true,
displaytitle: true,
fullscreen: "true",
primary: 'html5',
provider: 'http',
autostart: false,
image:"<?php echo $shot; ?>", // https://i.imgur.com/zQ3Mtff.jpg
sources: <?php echo $file?>,
tracks: [{ <?php echo $legenda; ?> }],
logo : { file: "https://i.imgur.com/JAgpGc1.png", logoBar: "https://i.imgur.com/JAgpGc1.png", link: "/", hide: false },
abouttext: "POWERSTREAM",
aboutlink: "/",
});
videoPlayer.on('ready',function() {
jwLogoBar.addLogo(videoPlayer);
});
</script>
</body>
</html>
include drive.php
<?php
define('HDOM_TYPE_ELEMENT', 1);
define('HDOM_TYPE_COMMENT', 2);
define('HDOM_TYPE_TEXT', 3);
define('HDOM_TYPE_ENDTAG', 4);
define('HDOM_TYPE_ROOT', 5);
define('HDOM_TYPE_UNKNOWN', 6);
define('HDOM_QUOTE_DOUBLE', 0);
define('HDOM_QUOTE_SINGLE', 1);
define('HDOM_QUOTE_NO', 3);
define('HDOM_INFO_BEGIN', 0);
define('HDOM_INFO_END', 1);
define('HDOM_INFO_QUOTE', 2);
define('HDOM_INFO_SPACE', 3);
define('HDOM_INFO_TEXT', 4);
define('HDOM_INFO_INNER', 5);
define('HDOM_INFO_OUTER', 6);
define('HDOM_INFO_ENDSPACE',7);
// helper functions
// -----------------------------------------------------------------------------
// get html dom form file
//Create folder if it doesn't already exist
if (!file_exists('cache')) {
mkdir('cache', 0777, true);
}
//Check cache
function Drive($link) {
$timeout = 900;
$file_name = md5('AA'.$link.'A3Code');
if(file_exists('cache/'.$file_name.'.cache')) {
$fopen = file_get_contents('cache/'.$file_name.'.cache');
$data = explode('@@', $fopen);
$now = gmdate('Y-m-d H:i:s', time() + 3600*(+7+date('I')));
$times = strtotime($now) - $data[0];
if($times >= $timeout) {
$tmp = explode("file/d/",$link);
$tmp2 = explode("/",$tmp[1]);
$id = $tmp2[0];
$linkdown = trim(getlink($id));
$create_cache = gd_cache($link, $linkdown);
$arrays = explode('|', $create_cache);
$cache = $arrays[0];
} else {
$cache = $data[1];
}
} else {
$tmp = explode("file/d/",$link);
$tmp2 = explode("/",$tmp[1]);
$id = $tmp2[0];
$linkdown = trim(getlink($id));
$create_cache = gd_cache($link, $linkdown);
$arrays = explode('|', $create_cache);
$cache = $arrays[0];
}
return $cache;
}
//New cache
function gd_cache($link, $source) {
$time = gmdate('Y-m-d H:i:s', time() + 3600*(+7+date('I')));
$file_name = md5('AA'.$link.'A3Code');
$string = strtotime($time).'@@'.$source;
$file = fopen("cache/".$file_name.".cache",'w');
fwrite($file,$string);
fclose($file);
if(file_exists('cache/'.$file_name.'.cache')) {
$msn = $source;
} else {
$msn = $source;
}
return $msn;
}
function getlink($id){
$link = "https://drive.google.com/uc?export=download&id=$id";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/google.mp3");
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/google.mp3");
$page = curl_exec($ch);
$get = locheader($page);
if ($get != ""){
} else {
$html = str_get_html($page);
$link = urldecode(trim($html->find('a[id=uc-download-link]',0)->href));
$tmp = explode("confirm=",$link);
$tmp2 = explode("&",$tmp[1]);
$confirm = $tmp2[0];
$linkdowngoc = "https://drive.google.com/uc?export=download&id=$id&confirm=$confirm";
curl_setopt ($ch, CURLOPT_URL, $linkdowngoc);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/google.mp3");
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/google.mp3");
// Getting binary data
$page = curl_exec($ch);
$get = locheader($page);
}
curl_close($ch);
return $get;
}
Código muito grande para continuar...
?>
How can I get the quality links and save them in variables to use in the player?