Artificial-superintelligence commited on
Commit
c764b90
·
verified ·
1 Parent(s): e7c6748

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,9 +1,7 @@
1
  import gradio as gr
2
  import yt_dlp
3
  import os
4
- import re
5
  import time
6
- from moviepy.video.io.VideoFileClip import VideoFileClip
7
 
8
  # Function to download video
9
  def download_video(url):
@@ -18,8 +16,14 @@ def download_video(url):
18
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
19
  info_dict = ydl.extract_info(url, download=False)
20
  title = info_dict.get('title', None)
 
21
  ydl.download([url])
22
- return f"Downloaded successfully: {title}", f"/downloads/{title}.mp4"
 
 
 
 
 
23
  except Exception as e:
24
  return f"Error: {e}", None
25
 
 
1
  import gradio as gr
2
  import yt_dlp
3
  import os
 
4
  import time
 
5
 
6
  # Function to download video
7
  def download_video(url):
 
16
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
17
  info_dict = ydl.extract_info(url, download=False)
18
  title = info_dict.get('title', None)
19
+ video_file = f"{download_path}/{title}.mp4"
20
  ydl.download([url])
21
+
22
+ # Wait a moment to ensure the file is fully written
23
+ time.sleep(1) # Add a delay for the file to be available
24
+
25
+ # Return the download link
26
+ return f"Downloaded successfully: {title}", video_file
27
  except Exception as e:
28
  return f"Error: {e}", None
29