This repository was archived by the owner on Jul 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathloomdl.py
More file actions
executable file
·54 lines (40 loc) · 1.31 KB
/
loomdl.py
File metadata and controls
executable file
·54 lines (40 loc) · 1.31 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python3
import argparse
import json
import urllib.request
from urllib.parse import urlparse
def fetch_loom_download_url(id):
request = urllib.request.Request(
url=f"https://www.loom.com/api/campaigns/sessions/{id}/transcoded-url",
headers={},
method="POST",
)
response = urllib.request.urlopen(request)
body = response.read()
content = json.loads(body.decode("utf-8"))
url = content["url"]
return url
def download_loom_video(url, filename):
urllib.request.urlretrieve(url, filename)
def parse_arguments():
parser = argparse.ArgumentParser(
prog="loomdl", description="script to download loom.com videos"
)
parser.add_argument(
"url", help="Url of the video in the format https://www.loom.com/share/[ID]"
)
parser.add_argument("-o", "--out", help="Path to output the file to")
arguments = parser.parse_args()
return arguments
def extract_id(url):
parsed_url = urlparse(url)
return parsed_url.path.split("/")[-1]
def main():
arguments = parse_arguments()
id = extract_id(arguments.url)
url = fetch_loom_download_url(id)
filename = arguments.out or f"{id}.mp4"
print(f"Downloading video {id} and saving to {filename}")
download_loom_video(url, filename)
if __name__ == "__main__":
main()