Skip to content

Instantly share code, notes, and snippets.

View kylenstone's full-sized avatar

Kyle kylenstone

  • Save Your Generation
  • Boulder, Colorado
View GitHub Profile
@kylenstone
kylenstone / gist:04a0ec34ff42ca5fde75e986c83ef3b5
Created November 24, 2020 19:02
Enriching Frame.io comments data with Zapier and Excel Online
import requests
import json
"""
This code demonstrates how to catch Frame.io comments in Zapier
to route them to another app such as Google Docs or Excel.
The following refactors could improve this code:
1. input_data (populated by Zapier) should be presumed to be a comment_id,
not an asset_id. This would simplify the code and reduce API calls.
@kylenstone
kylenstone / frameIOFolderTemplaterZapier.js
Last active October 28, 2020 21:18
Frame.io Folder Templater for Zapier Code Steps (Node 10.x+)
/**
/ This sample code demonstrates applying a Folder template to a Frame.io Project.
/ A Zapier Code Step must be configured to catch webhook events emitted by Frame.io.
/ Learn about Frame.io webhooks: https://docs.frame.io/docs/webhooks
/ Learn about using JavaScript in Zapier: https://zapier.com/help/create/code-webhooks/use-javascript-code-in-zaps
*/
// Destructure Zapier-defined variables
const { teamId, userId, resourceId, AUTH_TOKEN_KEY } = inputData;
@kylenstone
kylenstone / oas3-latest.json
Created October 21, 2020 01:59
oas3-latest
{
"components": {
"requestBodies": {
"ActionRequest": {
"content": {
"application/json": {
"schema": {
"properties": {
"allow_collaborators": {
"default": false,
@kylenstone
kylenstone / example_get_asset_id_response.json
Created October 8, 2020 20:58
Example Get Asset response
{
"shared": true,
"transcoded_at": "2020-09-25T15:44:02.325115Z",
"public_item_count": 0,
"webm_540": null,
"project_id": "c3400a30-d17a-479d-9f4e-467f1882f43e",
"filetype": "video/mp4",
"view_count": 1,
"hls_manifest": "https://stream.frame.io/manifest/hls/master?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOnsidmlkZW8iOlsiczM6Ly9mcmFtZWlvLWFzc2V0cy1wcm9kdWN0aW9uL2VuY29kZS8zNmVjYWFkYy02NGRjLTQ3OTgtODhiYy1mMjYxYWY3ODA0NmQvaDI2NF8zNjAubXA0IiwiczM6Ly9mcmFtZWlvLWFzc2V0cy1wcm9kdWN0aW9uL2VuY29kZS8zNmVjYWFkYy02NGRjLTQ3OTgtODhiYy1mMjYxYWY3ODA0NmQvaDI2NF81NDAubXA0IiwiczM6Ly9mcmFtZWlvLWFzc2V0cy1wcm9kdWN0aW9uL2VuY29kZS8zNmVjYWFkYy02NGRjLTQ3OTgtODhiYy1mMjYxYWY3ODA0NmQvaDI2NF8xMDgwX2Jlc3QubXA0Il0sInVzZXJfY29uZmlnIjp7InRlYW1faWQiOiJhYTg5MTY4Ny00YjFlLTQxNTAtOWI2ZC05ZTQ5MTFjNWI0MzYiLCJzZXNzaW9uX2lkIjoiRmp3ZjRyeXFMLV9qMEFjQXdYd0ciLCJyZXZpZXdfbGlua19pZCI6bnVsbCwicHJvamVjdF9pZCI6ImMzNDAwYTMwLWQxN2EtNDc5ZC05ZjRlLTQ2N2YxODgyZjQzZSIsInByZXNlbnRhdGlvbl9pZCI6bnVsbCwicGxheWVyX3R5cGUiOiJpbnRlcm5h
@kylenstone
kylenstone / projectPreferences.json
Created September 22, 2020 17:58
Example Project Preferences to pass into Project templater
{
"private" : false,
"project_preferences": {
"notify_on_updated_label": false,
"notify_on_new_mention": false,
"notify_on_new_comment": false,
"notify_on_new_collaborator": false,
"notify_on_new_asset": false,
"collaborator_can_share": false,
"collaborator_can_invite": false,
@kylenstone
kylenstone / onlineTemplate-folderTemplateExample.json
Created September 22, 2020 17:57
Example JSON object containing a combined project and folder template
[
{
"name": "Grade",
"type": "project",
"folders": [
{
"name": "Online",
"type": "folder"
},
{
@kylenstone
kylenstone / folder-templater-nodejs-example.js
Created September 22, 2020 17:56
Sample code to automatically create Frame.io Projects and Folders
// Note: this sample code is in the process of being re-written
// and assumes a client SDK is available to wrap API requests
// such as createFolder(). The intent is simply to provide
// convenience methods, but you can also write your own API requests
// as shown in this example: https://github.com/Frameio/custom-actions-example-app/blob/ks/DEVREL-589/examples/custom-action-offload-to-s3/modules/api.js
const apiClient = require('./api/client.js')
const template = require('./templates/onlineTemplate.json')
function createProject(name, teamId) {
@kylenstone
kylenstone / secondLambda.js
Created September 19, 2020 17:10
Frame.io Custom Action Backup to S3 Code: Lambda #2
const { s3Uploader } = require('./modules/api');
exports.handler = async (event) => {
let { caller, firstLambdaTraceID, url, name } = event;
// Logs for convenient searching in X-Ray and CloudWatch
console.log(`Second Lambda trace ID: ${process.env._X_AMZN_TRACE_ID}`);
console.log(`Called by ${caller} with trace ID: ${firstLambdaTraceID}. Begin uploading ${name}...`);
try {
@kylenstone
kylenstone / firstLambda.js
Created September 19, 2020 01:12
Frame.io Custom Action Backup to S3 Code: Lambda #1
const { fetchAsset, invokeLambda } = require('./modules/api');
exports.handler = async function (event, context) {
// Save the X-ray Trace ID and and this Lambda's function name.
// We'll pass them to our second 'file handler' Lambda.
const firstLambdaTraceID = process.env._X_AMZN_TRACE_ID;
const caller = context.functionName;
let id = JSON.parse(event.body).resource.id;
let { url, name} = await fetchAsset(id);
@kylenstone
kylenstone / api.js
Created September 19, 2020 01:07
Frame.io Custom Action Backup to S3: API.js Helper Library
const AWS = require('aws-sdk');
const fetch = require('node-fetch');
async function fetchAsset (id) {
const token = process.env.FRAMEIO_TOKEN;
let url = `http://api.frame.io/v2/assets/${id}`;
let requestOptions = {
method: 'GET',
headers: {
'Content-Type': 'application/json',