-
Notifications
You must be signed in to change notification settings - Fork 503
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (23 loc) · 988 Bytes
/
app.py
File metadata and controls
27 lines (23 loc) · 988 Bytes
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
from tqdm import tqdm
import requests
import html
import sys
def download(url):
source = requests.get(url).text
source_cleaned = html.unescape(source).split()
for item in source_cleaned:
if "dms.licdn.com" in item:
download_link = item.split(",")[0].split('"src":')[1][1:-1]
r = requests.get(download_link, stream=True)
total_size_in_bytes = int(r.headers.get("content-length", 0))
block_size = 1024 # 1 Kibibyte
progress_bar = tqdm(total=total_size_in_bytes, unit="iB", unit_scale=True)
with open("test.mp4", "wb") as file:
for data in r.iter_content(block_size):
progress_bar.update(len(data))
file.write(data)
progress_bar.close()
if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
print("ERROR, something went wrong")
if __name__ == "__main__":
download(sys.argv[1])