Skip to content

Instantly share code, notes, and snippets.

@codekaust
Last active September 19, 2020 10:09
Show Gist options
  • Save codekaust/8624cbfe30e6bdb5e41c42de4c543c05 to your computer and use it in GitHub Desktop.
Save codekaust/8624cbfe30e6bdb5e41c42de4c543c05 to your computer and use it in GitHub Desktop.
# place it in folder where */*.mp4 is video
import requests, glob, json, os
admin_token = str(input("Enter your token: "))
backend = str(input("Enter backend (backend/api): "))
url = f"https://{backend}.mypathshala.net/study_material/admin_user/recording/"
print(admin_token,backend,url)
for vid_file in glob.glob('*/*.mp4'):
meta_file = vid_file[:vid_file.rindex('/')+1]+'metadata.json'
with open(meta_file) as f:
_url = json.load(f)['meeting_url']
single_class_entry = _url[_url.rindex('/')+1:]
payload = {'single_class_entry': int(single_class_entry)}
files = [
('video', open(vid_file,'rb'))
]
headers = {
'Authorization': 'Token ' + admin_token
}
response = requests.request("PATCH", url, headers=headers, data = payload, files = files)
if response.status_code == 200:
os.remove(vid_file)
print(response.text.encode('utf8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment