Reputation: 31
When I upload a video to Google Drive, it's converted to many qualities and become available for stream with a youtube player My question is how to get the direct video urls for different qualities using php.
So far I tried with file_get_contents, the player page and try to parse the code like this
$browser = $_SERVER['HTTP_USER_AGENT'];
$options = array('http' => array('user_agent' => $browser));
$context = stream_context_create($options);
$page= file_get_contents($link, false, $context);
$h= explode('"22|',$page);
$h1=$h[1];
$h2=explode(',',$h1);
$hd=$h2[0];
$hdsrc = str_replace('\u003d', '=', $hd);
$hdsrc = str_replace('\u0026', '&', $hdsrc);
$hdsrc = str_replace('%2C', '&', $hdsrc);
$hdsrc = str_replace('\\', '', $hdsrc);
I got the long url xxxxxx.googlevideo...............
but it's not playable !! Any ideas how can I get those direct video urls for different qualities.
PS: I know about the direct download link, I want the converted qualities URLs.
Thanks
Upvotes: 3
Views: 2378
Reputation: 57
The link type https://drive.google.com/uc?export=download&id={FILE_ID} work for play streaming audio in android with REST API v2, but in your google drive you have to change file security to "public if you have a link". I hope it help you.
Upvotes: 1