HenzHosting commited on
Commit
3bd4682
Β·
verified Β·
1 Parent(s): 7c0b853

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,11 +1,18 @@
1
- from pytube import YouTube
2
  import gradio as gr
3
 
4
  def download_video(video_url):
5
  try:
6
- yt = YouTube(video_url)
7
- video_title = yt.title
8
- yt.streams.get_highest_resolution().download()
 
 
 
 
 
 
 
9
  return f"βœ… Downloaded: {video_title}"
10
  except Exception as e:
11
  return f"❌ Error: {str(e)}"
 
1
+ import yt_dlp
2
  import gradio as gr
3
 
4
  def download_video(video_url):
5
  try:
6
+ # Set download options
7
+ ydl_opts = {
8
+ 'outtmpl': '%(title)s.%(ext)s', # Save file with video title as the name
9
+ 'format': 'best', # Download the best available format
10
+ }
11
+
12
+ # Download the video
13
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
14
+ info_dict = ydl.extract_info(video_url, download=True)
15
+ video_title = info_dict.get('title', 'Video')
16
  return f"βœ… Downloaded: {video_title}"
17
  except Exception as e:
18
  return f"❌ Error: {str(e)}"