rapacious commited on
Commit
b41072e
·
verified ·
1 Parent(s): 669658f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import yt_dlp
3
  import os
4
 
5
- def download_video(url, quality, format_choice, download_playlist):
6
  try:
7
  # Tùy chọn cấu hình cho yt-dlp
8
  ydl_opts = {
@@ -10,6 +10,10 @@ def download_video(url, quality, format_choice, download_playlist):
10
  'noplaylist': not download_playlist, # Tải playlist nếu được chọn
11
  }
12
 
 
 
 
 
13
  # Điều chỉnh chất lượng video
14
  if quality == "Best":
15
  ydl_opts['format'] = 'bestvideo+bestaudio/best'
@@ -54,7 +58,7 @@ interface = gr.Interface(
54
  choices=["Best", "Medium", "Low"],
55
  label="Chất lượng video",
56
  value="Best",
57
- info="Best: Cao nhất có thể, Medium: 720p, Low: 480p"
58
  ),
59
  gr.Dropdown(
60
  choices=["MP4", "MKV", "Audio Only (MP3)"],
@@ -65,12 +69,17 @@ interface = gr.Interface(
65
  gr.Checkbox(
66
  label="Tải toàn bộ playlist (nếu có)",
67
  value=False,
68
- info="Check để tải toàn bộ playlist thay vì chỉ một video"
 
 
 
 
 
69
  )
70
  ],
71
  outputs=gr.Textbox(label="Kết quả"),
72
  title="Trình tải video nâng cao",
73
- description="Dán URL video từ bất kỳ trang nào hỗ trợ (YouTube, Facebook, v.v.) tùy chỉnh cách tải."
74
  )
75
 
76
  # Khởi chạy ứng dụng
 
2
  import yt_dlp
3
  import os
4
 
5
+ def download_video(url, quality, format_choice, download_playlist, cookies_file):
6
  try:
7
  # Tùy chọn cấu hình cho yt-dlp
8
  ydl_opts = {
 
10
  'noplaylist': not download_playlist, # Tải playlist nếu được chọn
11
  }
12
 
13
+ # Sử dụng file cookie nếu được cung cấp
14
+ if cookies_file and os.path.exists(cookies_file):
15
+ ydl_opts['cookiefile'] = cookies_file
16
+
17
  # Điều chỉnh chất lượng video
18
  if quality == "Best":
19
  ydl_opts['format'] = 'bestvideo+bestaudio/best'
 
58
  choices=["Best", "Medium", "Low"],
59
  label="Chất lượng video",
60
  value="Best",
61
+ info="Best: Cao nhất, Medium: 720p, Low: 480p"
62
  ),
63
  gr.Dropdown(
64
  choices=["MP4", "MKV", "Audio Only (MP3)"],
 
69
  gr.Checkbox(
70
  label="Tải toàn bộ playlist (nếu có)",
71
  value=False,
72
+ info="Check để tải toàn bộ playlist"
73
+ ),
74
+ gr.Textbox(
75
+ label="Đường dẫn file cookie (nếu cần)",
76
+ placeholder="Ví dụ: cookies.txt",
77
+ info="Dùng file cookie để tải video yêu cầu đăng nhập (YouTube, v.v.)"
78
  )
79
  ],
80
  outputs=gr.Textbox(label="Kết quả"),
81
  title="Trình tải video nâng cao",
82
+ description="Dán URL video tùy chỉnh. Nếu video yêu cầu đăng nhập, cung cấp file cookie."
83
  )
84
 
85
  # Khởi chạy ứng dụng