Skip to content

Instantly share code, notes, and snippets.

@Epithumia
Created June 14, 2014 10:52
Show Gist options
  • Save Epithumia/a75c978f02b56b3ccec4 to your computer and use it in GitHub Desktop.
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)
# -*- 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