Skip to content

Instantly share code, notes, and snippets.

@richo
Created February 28, 2018 02:02
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 richo/ae525a02cda1252de3d43f01f4999de4 to your computer and use it in GitHub Desktop.
Save richo/ae525a02cda1252de3d43f01f4999de4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
from tusclient import client
import json
import requests
from flysight_manager import vimeo_credentials
API_BASE = "https://api.vimeo.com"
class VimeoUploader(object):
def _post(self, url, payload):
resp = requests.post(API_BASE + url,
headers = {
"Authorization": ("bearer %s" % vimeo_credentials.access_token),
"Content-Type": "application/json"
},
data = json.dumps(payload),
)
return resp
def upload_file(self, filename, name, description):
size = os.stat(filename).st_size
resp = self._post("/me/videos", {"upload": {"approach": "tus", "size": size}})
print repr(resp.text)
print repr(resp.json())
uploader = VimeoUploader()
uploader.upload_file('/Users/richo/Downloads/frontaled.mp4', 'Frontaled', 'richo gets frontaled by sawyer')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment