Skip to content

Instantly share code, notes, and snippets.

@kscottz
Created February 4, 2016 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kscottz/2c8980677d643b2ee628 to your computer and use it in GitHub Desktop.
Save kscottz/2c8980677d643b2ee628 to your computer and use it in GitHub Desktop.
Trigger a gopro camera over wifi and automagically find and download the images or videos.
from goprohero import GoProHero
import urllib
import bs4
import time
def download_and_save(name,route="http://10.5.5.9:8080/videos/DCIM/100GOPRO/"):
grab = route+name
result = urllib.urlopen(grab)
if( result.code == 200 ):
with open(name,'wb') as fp:
fp.write(result.read())
result.close()
def get_new(last=[],url="http://10.5.5.9:8080/videos/DCIM/100GOPRO/"):
unique = None
last = set(last)
out = urllib.urlopen(url)
if(out.code == 200):
soup = bs4.BeautifulSoup(out.read())
fresh = set([row.renderContents() for row in soup.findAll('a')])
unique = list(fresh.difference(last))
return unique
out = get_new()
cam = GoProHero(password="herpderp")
#print cam.status()
cam.command('mode','burst')
cam.command('record','on')
time.sleep(3)
out = get_new(last=out)
for o in out:
print o
download_and_save(o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment