Created
June 14, 2014 10:52
-
-
Save Epithumia/a75c978f02b56b3ccec4 to your computer and use it in GitHub Desktop.
Simple script to download images wirelessly from the Olympus E-M1 to the computer (with progress bar)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from urllib2 import urlopen | |
import re | |
page = urlopen('http://192.168.0.10/DCIM').read() | |
#print page | |
m = re.findall('(wlansd.*DCIM.*;)',page) | |
for entry in m: | |
folder = entry.split(',')[1] | |
#print folder | |
page = urlopen('http://192.168.0.10/DCIM/'+folder).read() | |
#print page | |
sub = re.findall('wlansd.*DCIM.*;',page) | |
for fi in sub: | |
img = fi.split(',')[1] | |
url = 'http://192.168.0.10/DCIM/' + folder + '/' + img | |
file_name = url.split('/')[-1] | |
u = urllib2.urlopen(url) | |
f = open(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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment