JUNGU commited on
Commit
728322d
·
verified ·
1 Parent(s): 7924003

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -19,7 +19,7 @@ def download_youtube_video(youtube_url):
19
  video_title = result.get('title', None)
20
  video_ext = 'mp4' # We're forcing mp4 format
21
  downloaded_file = f"{video_title}.{video_ext}"
22
- return downloaded_file
23
 
24
  except Exception as e:
25
  print("An error occurred:", e)
@@ -28,21 +28,21 @@ def download_youtube_video(youtube_url):
28
  def app(video_link):
29
  video_path = download_youtube_video(video_link)
30
  if video_path:
31
- return gr.File.update(value=video_path, visible=True), gr.Markdown.update(visible=False)
32
  else:
33
- return gr.File.update(value=None, visible=False), gr.Markdown.update(visible=True, value="Download failed. Please check the URL and try again.")
34
 
35
  with gr.Blocks() as interface:
36
  gr.Markdown("## YouTube Video Downloader")
37
  video_link = gr.Textbox(label="Enter YouTube link 🔗 To Download Video⬇️")
38
  download_button = gr.Button("Download")
39
- output = gr.File(label="Downloaded Video", visible=False)
40
- error_message = gr.Markdown(visible=False)
41
 
42
  download_button.click(
43
  fn=app,
44
  inputs=video_link,
45
- outputs=[output, error_message],
46
  api_name="download"
47
  )
48
 
 
19
  video_title = result.get('title', None)
20
  video_ext = 'mp4' # We're forcing mp4 format
21
  downloaded_file = f"{video_title}.{video_ext}"
22
+ return os.path.abspath(downloaded_file)
23
 
24
  except Exception as e:
25
  print("An error occurred:", e)
 
28
  def app(video_link):
29
  video_path = download_youtube_video(video_link)
30
  if video_path:
31
+ return video_path, "Download successful! Click the file name to download."
32
  else:
33
+ return None, "Download failed. Please check the URL and try again."
34
 
35
  with gr.Blocks() as interface:
36
  gr.Markdown("## YouTube Video Downloader")
37
  video_link = gr.Textbox(label="Enter YouTube link 🔗 To Download Video⬇️")
38
  download_button = gr.Button("Download")
39
+ output = gr.File(label="Downloaded Video")
40
+ message = gr.Markdown()
41
 
42
  download_button.click(
43
  fn=app,
44
  inputs=video_link,
45
+ outputs=[output, message],
46
  api_name="download"
47
  )
48