Created
February 28, 2018 02:02
-
-
Save richo/ae525a02cda1252de3d43f01f4999de4 to your computer and use it in GitHub Desktop.
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
#!/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