you can get the type of video using the info () method or dict headers
f=urllib2.urlopen(url) print f.headers['Content-Type'] print f.info()
Run with a randomly selected avi file running on the network, which is more than 600 MB
$ cat test.py #!/usr/bin/env python import urllib2 url="http://www.merseypirates.com/rjnsteve/rjnsteve/oem16.avi" f=urllib2.urlopen(url) print f.headers['Content-Type'] $ time python test.py video/x-msvideo real 0m4.931s user 0m0.115s sys 0m0.042s
it will “take bandwidth” only when the file is downloaded, i.e. packets are sent to and from the socket.
ghostdog74
source share