Next commited on
Commit
1b0583a
β€’
1 Parent(s): caa8675

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -3,8 +3,8 @@ import os
3
 
4
  def download_url(url, name, ext):
5
  opts = {
6
- "mp3": "-f \"ba\" -x --audio-format mp3",
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}")
@@ -14,23 +14,25 @@ with gr.Blocks(theme="Nex432/green") as demo:
14
  with gr.Tab("main settings"):
15
  url = gr.Textbox(label="Media URL")
16
  name_file = gr.Textbox(label="Media Name")
17
- format = gr.Dropdown(label="Format File `mp3` and `mp4`", choices=["mp3", "mp4"])
18
  download = gr.Button("Download")
19
  audio_output = gr.Audio(visible=False)
20
  video_output = gr.Video(visible=False)
 
21
  def download_media(url, name_file, format):
22
- filename = download_url(url, name_file, format):
23
  if format == "mp3":
24
  return filename, None # Return filename for audio, None for video
25
  else:
26
  return None, filename # Return None for audio, filename for video
27
-
28
  download.click(download_media, inputs=[url, name_file, format], outputs=[audio_output, video_output])
 
29
  with gr.Tab("credits"):
30
  gr.Markdown(
31
- f"""
32
- code by [Nex432](https://huggingface.co/Nex432)<br> with [chatGPT's](https://chatgpt.com) help
33
-
34
  """
35
  )
 
36
  demo.launch()
 
3
 
4
  def download_url(url, name, ext):
5
  opts = {
6
+ "mp3": '-f "ba" -x --audio-format mp3',
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}")
 
14
  with gr.Tab("main settings"):
15
  url = gr.Textbox(label="Media URL")
16
  name_file = gr.Textbox(label="Media Name")
17
+ format = gr.Dropdown(label="Format File", choices=["mp3", "mp4"])
18
  download = gr.Button("Download")
19
  audio_output = gr.Audio(visible=False)
20
  video_output = gr.Video(visible=False)
21
+
22
  def download_media(url, name_file, format):
23
+ filename = download_url(url, name_file, format)
24
  if format == "mp3":
25
  return filename, None # Return filename for audio, None for video
26
  else:
27
  return None, filename # Return None for audio, filename for video
28
+
29
  download.click(download_media, inputs=[url, name_file, format], outputs=[audio_output, video_output])
30
+
31
  with gr.Tab("credits"):
32
  gr.Markdown(
33
+ """
34
+ Code by [Nex432](https://huggingface.co/Nex432)<br> with [ChatGPT's](https://chatgpt.com) help
 
35
  """
36
  )
37
+
38
  demo.launch()