Created
June 28, 2024 07:14
-
-
Save AlessandroVaccarino/fe868774394cc0342351ed98c715d122 to your computer and use it in GitHub Desktop.
Simple Python scripts that, starting from a Loom video link, downloads it locally
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/python3 | |
import requests | |
url="https://www.loom.com/share/..." | |
def extract_id_from_url(url): | |
urlRet = url.split("/")[-1] | |
if '?' in urlRet: | |
urlRet = urlRet.split("?")[0] | |
return urlRet | |
def fetch_loom_download_url(id): | |
response = requests.post(url=f"https://www.loom.com/api/campaigns/sessions/{id}/transcoded-url") | |
if response.status_code == 200: | |
return response.json()["url"] | |
else: | |
print("Error while retrieving response: ", response.status_code) | |
exit | |
def download_loom_video(url, filename): | |
response = requests.get(url) | |
open(filename,"wb").write(response.content) | |
id = extract_id_from_url(url) | |
outputFilename = f"LoomVideo_{id}.mp4" | |
url = fetch_loom_download_url(id) | |
download_loom_video(url, outputFilename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment