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.  
  10. def url2name(url):
  11. return basename(urlsplit(url)[2])
  12. def download(url, localFileName = None):
  13. localName = url2name(url)
  14. req = urllib2.Request(url)
  15. r = urllib2.urlopen(req)
  16. if r.info().has_key('Content-Disposition'):
  17. # If the response has Content-Disposition, we take file name from it
  18. localName = r.info()['Content-Disposition'].split('filename=')[1]
  19. if localName[0] == '"' or localName[0] == "'":
  20. localName = localName[1:-1]
  21. elif r.url != url:
  22. # if we were redirected, the real file name we take from the final URL
  23. localName = url2name(r.url)
  24. if localFileName:
  25. # we can force to save the file as specified name
  26. localName = localFileName
  27. f = open(localName, 'wb')
  28. f.write(r.read())
  29. f.close()
  30.  
  31.  
  32. dropbox = 'http://d...content-available-to-author-only...x.com/u/3884086'
  33. user = '3884086'
  34. file = '30.Rock.S06E05.Today.You.Are.a.Man.avi'
  35.  
  36. # file
  37. download(dropbox + '/' + user + '/' + file)
Runtime error #stdin #stdout 0.03s 6740KB
stdin
1
2
10
42
11
stdout
Standard output is empty