Skip to content Skip to sidebar Skip to footer

Python - Download Video From Indirect Url

I have a link like this https://r9---sn-4g57knle.googlevideo.com/videoplayback?id=10bc30daeba89d81&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-

Solution 1:

You can use pycurl

#!/bin/usr/env python
import sys
import pycurl

c = pycurl.Curl()
c.setopt(c.FOLLOWLOCATION, 1)
c.setopt(c.URL, sys.argv[1])
with open(sys.argv[2], 'w') as f:
    c.setopt(c.WRITEFUNCTION, f.write)
    c.perform()

Usage:

$ chmod +x a.py 
$ ./a.py "https://2.bp.blogspot.com/bO0q678cHRVZqTDclb33qGUXve_X1CRTgHMVz9NUgA=m22" output.mp4
$ file output.mp4
output.mp4: ISO Media, MP4 v2 [ISO 14496-14]

Post a Comment for "Python - Download Video From Indirect Url"