Created
June 29, 2014 20:24
-
-
Save Epithumia/6c83aa3cbedc71d7739c to your computer and use it in GitHub Desktop.
Proof of concept : wireless tethering on the E-M1, in camera control mode
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 urllib import urlretrieve | |
from urllib2 import urlopen | |
import re | |
import time | |
urlopen('http://192.168.0.10/switch_cammode.cgi?mode=play').read() | |
page = urlopen('http://192.168.0.10/get_imglist.cgi?DIR=/DCIM').read() | |
m = re.findall('(DCIM.*)',page)[0].split(',')[1] | |
page = urlopen('http://192.168.0.10/get_imglist.cgi?DIR=/DCIM/'+m).read() | |
startList = page.split() # List of pictures on the camera | |
curnumdata = urlopen('http://192.168.0.10/get_dcffilenum.cgi').read() | |
curnum=re.search('(<dcffile>)(.*)(</dcffile>)',curnumdata).group(2) # Number of most recent image | |
lastnum = curnum | |
# Set the camera to control mode | |
urlopen('http://192.168.0.10/switch_cammode.cgi?mode=shutter').read() | |
# Check every 5 minutes whether a picture was taken or not | |
while lastnum==curnum: | |
time.sleep(300) | |
# Set play mode, you can't ask the cam for info if in shutter mode | |
urlopen('http://192.168.0.10/switch_cammode.cgi?mode=play').read() | |
curnumdata = urlopen('http://192.168.0.10/get_dcffilenum.cgi').read() | |
# Restore shutter mode | |
urlopen('http://192.168.0.10/switch_cammode.cgi?mode=shutter').read() | |
curnum=re.search('(<dcffile>)(.*)(</dcffile>)',curnumdata).group(2) | |
# If a picture was taken, set mode to play, then grab list of files | |
urlopen('http://192.168.0.10/switch_cammode.cgi?mode=play').read() | |
page = urlopen('http://192.168.0.10/get_imglist.cgi?DIR=/DCIM').read() | |
m = re.findall('(DCIM.*)',page)[0].split(',')[1] | |
page = urlopen('http://192.168.0.10/get_imglist.cgi?DIR=/DCIM/'+m).read() | |
curList = page.split() | |
# Download each new file | |
for item in curList: | |
if item not in startList: | |
path = 'http://192.168.0.10' + item.split(',')[0] + '/' + item.split(',')[1] | |
img = item.split(',')[1] | |
print 'Retrieving ... ' + img | |
urlretrieve(path,img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment