-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamable.py
34 lines (25 loc) · 906 Bytes
/
streamable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
from data_manager import DataStore
import utils
def upload(file_path):
"""Upload a file to Streamable.com
Args:
file_path (string): Path to the video to be uploaded.
Returns:
A string that represents the url to the uploaded video
"""
with open(file_path, 'rb') as file:
filename = utils.get_filename(file_path)
content = {'file': (filename, file)}
auth = DataStore.get_streamable_secrets()
headers = {
'user-agent': 'lol-highlights-enhancer/1.0.0 ([email protected])',
'Authorization': f'Basic {auth}'}
api_url = 'https://api.streamable.com/upload'
response = requests.post(
api_url,
files=content,
headers=headers)
shortcode = response.json()['shortcode']
video_url = f'https://streamable.com/{shortcode}'
return video_url