Spaces:
Build error
Build error
File size: 1,024 Bytes
bc39353 2e18f1a bc39353 088f881 bc39353 088f881 2e18f1a 088f881 2e18f1a 088f881 bc39353 2e18f1a 088f881 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
import yt_dlp as youtube_dl
def download_youtube_video(youtube_url):
"""Downloads a YouTube video using yt_dlp and returns the downloaded file path."""
try:
ydl_opts = {
'format': 'best',
'outtmpl': '%(title)s.%(ext)s',
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
result = ydl.extract_info(youtube_url, download=True)
video_title = result.get('title', None)
video_ext = result.get('ext', None)
downloaded_file = f"{video_title}.{video_ext}"
return downloaded_file
except Exception as e:
print("An error occurred:", e)
return None
def app(video_link):
video_path = download_youtube_video(video_link)
return video_path
interface = gr.Interface(
fn=app,
inputs=gr.Textbox(label="Enter YouTube link 🔗 To Download Video⬇️ "),
outputs=gr.Textbox(label="Downloaded Video Path")
)
if __name__ == "__main__":
interface.launch(debug=True)
|