Search code examples
javascriptphphtmlforce-download

How to download external video without playing in browser?


I try to download a video without playing in my Android default browser or Firefox. I already tried like below:

<a href="https://something.googlevideo.com/xxxxxx&title=Video+Title" download>Download</a>

<a href="https://something.googlevideo.com/xxxxxx&title=Video+Title" target="_blank" download>Download</a>

<a href="https://something.googlevideo.com/xxxxxx&title=Video+Title" rel=”external" download>Download</a>

url: https://r1---sn-bg5hxxo2ivox-q5jz.googlevideo.com/videoplayback?aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398&fvip=1&sparams=aitags%2Cclen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&mime=video%2Fmp4&id=o-ALRV5YpAaCpyILP6H-8loaZj-ZDemJBajF3jtnfwxUch&itag=398&dur=240.320&clen=30917236&lmt=1539885977797930&ip=119.30.32.177&key=yt6&expire=1553211455&c=WEB&ei=3suTXOHhPKS88QP8vYCoDg&ms=au%2Crdu&mt=1553189732&mv=m&ipbits=0&mm=31%2C29&mn=sn-bg5hxxo2ivox-q5jz%2Csn-npoeene6&requiressl=yes&keepalive=yes&source=youtube&txp=5511222&pl=24&gir=yes&initcwndbps=63750&title=ytdl.ml+-++Guru+Randhawa_+Ban+Ja+Rani+Video+Song+With+Lyrics+_+Tumhari+Sulu+_+Vidya+Balan+Manav+Kaul+&ratebypass=yes&signature=0CC08F953D3A80FE8283591B910AD243B57069E8.A1F38C1FDD6E9BA461C4A69210106728890DE858

I don't want to download this video in my server. How can I download this video using PHP or JavaScript or HTML?


Solution

  • The download html attribute only works when the file is on the same URL of your webpage.

    For downloading external URLs, the external server must send the download HTTP headers

    Other way to make it work is create an Proxy on your server, this way the download URL will be the same of the website, but every download will use your server network traffic (not good idea)

    <a> download attribute not working anymore