gpt4 book ai didi

php - 如何从 Google 云端硬盘视频中获取 redirector.googlevideo.com 链接

转载 作者:可可西里 更新时间:2023-11-01 12:20:30 26 4
gpt4 key购买 nike

我有一个谷歌驱动器视频文件(如 https://drive.google.com/file/d/FILE_ID/view ),我想获取它的 redirector.googlevideo.com 链接。

http://api.getlinkdrive.com/ 这样的网站如何?做吗?我试过使用 Google Drive REST API(v2 和 v3),但仍然找不到方法。许多电视节目和电影网站将他们的内容托管在谷歌驱动器上,并使用这个过期的“隐藏的”URL,这样你就不能将它嵌入其他地方。

我得到的最接近的方法是转到 docs.google.com/get_video_info?docid=FILE_ID 并获取 fmt_stream_map 链接,但这不会返回我需要的重定向器链接。

最佳答案

PHP 代码在这里不起作用,甚至没有意义,因为它将返回服务器端的结果。

这是我的 Javascript/Ajax 代码。不幸的是,你应该使用 Access-Control-Allow-Origin extension在 Chrome 浏览器中。首先请看this screenshot控制台窗口。

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://content.jwplatform.com/libraries/YOUR-JW-PLAYER-LICENSE-KEY.js"></script>
</head>

<body>
<p id="urls"></p>
<div id="myElement"></div>
</body>

<script>
var docid = "0B4Mn0g4wWmQ1ZThycVhOcDJQc2c";
var api_url = "https://docs.google.com/get_video_info";
var ans = {};
var url = "";

getGoogleVideoUrl();

function getGoogleVideoUrl(){
$.ajax({
url: api_url,
type: "get",
data: {
docid: docid,
},
success: function(response) {
//
// get value of which key is 'fmt_stream_map'.
//
var fmt_stream_map = getQueryVariable(response, 'fmt_stream_map');
//
// split my comma
//
var maps = fmt_stream_map.split("%2C");
//
// loop all links,
//
var purl = "";
for (x in maps) {
var res = decodeURIComponent(decodeURIComponent(maps[x])).split('|');
// purl = res[1].replace(new RegExp("/\/[^\/]+\.google\.com/", 'g'),"//redirector.googlevideo.com/");
// purl = res[1].replace(new RegExp("\.google\.com/", 'g'),".googlevideo.com/");

purl = res[1];
//.replace(/.c.docs.google.com/g,".googlevideo.com")
//.replace(/app=explorer/g,"app=storage")
//.replace(/key=ck2/g,"key=cms1")
//.replace(/&cp=/g,"&api=")
//.replace(/,cp&/g,',api&')
//.replace(/,cp,/g,',api,')
//.replace(/=cp,/g,'=api,')
//.replace(/&sparams=/g,'&cms_redirect=yes&sparams=');

switch (parseInt(res[0])) {
case 5:
quality = 'Low Quality, 240p, FLV, 400x240';
break;
case 17:
quality = 'Low Quality, 144p, 3GP, 0x0';
break;
case 18:
quality = 'Medium Quality, 360p, MP4, 480x360';
break;
case 22:
quality = 'High Quality, 720p, MP4, 1280x720';
break;
case 34:
quality = 'Medium Quality, 360p, FLV, 640x360';
break;
case 35:
quality = 'Standard Definition, 480p, FLV, 854x480';
break;
case 36:
quality = 'Low Quality, 240p, 3GP, 0x0';
break;
case 37:
quality = 'Full High Quality, 1080p, MP4, 1920x1080';
break;
case 38:
quality = 'Original Definition, MP4, 4096x3072';
break;
case 43:
quality = 'Medium Quality, 360p, WebM, 640x360';
break;
case 44:
quality = 'Standard Definition, 480p, WebM, 854x480';
break;
case 45:
quality = 'High Quality, 720p, WebM, 1280x720';
break;
case 46:
quality = 'Full High Quality, 1080p, WebM, 1280x720';
break;
case 82:
quality = 'Medium Quality 3D, 360p, MP4, 640x360';
break;
case 84:
quality = 'High Quality 3D, 720p, MP4, 1280x720';
break;
case 102:
quality = 'Medium Quality 3D, 360p, WebM, 640x360';
break;
case 104:
quality = 'High Quality 3D, 720p, WebM, 1280x720';
break;
default:
quality = 'transcoded (unknown) quality';
break;
}
ans[quality] = purl;
}
console.log(ans);
$('#urls').html(JSON.stringify(ans));

url = ans[Object.keys(ans)[0]];
build_player();

},
error: function(xhr) {
//Do Something to handle error
}
});
}



function build_player(){
var playerInstance = jwplayer("myElement");
playerInstance.setup({
file: url,
type: "mp4",
width: 800 ,
height: 600,
});
}

function getQueryVariable(query, variable) {
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
//return decodeURIComponent(pair[1]);
return pair[1];
}
}
console.log('Query variable %s not found', variable);
return "";
}

</script>
</html>

这段代码基本可以运行,但是在jwplayer组件中没有播放。

但是,如果你输入这个 URL,“https://docs.google.com/get_video_info?docid=0B4Mn0g4wWmQ1ZThycVhOcDJQc2c”,直接在 chrome 浏览器中,获取 JSON 文件,手动解析它,直接在这段代码中使用其中一个 URL 作为 jwplayer 的文件 url,它工作得很好,虽然它包含“app=explorer”标签本身。

我不确定为什么会这样。所以我试着比较 2 个链接,有些参数是不同的。第一个来自上面的代码并且不工作,第二个 JSON 文件直接并且工作。)

ei=hJ5yWaHCKYXb-wWona2YBA
ei=KZ5yWZSkK4aFqgXAwpoo

susci=o-AC34EOoA1Wst0Heh0U_bP9epqR8K9s4UBhwlqmsxKZKwAOA
susci=o-AH82qbGL8BcWQ3BPybbvZyuNBiDd2Uasz4J0ZNXJCZwobPje

expire=1500698308
expire=1500698217

cp=QVNFUkdfV1NOSVhOOnhwOWFybUloWXNX
cp=QVNFUkdfV1JPSFhOOmpURGRUeUt3eVpv

signature=3D306FD9D9ADA683D313AABDFE057B608A6F2A39.8BB3A9C321B6BEAC8D1D5AEED2F25511DF97CE2B
signature=2C2465BDFC4D9CCFD0D4A42F38BAEF44D55AFDF1.A916937113445ABB90D18B3AE89600729CFADDE6

为什么第一个不工作而第二个工作?有什么想法吗?

关于php - 如何从 Google 云端硬盘视频中获取 redirector.googlevideo.com 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42115189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com