Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d66a196

Browse files
Merge pull request avinashkranjan#1140 from Sukriti-sood/linkedin_video_downloader
addeded linkedin_video downloader
2 parents 458fa96 + 7563e0e commit d66a196

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed

‎Linkedin_Video_Downloader/Readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Linkedin Video Downloader
2+
3+
A GUI downloader used to download Lnkedin video by providing URL of the Post.
4+
5+
## Installation
6+
7+
> pip3 install -r requirements.txt
8+
## Usage
9+
10+
Provide the URL of the Post in the field and click `Download`.
11+
12+
## Output
13+
14+
Downloaded video you desired in the same directory of the script.
15+
16+
## Authors
17+
18+
Written by [Sukriti-sood](https://www.github.com/Sukriti-sood).
19+
20+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests==2.25.1

‎Linkedin_Video_Downloader/script.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# ALL Imports
2+
3+
import tkinter as tk
4+
import requests as req
5+
import html
6+
import time
7+
from tkinter.ttk import *
8+
from threading import Thread
9+
import queue
10+
from queue import Empty
11+
12+
13+
def Invalid_Url():
14+
""" Sets Status bar label to error message """
15+
Status["text"] = "Invalid URL..."
16+
Status["fg"] = "red"
17+
18+
19+
def Download_vid():
20+
21+
# Validates Link and download Video
22+
global Url_Val
23+
url=Url_Val.get()
24+
25+
Status["text"]="Downloading"
26+
Status["fg"]="green"
27+
28+
29+
# Validating Input
30+
31+
if not "linkedin.com/posts" in url:
32+
Invalid_Url()
33+
return
34+
35+
response =req.get(url)
36+
37+
if not response.status_code == 200:
38+
Invalid_Url()
39+
return
40+
41+
htmlsource = response.text
42+
43+
sources = html.unescape(htmlsource).split()
44+
45+
for source in sources:
46+
47+
if "dms.licdn.com" in source:
48+
49+
videourl = source.split(',')[0].split('"src":')[1][1:-1]
50+
start_downloading()
51+
52+
download_thread=VideoDownload(videourl)
53+
download_thread.start()
54+
monitor(download_thread)
55+
break
56+
57+
58+
class VideoDownload(Thread):
59+
60+
def __init__(self, url):
61+
super().__init__()
62+
63+
self.url = url
64+
65+
def run(self):
66+
""" download video"""
67+
68+
# save the picture to a file
69+
block_size = 1024 # 1kB
70+
r = req.get(self.url, stream=True)
71+
total_size = int(r.headers.get("content-length"))
72+
73+
with open('video.mp4', 'wb') as file:
74+
totaldata=0;
75+
for data in r.iter_content(block_size):
76+
totaldata+=len(data)
77+
per_downloaded=totaldata*100/total_size
78+
queue.put(per_downloaded)
79+
bar['value'] = per_downloaded
80+
file.write(data)
81+
time.sleep(0.01)
82+
file.close()
83+
print("Download Finished")
84+
85+
print("Download Complete !!!")
86+
Status["text"] = "Finished!!"
87+
Status["fg"] = "green"
88+
89+
90+
#start download
91+
def start_downloading():
92+
bar["value"]=0;
93+
94+
def monitor( download_thread):
95+
""" Monitor the download thread """
96+
if download_thread.is_alive():
97+
98+
try:
99+
bar["value"]=queue.get(0)
100+
ld_window.after(10, lambda: monitor(download_thread))
101+
except Empty:
102+
pass
103+
104+
# GUI
105+
106+
ld_window=tk.Tk()
107+
ld_window.title("Linkedin Video Downloader")
108+
ld_window.geometry("400x300")
109+
110+
# Label for URL Input
111+
input_label= tk.Label(ld_window,text="Enter Linkedin Video URL:")
112+
input_label.pack()
113+
114+
queue=queue.Queue()
115+
116+
# Input of URL
117+
Url_Val = tk.StringVar()
118+
Url_Input = tk.Entry(ld_window, textvariable=Url_Val, font=("Calibri", 9))
119+
Url_Input.place( x=25,y=50, width=350)
120+
121+
# Button for Download
122+
Download_button = tk.Button(ld_window, text="Download", font=("Calibri", 9), command=Download_vid)
123+
Download_button.place(x=100, y=100, width=200)
124+
125+
# Progress Bar
126+
bar = Progressbar(ld_window, length=350, style='grey.Horizontal.TProgressbar',mode='determinate')
127+
bar.place(y=200,width=350,x=25)
128+
129+
130+
# Text for Status of Downloading
131+
Status = tk.Label(ld_window, text="Hello!! :D", fg="blue", font=("Calibri", 9), bd=1, relief=tk.SUNKEN, anchor=tk.W, padx=3)
132+
Status.pack(side=tk.BOTTOM, fill=tk.X)
133+
134+
ld_window.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /