我正在尝试下载youtube视频,但是当readfile只下载一个5 kb的文件时我遇到了障碍。
PHP
array
url_encoded_fmt_stream_map
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="videofile.mp4"');
$url = "https%3A%2F%2Fr1---sn-hp57kn7r.googlevideo.com%2Fvideoplayback%3Fipbits%3D0%26mt%3D1451427839%26nh%3DIgpwcjAzLm1pYTA0KgkxMjcuMC4wLjE%26fexp%3D3300134%252C3300137%252C3300164%252C3312381%252C9405265%252C9408540%252C9412777%252C9416126%252C9417056%252C9418184%252C9418222%252C9418400%252C9420452%252C9422596%252C9423662%252C9424552%252C9424823%252C9424981%252C9425381%252C9425403%252C9426538%26sver%3D3%26signature%3DAAC9121A2283672F4C84761DE6CBEF1CE2F5F6F5.E1CC3D9DEEA98D167E7D747990A3F53E00968869%26initcwndbps%3D192500%26key%3Dyt6%26sparams%3Ddur%252Cid%252Cinitcwndbps%252Cip%252Cipbits%252Citag%252Clmt%252Cmime%252Cmm%252Cmn%252Cms%252Cmv%252Cnh%252Cpl%252Cratebypass%252Crequiressl%252Csource%252Cupn%252Cexpire%26expire%3D1451449492%26lmt%3D1393704779008322%26ratebypass%3Dyes%26ip%3D98.89.14.143%26mn%3Dsn-hp57kn7r%26mm%3D31%26source%3Dyoutube%26ms%3Dau%26id%3Do-AJfgwitywpU71wLMxgZ4gx6YIYrwD6SiDTmN-gRPsVDi%26pl%3D17%26mv%3Dm%26requiressl%3Dyes%26mime%3Dvideo%252Fmp4%26dur%3D408.531%26upn%3DTYw3Io4raMI%26itag%3D22\u0026fallback_host=tc.v18.cache6.googlevideo.com\u0026quality=hd720\u0026itag=22\u0026type=video%2Fmp4";
$decodedurl = urldecode($url);
$dlurl = str_replace("%2C", ",", $decodedurl);
readfile($dlurl);
我用fiddler检索了这个数据。
答案 0 :(得分:0)
试试这个注意您的网址现已过期
$url = "https%3A%2F%2Fr1---sn-hp57kn7r.googlevideo.com%2Fvideoplayback%3Fipbits%3D0%26mt%3D1451427839%26nh%3DIgpwcjAzLm1pYTA0KgkxMjcuMC4wLjE%26fexp%3D3300134%252C3300137%252C3300164%252C3312381%252C9405265%252C9408540%252C9412777%252C9416126%252C9417056%252C9418184%252C9418222%252C9418400%252C9420452%252C9422596%252C9423662%252C9424552%252C9424823%252C9424981%252C9425381%252C9425403%252C9426538%26sver%3D3%26signature%3DAAC9121A2283672F4C84761DE6CBEF1CE2F5F6F5.E1CC3D9DEEA98D167E7D747990A3F53E00968869%26initcwndbps%3D192500%26key%3Dyt6%26sparams%3Ddur%252Cid%252Cinitcwndbps%252Cip%252Cipbits%252Citag%252Clmt%252Cmime%252Cmm%252Cmn%252Cms%252Cmv%252Cnh%252Cpl%252Cratebypass%252Crequiressl%252Csource%252Cupn%252Cexpire%26expire%3D1451449492%26lmt%3D1393704779008322%26ratebypass%3Dyes%26ip%3D98.89.14.143%26mn%3Dsn-hp57kn7r%26mm%3D31%26source%3Dyoutube%26ms%3Dau%26id%3Do-AJfgwitywpU71wLMxgZ4gx6YIYrwD6SiDTmN-gRPsVDi%26pl%3D17%26mv%3Dm%26requiressl%3Dyes%26mime%3Dvideo%252Fmp4%26dur%3D408.531%26upn%3DTYw3Io4raMI%26itag%3D22";
$data = urldecode($url);
header('Content-Disposition: attachment; filename="videofile.mp4"');
readfile($data);