Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
-
import subprocess
|
| 4 |
|
| 5 |
def fetch(url, name, ext):
|
| 6 |
opts = {
|
|
@@ -8,21 +7,16 @@ def fetch(url, name, ext):
|
|
| 8 |
"mp4": "-f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"",
|
| 9 |
}[ext]
|
| 10 |
filename = f"{name}.{ext}"
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
# Run yt-dlp command using subprocess to capture errors
|
| 14 |
-
result = subprocess.run(f"yt-dlp {opts} {url} -o {filename}", shell=True, check=True)
|
| 15 |
-
return filename
|
| 16 |
-
except subprocess.CalledProcessError as e:
|
| 17 |
-
return f"Error: {str(e)}"
|
| 18 |
|
| 19 |
# Create the Gradio interface
|
| 20 |
interface = gr.Interface(
|
| 21 |
fn=fetch,
|
| 22 |
inputs=[
|
| 23 |
-
gr.Textbox(label="Link Address", placeholder="Enter the
|
| 24 |
-
gr.Textbox(label="File
|
| 25 |
-
gr.Dropdown(["mp3", "mp4"], value="mp4", label="File
|
| 26 |
],
|
| 27 |
outputs=gr.File(label="Download!"),
|
| 28 |
description="Download from X, Youtube, Reddit, etc..",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
def fetch(url, name, ext):
|
| 5 |
opts = {
|
|
|
|
| 7 |
"mp4": "-f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"",
|
| 8 |
}[ext]
|
| 9 |
filename = f"{name}.{ext}"
|
| 10 |
+
os.system(f"yt-dlp {opts} {url} -o {filename}")
|
| 11 |
+
return filename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Create the Gradio interface
|
| 14 |
interface = gr.Interface(
|
| 15 |
fn=fetch,
|
| 16 |
inputs=[
|
| 17 |
+
gr.Textbox(label="Link Address", placeholder="Enter the url here ..."),
|
| 18 |
+
gr.Textbox(label="File name", placeholder="Example: file_name"),
|
| 19 |
+
gr.Dropdown(["mp3", "mp4"], value="mp4", label="File type")
|
| 20 |
],
|
| 21 |
outputs=gr.File(label="Download!"),
|
| 22 |
description="Download from X, Youtube, Reddit, etc..",
|