Created
February 4, 2016 07:28
-
-
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.
This file contains hidden or 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
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