Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Last active August 5, 2016 02:33
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 bmcbride/675f83faac4352e8165b to your computer and use it in GitHub Desktop.
Save bmcbride/675f83faac4352e8165b to your computer and use it in GitHub Desktop.
Download all the videos for a specific form (with optional gpx tracks)
import sys
import urllib2
import os
from fulcrum import Fulcrum
api_key = raw_input('api_key:')
form_id = raw_input('form_id:')
if api_key == '' or api_key == 'your_api_key' or form_id == '' or form_id == 'your_form_id':
sys.exit('api_key and form_id are required!')
fulcrum = Fulcrum(key=api_key)
videos = fulcrum.videos.search(url_params={'form_id': form_id})
# search for files already downloaded
downloaded = [];
dirname = os.path.dirname(os.path.realpath(__import__('__main__').__file__))
for file in os.listdir(dirname):
if file.endswith('.mp4'):
print(file)
downloaded.append(file[0:-4])
# loop through videos
for video in videos['videos']:
# if file is not already downloaded, download it
if video['access_key'] not in downloaded:
# download mp4 file
print ('Downloading video file: '+video['access_key']+'.mp4 (~ '+str(video['file_size']/1000000)+' mb)')
videoURL = 'https://api.fulcrumapp.com/api/v2/videos/'+video['access_key']+'.mp4?token='+api_key
mp4 = urllib2.urlopen(videoURL)
videoFile = open(video['access_key']+'.mp4', 'w')
videoFile.write(mp4.read())
videoFile.close()
print ('Downloaded video file: '+video['access_key']+'.mp4')
# download gpx file if there is one
if video['track']:
print ('Downloading gpx file: '+video['access_key']+'.gpx')
trackURL = 'https://api.fulcrumapp.com/api/v2/videos/'+video['access_key']+'/track.gpx?token='+api_key
gpx = urllib2.urlopen(trackURL)
trackFile = open(video['access_key']+'.gpx', 'w')
trackFile.write(gpx.read())
trackFile.close()
print ('Downloaded gpx file: '+video['access_key']+'.gpx')
import sys
import urllib2
from fulcrum import Fulcrum
api_key = raw_input('api_key:')
form_id = raw_input('form_id:')
if api_key == '' or api_key == 'your_api_key' or form_id == '' or form_id == 'your_form_id':
sys.exit('api_key and form_id are required!')
fulcrum = Fulcrum(key=api_key)
videos = fulcrum.videos.search(url_params={'form_id': form_id})
#print(videos)
for index, item in enumerate(videos['videos']):
url = 'https://api.fulcrumapp.com/api/v2/videos/'+item['access_key']+'.mp4?token='+api_key
u = urllib2.urlopen(url)
localFile = open(item['access_key']+'.mp4', 'w')
localFile.write(u.read())
localFile.close()
print ('Downloaded '+item['access_key']+'.mp4')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment