Skip to content

Instantly share code, notes, and snippets.

@Epithumia
Created June 30, 2014 23:31
Show Gist options
  • Save Epithumia/ced7a298396b24b79024 to your computer and use it in GitHub Desktop.
Save Epithumia/ced7a298396b24b79024 to your computer and use it in GitHub Desktop.
Proof of concept : wireless tethering on the E-M1, in camera control mode, now with smarter polling
# -*- coding: utf-8 -*-
from urllib import urlretrieve
from urllib2 import urlopen
import re
import time
def getInitialData():
data = []
page = urlopen('http://192.168.0.10/DCIM').read()
m = re.findall('(wlansd.*DCIM.*;)',page)
for entry in m:
folder = entry.split(',')[1]
page = urlopen('http://192.168.0.10/DCIM/'+folder).read()
sub = re.findall('wlansd.*DCIM.*;',page)
for f in sub:
data.append(f)
return data
def checkNew(data):
page = urlopen('http://192.168.0.10/DCIM').read()
m = re.findall('(wlansd.*DCIM.*;)',page)
new = []
for entry in m:
folder = entry.split(',')[1]
page = urlopen('http://192.168.0.10/DCIM/'+folder).read()
sub = re.findall('wlansd.*DCIM.*;',page)
for f in sub:
if f not in data:
new.append(f)
return new
startData = getInitialData()
shutter = urlopen('http://192.168.0.10/switch_cammode.cgi?mode=shutter').read()
while True:
time.sleep(5)
newData = checkNew(startData)
if newData <> []:
print('Getting ' + str(len(newData)) + ' new images')
for item in newData:
startData.append(item)
img = item.split(',')[1]
folder = item.split(',')[0].split('"')[1]
url = 'http://192.168.0.10' + folder + '/' + img
print 'Retrieving ' + url
urlretrieve(url,img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment