zohadev commited on
Commit
d18b634
·
verified ·
1 Parent(s): ec7aabd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -6,8 +6,13 @@ import gradio as gr
6
  def download_video(url, quality, crop_start, crop_end):
7
  yt = YouTube(url)
8
  stream = yt.streams.filter(only_audio=False).first()
 
9
  stream.download(output_path="downloads")
10
 
 
 
 
 
11
  video_path = os.path.join("downloads", yt.title + ".mp4")
12
  clip = mp.VideoFileClip(video_path)
13
 
 
6
  def download_video(url, quality, crop_start, crop_end):
7
  yt = YouTube(url)
8
  stream = yt.streams.filter(only_audio=False).first()
9
+ stream.on_progress = lambda stream, chunk, bytes_remaining: None
10
  stream.download(output_path="downloads")
11
 
12
+ # Wait until the download is complete
13
+ while not os.path.exists(os.path.join("downloads", yt.title + ".mp4")):
14
+ pass
15
+
16
  video_path = os.path.join("downloads", yt.title + ".mp4")
17
  clip = mp.VideoFileClip(video_path)
18