Thursday, 15 March 2012

Is it possible to download YouTube video links through PHP with resumable? -



Is it possible to download YouTube video links through PHP with resumable? -

is possible download youtube video links through php resumable. can fetch download links through youtube-dl.

in php resumable, needs known size of video. link can't fetch out size, possible create resumable through php.

let link is: [mp4]

https://r10---sn-hp576n7z.googlevideo.com/videoplayback?mt=1415174349&itag=22&fexp=915516%2c930666%2c932404%2c934601%2c947209%2c947215%2c948124%2c952302%2c952901%2c953912%2c957103%2c957201&key=yt5&upn=xe1em66ncsc&sparams=gcr%2cid%2cip%2cipbits%2citag%2cmime%2cmm%2cms%2cmv%2cratebypass%2crequiressl%2csource%2cupn%2cexpire&ipbits=0&ratebypass=yes&gcr=us&mv=u&id=o-anmao-oacohtvjp7yijsepi5a3vvlercss6ul3wlfoa7&ms=au&expire=1415196179&sver=3&ip=176.576.184.114&mime=video%2fmp4&requiressl=yes&source=youtube&mm=31&signature=29046d03c1ec013a78bd20e4cdd362bba62adf4b.a0e2e8e104769dd664202597a91f0888f9e554b3

try filesize:

<?php /** * returns size of file without downloading it, or -1 if file * size not determined. * * @param $url - location of remote file download. cannot * null or empty. * * @return size of file referenced $url, or -1 if size * not determined. */ function curl_get_file_size( $url ) { // assume failure. $result = -1; $curl = curl_init( $url ); // issue head request , follow redirects. curl_setopt( $curl, curlopt_nobody, true ); curl_setopt( $curl, curlopt_header, true ); curl_setopt( $curl, curlopt_returntransfer, true ); curl_setopt( $curl, curlopt_followlocation, true ); curl_setopt( $curl, curlopt_useragent, 'user_agent_string' ); $data = curl_exec( $curl ); curl_close( $curl ); if( $data ) { $content_length = "unknown"; $status = "unknown"; if( preg_match( "/^http\/1\.[01] (\d\d\d)/", $data, $matches ) ) { $status = (int)$matches[1]; } if( preg_match( "/content-length: (\d+)/", $data, $matches ) ) { $content_length = (int)$matches[1]; } // http://en.wikipedia.org/wiki/list_of_http_status_codes if( $status == 200 || ($status > 300 && $status <= 308) ) { $result = $content_length; } } homecoming $result; }

usage:

$file_size = curl_get_file_size($url);

php youtube download youtube-dl resume-download

No comments:

Post a Comment