Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2
- import os
- # from dragline.http import Reques
- # url = "http://us-7.blastvideo.ws/user_box/brimstone/videos/DTBS207_xbox.mp4?start=0"
- currd = os.getcwd()
- headers = {
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.',
- 'Accept-Encoding': 'gzip, deflate, sdch',
- 'Accept-Language': 'en-US,en;q=0.8',
- 'Cache-Control': 'no-cache',
- 'Connection': 'keep-alive',
- 'Host': '176.31.237.56',
- 'Pragma': 'no-cache',
- 'User-Agent': 'Mozilla/5.0',
- 'X-Requested-With': 'ShockwaveFlash/17.0.0.134'
- }
- def download(url,file_name):
- # file_name = url.split('/')[-1]
- # request = urllib2.Request(url,headers=headers)
- # print request
- u = urllib2.urlopen(url)
- f = open(currd +'/'+file_name, 'wb')
- meta = u.info()
- file_size = int(meta.getheaders("Content-Length")[0])
- print "Downloading: %s Bytes: %s" % (file_name, file_size)
- file_size_dl = 0
- block_sz = 8192
- while True:
- buffer = u.read(block_sz)
- if not buffer:
- break
- file_size_dl += len(buffer)
- f.write(buffer)
- status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
- status = status + chr(8)*(len(status)+1)
- print status,
- f.close()
- if __name__ == '__main__':
- urls = [{
- "name":"Goosebumps.mp4",
- "url":"http://sharesix.com/f/0orLvQ6"
- }]
- for i in urls:
- try:
- download(i['url'],i['name'])
- except:
- print "Error in",i['url'][0],i['name']
Add Comment
Please, Sign In to add comment