Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,28 @@
|
|
| 1 |
-
import yt_dlp
|
| 2 |
-
import gradio as gr
|
| 3 |
-
import os
|
| 4 |
-
import time
|
| 5 |
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
ydl_opts = {
|
| 13 |
-
'format': '
|
| 14 |
-
'
|
| 15 |
-
'key': 'FFmpegExtractAudio',
|
| 16 |
-
'preferredcodec': audio_format,
|
| 17 |
-
}],
|
| 18 |
-
'outtmpl': path_file,
|
| 19 |
-
'progress_hooks': [lambda d: progress(d['downloaded_bytes'] / d['total_bytes']) if d['status'] == 'downloading' else None]
|
| 20 |
}
|
| 21 |
-
|
| 22 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 23 |
-
ydl.download
|
| 24 |
-
|
| 25 |
-
return
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
gr.Textbox(label="
|
| 30 |
-
gr.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
inputs=inputs,
|
| 41 |
-
outputs=output,
|
| 42 |
-
title=title,
|
| 43 |
-
description=description,
|
| 44 |
-
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import yt_dlp
|
| 5 |
+
|
| 6 |
+
def download_video(url):
|
|
|
|
| 7 |
ydl_opts = {
|
| 8 |
+
'format': 'best',
|
| 9 |
+
'outtmpl': 'downloaded_videos/%(title)s.%(ext)s',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
}
|
|
|
|
| 11 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 12 |
+
info_dict = ydl.extract_info(url, download=True)
|
| 13 |
+
video_title = info_dict.get('title', None)
|
| 14 |
+
return f"Video '{video_title}' downloaded successfully!"
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=download_video,
|
| 18 |
+
inputs=gr.Textbox(label="YouTube URL"),
|
| 19 |
+
outputs=gr.Textbox(label="Download Status"),
|
| 20 |
+
title = "yt_dlp",
|
| 21 |
+
description = "This space was made by [Blane187](https://huggingface.co/Blane187). Please credit me if you use this thing :D"
|
| 22 |
+
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
iface.launch()
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|