Last active
August 24, 2020 21:56
-
-
Save patdevinwilson/2b8705e86abfeb4b0b6d77dd85caf414 to your computer and use it in GitHub Desktop.
Looks up a list of inline photo IDs from a CSV file and downloads photos from Fulcrum API
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
import csv | |
from fulcrum import Fulcrum | |
from fulcrum.exceptions import NotFoundException | |
api_key = '[API KEY]' | |
fulcrum = Fulcrum(key=api_key) | |
photos_list = csv.reader(open('photos.csv'), delimiter=',') | |
for row in photos_list: | |
# fetch existing record (first column must contain fulcrum_id) | |
try: | |
photo = fulcrum.photos.media(row[0]) | |
except NotFoundException: | |
print('^/ ' + row[0]) | |
continue | |
with open(row[0]+'.jpg'.format(id), 'wb') as f: | |
f.write(photo) | |
print('Downloaded' row[0]+'.jpg'.format(id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment