Last active
April 3, 2019 08:06
-
-
Save jackcrombie/30db6ebdc5b6992d392123982cdae53d to your computer and use it in GitHub Desktop.
Run this in a code step in Zapier to upload files from their public URL to a wistia Project. This allows us to bypass some of the file size and timeout issues faced when trying to upload large videos (+1GB) to Wistia via dropbox or google drive integrations. I've used Amazon s3 to store the files and serve them to Wistia.
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 requests #imports pythons requests library | |
import json #imports pythons json library | |
#grab data from previous steps in Zapier | |
s3URL = input_data['s3URL'] | |
project_id = input_data['projectID'] | |
#print these to logs for troubleshooting while building zaps | |
print s3URL #prints out s3 url from Airtable | |
print project_id #prints project ID from Airtable | |
#upload API call | |
r = requests.post('https://upload.wistia.com', | |
{'url': s3URL, | |
'api_password':'your_api_key_here', | |
'project_id':project_id}) | |
dataDict = json.loads(r.text) #Read the json from the text returned by the API call and store it as dataDict | |
print dataDict['hashed_id'] #check the hashed_id is there | |
hashed_id = dataDict['hashed_id'] #store hashed_id so we can pass it back to our zaps | |
thumb_url = dataDict['thumbnail']['url'] #store the thumbnail url so we can post that to slack | |
print thumb_url #print the thumb_url so we can troubleshoot in zapier | |
#return the hashedID and Thumbnail to our zaps | |
return [ | |
{'hashedID':hashed_id}, | |
{'thumbnail':thumb_url} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment