fork download
  1. #!/usr/bin/python
  2. # A Dropbox Proxy that enables files to be downloaded despite proxies.
  3. # It works by requesting a file, via text file in your Dropbox. Your home computer downloads it and puts it in your Dropbox.
  4. # You can then download it via dropbox.com, assuming it's not blocked.
  5. # Screw the Firewalls!!!
  6.  
  7. from os.path import basename
  8. from urlparse import urlsplit
  9. import urllib2
  10.  
  11. def url2name(url):
  12. return basename(urlsplit(url)[2])
  13. def download(url, localFileName = None):
  14. localName = url2name(url)
  15. req = urllib2.Request(url)
  16. r = urllib2.urlopen(req)
  17. if r.info().has_key('Content-Disposition'):
  18. # If the response has Content-Disposition, we take file name from it
  19. localName = r.info()['Content-Disposition'].split('filename=')[1]
  20. if localName[0] == '"' or localName[0] == "'":
  21. localName = localName[1:-1]
  22. elif r.url != url:
  23. # if we were redirected, the real file name we take from the final URL
  24. localName = url2name(r.url)
  25. if localFileName:
  26. # we can force to save the file as specified name
  27. localName = localFileName
  28. f = open(localName, 'wb')
  29. f.write(r.read())
  30. f.close()
  31.  
  32.  
  33. dropbox = 'http://d...content-available-to-author-only...x.com/u/3884086'
  34. user = '3884086'
  35. file = '30.Rock.S06E05.Today.You.Are.a.Man.avi'
  36.  
  37. # file
  38. download(dropbox + '/' + user + '/' + file)
Runtime error #stdin #stdout 0.06s 9560KB
stdin
1
2
10
42
11
stdout
Standard output is empty