如何获取Google驱动器文件的绝对文件路径作为url?

时间:2018-11-18 09:31:10

标签: html5 google-chrome google-drive-api

有什么方法可以获取Google驱动器中文件的文件路径?通常,谷歌驱动器文件的URL可以是一个共享的URL。但是,如果我们想访问绝对文件路径怎么办?就像是: drive.google.com/file/myvideo.mp4 然后,我想使用视频标签在网页中显示视频文件。

Google驱动器处理我上传的视频文件花费的时间太长,因此我无法将其嵌入到我的网站中,因此我认为也许访问文件路径可以解决问题:) 那么如何获得类似于url的内容呢?

感谢您的帮助。

编辑: 找到了!现在,我可以获取驱动器中任何文件的绝对文件路径。请按照以下步骤操作:

1-打开: https://drive.google.com/us?id=yourfileid yourfileid是文件ID 2-加载并复制页面上的URL 3-就是这样,这是绝对文件路径URL

1 个答案:

答案 0 :(得分:0)

要获取谷歌驱动器上视频的绝对路径,只需向链接发送请求

https://drive.google.com/u/1/get_video_info?docid="+IdVideo 

返回的将是一个逐字节的文件,其中包含视频中的所有信息,包括绝对链接,值得记住的是,数据立即在 url 中编码以访问它只是解码另一个重要点,并且您获得的链接仅对发出请求的设备有效,为什么将链接链接到 IP 以及发送请求的代理,例如,如果您通过邮递员发送请求并尝试在 chrome 中打开链接是访问被拒绝错误,反之亦然。 以下是请求提供的响应示例:

status=ok&hl=pt_BR&allow_embed=0&ps=docs&partnerid=30&autoplay=0&docid=1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8&abd=0&public=true&el=embed&title=Jogos+Vorazes+Em+Chamas+-+ToTTi9.mp4&BASE_URL=https%3A%2F%2Fdrive.google.com%2Fu%2F0%2F&iurl=https%3A%2F%2Fdrive.google.com%2Fu%2F0%2Fvt%3Fauthuser%3D0%26id%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%26s%3DAMedNnoAAAAAYHNJTEUxV9Q3qpFIyzfWQ9jSgXyoRJ7h&cc3_module=https%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fsubtitles3_module.swf&ttsurl=https%3A%2F%2Fdrive.google.com%2Fu%2F0%2Ftimedtext%3Fauthuser%3D0%26id%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%26vid%3D78edbfcf1fc76400&reportabuseurl=https%3A%2F%2Fdrive.google.com%2Fu%2F0%2Fabuse%3Fauthuser%3D0%26id%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8&token=1&plid=V0QWdNzM2hSOAQ&fmt_stream_map=18%7Chttps%3A%2F%2Fr2---sn-bg0eznlz.c.drive.google.com%2Fvideoplayback%3Fexpire%3D1618175340%26ei%3DLC1zYNjFDcOM8gStnI64Bg%26ip%3D45.184.131.85%26cp%3DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%26id%3D78edbfcf1fc76400%26itag%3D18%26source%3Dwebdrive%26requiressl%3Dyes%26mh%3DXL%26mm%3D32%26mn%3Dsn-bg0eznlz%26ms%3Dsu%26mv%3Du%26mvi%3D2%26pl%3D24%26ttl%3Dtransient%26susc%3Ddr%26driveid%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%26app%3Dexplorer%26mime%3Dvideo%2Fmp4%26vprv%3D1%26prv%3D1%26dur%3D8775.029%26lmt%3D1612203534601168%26mt%3D1618160459%26sparams%3Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%26sig%3DAOq0QJ8wRQIhAPjdubHafwixI9u_3cHc4Qt0sF8092zP3ZNSxPvqHY7nAiApe4jGKLmb4jVA4vqAGa5M-Sv2vPiwCCMFDIjzPvpq-Q%3D%3D%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%26lsig%3DAG3C_xAwRgIhAL9KrFxY09TeS3LW7B6wVmuM6pJTlVNC7B3uqVYHYXiuAiEAv43kEsHHcDK805VYorcU_CSm9_END9gpT_KX7QSZ9PA%3D%2C22%7Chttps%3A%2F%2Fr2---sn-bg0eznlz.c.drive.google.com%2Fvideoplayback%3Fexpire%3D1618175340%26ei%3DLC1zYNjFDcOM8gStnI64Bg%26ip%3D45.184.131.85%26cp%3DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%26id%3D78edbfcf1fc76400%26itag%3D22%26source%3Dwebdrive%26requiressl%3Dyes%26mh%3DXL%26mm%3D32%26mn%3Dsn-bg0eznlz%26ms%3Dsu%26mv%3Du%26mvi%3D2%26pl%3D24%26ttl%3Dtransient%26susc%3Ddr%26driveid%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%26app%3Dexplorer%26mime%3Dvideo%2Fmp4%26vprv%3D1%26prv%3D1%26dur%3D8775.029%26lmt%3D1612196404551931%26mt%3D1618160459%26sparams%3Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%26sig%3DAOq0QJ8wRAIgJFTtuzFA6Y8D-esOQBFfwIc0N2Sncbo32ERciZ9TaecCIGCvb44U8ejqtdUzc84GmFKT_17DpYj2iWXBROl3n5E2%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%26lsig%3DAG3C_xAwRQIgVeWACgdswVRbGA7KGlPCE1rbEkmbG-J7Qu_frbBTd3ECIQCvqYFUuOZ9quV33O5FsS5duvgynpNG_5IEZDm48i7Uhw%3D%3D%2C37%7Chttps%3A%2F%2Fr2---sn-bg0eznlz.c.drive.google.com%2Fvideoplayback%3Fexpire%3D1618175340%26ei%3DLC1zYNjFDcOM8gStnI64Bg%26ip%3D45.184.131.85%26cp%3DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%26id%3D78edbfcf1fc76400%26itag%3D37%26source%3Dwebdrive%26requiressl%3Dyes%26mh%3DXL%26mm%3D32%26mn%3Dsn-bg0eznlz%26ms%3Dsu%26mv%3Du%26mvi%3D2%26pl%3D24%26ttl%3Dtransient%26susc%3Ddr%26driveid%3D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%26app%3Dexplorer%26mime%3Dvideo%2Fmp4%26vprv%3D1%26prv%3D1%26dur%3D8775.029%26lmt%3D1612265735773933%26mt%3D1618160459%26sparams%3Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%26sig%3DAOq0QJ8wRAIgVK9gEt4VVCfclg29yeicdxkjSLBH5GLBaGc2zZ3rFs8CIEAZ-8QHSI3r2a2JI27km7J_6lf1yAF_knmUCfboxC5G%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%26lsig%3DAG3C_xAwRQIhAIMFtRVlbf2oImOUp7CqF_MlH5073S-RvuJ2s3rHqwHPAiBIjnF5UtBKJ73vipMsiqERIQ0kIVFeAq_jFP93gEhnVA%3D%3D&url_encoded_fmt_stream_map=itag%3D18%26url%3Dhttps%253A%252F%252Fr2---sn-bg0eznlz.c.drive.google.com%252Fvideoplayback%253Fexpire%253D1618175340%2526ei%253DLC1zYNjFDcOM8gStnI64Bg%2526ip%253D45.184.131.85%2526cp%253DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%2526id%253D78edbfcf1fc76400%2526itag%253D18%2526source%253Dwebdrive%2526requiressl%253Dyes%2526mh%253DXL%2526mm%253D32%2526mn%253Dsn-bg0eznlz%2526ms%253Dsu%2526mv%253Du%2526mvi%253D2%2526pl%253D24%2526ttl%253Dtransient%2526susc%253Ddr%2526driveid%253D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%2526app%253Dexplorer%2526mime%253Dvideo%252Fmp4%2526vprv%253D1%2526prv%253D1%2526dur%253D8775.029%2526lmt%253D1612203534601168%2526mt%253D1618160459%2526sparams%253Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%2526sig%253DAOq0QJ8wRQIhAPjdubHafwixI9u_3cHc4Qt0sF8092zP3ZNSxPvqHY7nAiApe4jGKLmb4jVA4vqAGa5M-Sv2vPiwCCMFDIjzPvpq-Q%253D%253D%2526lsparams%253Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%2526lsig%253DAG3C_xAwRgIhAL9KrFxY09TeS3LW7B6wVmuM6pJTlVNC7B3uqVYHYXiuAiEAv43kEsHHcDK805VYorcU_CSm9_END9gpT_KX7QSZ9PA%253D%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26quality%3Dmedium%2Citag%3D22%26url%3Dhttps%253A%252F%252Fr2---sn-bg0eznlz.c.drive.google.com%252Fvideoplayback%253Fexpire%253D1618175340%2526ei%253DLC1zYNjFDcOM8gStnI64Bg%2526ip%253D45.184.131.85%2526cp%253DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%2526id%253D78edbfcf1fc76400%2526itag%253D22%2526source%253Dwebdrive%2526requiressl%253Dyes%2526mh%253DXL%2526mm%253D32%2526mn%253Dsn-bg0eznlz%2526ms%253Dsu%2526mv%253Du%2526mvi%253D2%2526pl%253D24%2526ttl%253Dtransient%2526susc%253Ddr%2526driveid%253D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%2526app%253Dexplorer%2526mime%253Dvideo%252Fmp4%2526vprv%253D1%2526prv%253D1%2526dur%253D8775.029%2526lmt%253D1612196404551931%2526mt%253D1618160459%2526sparams%253Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%2526sig%253DAOq0QJ8wRAIgJFTtuzFA6Y8D-esOQBFfwIc0N2Sncbo32ERciZ9TaecCIGCvb44U8ejqtdUzc84GmFKT_17DpYj2iWXBROl3n5E2%2526lsparams%253Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%2526lsig%253DAG3C_xAwRQIgVeWACgdswVRbGA7KGlPCE1rbEkmbG-J7Qu_frbBTd3ECIQCvqYFUuOZ9quV33O5FsS5duvgynpNG_5IEZDm48i7Uhw%253D%253D%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26quality%3Dhd720%2Citag%3D37%26url%3Dhttps%253A%252F%252Fr2---sn-bg0eznlz.c.drive.google.com%252Fvideoplayback%253Fexpire%253D1618175340%2526ei%253DLC1zYNjFDcOM8gStnI64Bg%2526ip%253D45.184.131.85%2526cp%253DQVRGWkJfVFNSQVhPOlp3SExoWl9oYTNKYk56Sm1iU3dGd25LakR1Y1BUM01JNmVUYW5SRDNWZjM%2526id%253D78edbfcf1fc76400%2526itag%253D37%2526source%253Dwebdrive%2526requiressl%253Dyes%2526mh%253DXL%2526mm%253D32%2526mn%253Dsn-bg0eznlz%2526ms%253Dsu%2526mv%253Du%2526mvi%253D2%2526pl%253D24%2526ttl%253Dtransient%2526susc%253Ddr%2526driveid%253D1HCK3eleZSNQfpuZaI_oyIBQ9I_DroTq8%2526app%253Dexplorer%2526mime%253Dvideo%252Fmp4%2526vprv%253D1%2526prv%253D1%2526dur%253D8775.029%2526lmt%253D1612265735773933%2526mt%253D1618160459%2526sparams%253Dexpire%252Cei%252Cip%252Ccp%252Cid%252Citag%252Csource%252Crequiressl%252Cttl%252Csusc%252Cdriveid%252Capp%252Cmime%252Cvprv%252Cprv%252Cdur%252Clmt%2526sig%253DAOq0QJ8wRAIgVK9gEt4VVCfclg29yeicdxkjSLBH5GLBaGc2zZ3rFs8CIEAZ-8QHSI3r2a2JI27km7J_6lf1yAF_knmUCfboxC5G%2526lsparams%253Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%2526lsig%253DAG3C_xAwRQIhAIMFtRVlbf2oImOUp7CqF_MlH5073S-RvuJ2s3rHqwHPAiBIjnF5UtBKJ73vipMsiqERIQ0kIVFeAq_jFP93gEhnVA%253D%253D%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26quality%3Dhd1080&timestamp=1618160940245&length_seconds=8774&fmt_list=37%2F1920x1080%2F9%2F0%2F115%2C22%2F1280x720%2F9%2F0%2F115%2C18%2F640x360%2F9%2F0%2F115

如果您在下面使用 java 脚本,这是一个代码片段,如果可用或可用,请获取 720 质量的视频链接:

 async function obter_link_video(IdVideo){
      var All_Sizes_Video = {};
      var Returned = await fetch('https://drive.google.com/u/1/get_video_info?docid='+IdVideo);
      Returned = await Returned.text();
      Returned = await Returned.split("&");
      Returned.map((Value) => {
          var Result = Value.split("=");
          All_Sizes_Video[Result[0]] = Result[1];
      });
     if(All_Sizes_Video.status == "ok"){
     var size_array = [];
     var fmt_list = await decodeURIComponent(All_Sizes_Video.fmt_list);
     var fmt_list = fmt_list.split(",");
     var lenght_fmt_list = fmt_list.length-1;
     fmt_list.map((value, index) => {
         var result = value.split("/")[0];
         size_array.push(result);
         size_array.sort((a, b) => a - b);
         var length_size_array = size_array.lenght-1;
         if(index == lenght_fmt_list){
              size_array = lenght_fmt_list == 0 ?  size_array[0] : size_array[1];
         }
     });
     var map_all_links = await decodeURIComponent(All_Sizes_Video.fmt_stream_map);
     map_all_links = map_all_links.split(",");
     map_all_links.map((value) => {
         var select_size_video_by_link = value.split("|")[0] == size_array ? setlink_do_video(value.split("|")[1]) : "wrong";
         setesta_usando_link_absoluto(true);
         console.log(value.split('|')[1]);
    });
    }
  }

最后一个附录是每个 ip 每天最多可以发出 2000 个请求来获取有关视频的信息,如果超过此值,您将收到错误消息。