Skip to content

Commit 96f641b

Browse files
committed
Linkedin video download
1 parent e4483b5 commit 96f641b

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# vscode
2+
.vscode
3+
4+
# file generated
5+
video.mp4
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Linkedin Video Downloader
2+
This script uses Python requests library to grab the url of the linkedin post provided to get the video url. After getting the url of the video, the file gets saved as video file. A progress bar is displayed showing the current speed, time escaped & time left. The progress bar is implemented using tqdm.
3+
4+
5+
# How to use?
6+
- Install the dependicies required for this scrit (tqdm & requests):
7+
8+
```pip install requirements.txt```
9+
10+
- Use this format to download the video:
11+
12+
```python app.py <link of post>```
13+
14+
15+
# Working Demo
16+
17+
![](preview.gif)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from tqdm import tqdm
2+
import requests
3+
import html
4+
import sys
5+
6+
def download(url):
7+
source = requests.get(url).text
8+
source_cleaned = html.unescape(source).split()
9+
for item in source_cleaned:
10+
if "dms.licdn.com" in item:
11+
download_link = item.split(',')[0].split('"src":')[1][1:-1]
12+
r = requests.get(download_link, stream = True)
13+
total_size_in_bytes= int(r.headers.get('content-length', 0))
14+
block_size = 1024 #1 Kibibyte
15+
progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
16+
with open('test.mp4', 'wb') as file:
17+
for data in r.iter_content(block_size):
18+
progress_bar.update(len(data))
19+
file.write(data)
20+
progress_bar.close()
21+
if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
22+
print("ERROR, something went wrong")
23+
24+
if __name__ == "__main__":
25+
download(sys.argv[1])
168 KB
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tqdm==4.48.2
2+
requests==2.24.0

0 commit comments

Comments
 (0)