Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,377 +1,133 @@
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
command
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
command
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
command
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
command
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
command
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
command
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
command
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
command
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
command
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
command
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
command
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
command
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
command
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
command
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
command
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Vimeo/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
78 |
-
return run_command(command)
|
79 |
-
|
80 |
-
def download_from_facebook(url):
|
81 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Facebook/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
82 |
-
return run_command(command)
|
83 |
-
|
84 |
-
def download_from_instagram(url):
|
85 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Instagram/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
86 |
-
return run_command(command)
|
87 |
-
|
88 |
-
def download_from_twitter(url):
|
89 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Twitter/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
90 |
-
return run_command(command)
|
91 |
-
|
92 |
-
def download_from_tiktok(url):
|
93 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/TikTok/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
94 |
-
return run_command(command)
|
95 |
-
|
96 |
-
def download_from_reddit(url):
|
97 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Reddit/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
98 |
-
return run_command(command)
|
99 |
-
|
100 |
-
def download_from_dailymotion(url):
|
101 |
-
command = f'yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o "P:/Local Music/Dailymotion/%(uploader)s - %(title)s.%(ext)s" "{url}"'
|
102 |
-
return run_command(command)
|
103 |
-
|
104 |
-
def download_youtube_transcript_as_text(url):
|
105 |
-
command = f'yt-dlp --write-auto-subs --sub-lang en --skip-download -o "P:/Local Music/%(title)s.%(ext)s" "{url}"'
|
106 |
-
return run_command(command)
|
107 |
-
|
108 |
-
def download_youtube_transcript_as_markdown(url):
|
109 |
-
command = f'yt-dlp --write-auto-subs --sub-lang en --skip-download --convert-subs srt -o "P:/Local Music/%(title)s.md" "{url}"'
|
110 |
-
return run_command(command)
|
111 |
-
|
112 |
-
def download_video_info_and_save_as_json(url):
|
113 |
-
command = f'yt-dlp --write-info-json --skip-download -o "P:/Local Music/%(title)s.json" "{url}"'
|
114 |
-
return run_command(command)
|
115 |
-
|
116 |
-
def list_available_formats_without_downloading(url):
|
117 |
-
command = f'yt-dlp -F "{url}"'
|
118 |
-
return run_command(command)
|
119 |
-
|
120 |
-
def download_from_youtube_age_restricted_content(url, email, password):
|
121 |
-
command = f'yt-dlp --username "{email}" --password "{password}" -f bestvideo+bestaudio -o "P:/Local Music/%(title)s.%(ext)s" "{url}"'
|
122 |
-
return run_command(command)
|
123 |
-
|
124 |
-
def run_command(command):
|
125 |
-
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
126 |
-
return result.stdout + result.stderr
|
127 |
-
|
128 |
with gr.Blocks() as demo:
|
129 |
-
gr.Markdown("
|
130 |
-
|
131 |
-
with gr.
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
specific_format_btn = gr.Button("Download Specific Formats")
|
184 |
-
specific_format_btn.click(download_specific_formats, inputs=[url_input_specific_format, format_input], outputs=gr.Textbox())
|
185 |
-
|
186 |
-
with gr.Row():
|
187 |
-
url_input_skip = gr.Textbox(label="URL")
|
188 |
-
skip_btn = gr.Button("Skip Already Downloaded Files")
|
189 |
-
skip_btn.click(skip_already_downloaded_files, inputs=url_input_skip, outputs=gr.Textbox())
|
190 |
-
|
191 |
-
with gr.Row():
|
192 |
-
urls_input = gr.Textbox(label="URLs (space-separated)")
|
193 |
-
multiple_files_btn = gr.Button("Download Multiple Individual Files")
|
194 |
-
multiple_files_btn.click(download_multiple_individual_files, inputs=urls_input, outputs=gr.Textbox())
|
195 |
-
|
196 |
-
with gr.Row():
|
197 |
-
url_input_chapters = gr.Textbox(label="URL")
|
198 |
-
chapters_btn = gr.Button("Download and Automatically Split by Chapters")
|
199 |
-
chapters_btn.click(download_and_automatically_split_by_chapters, inputs=url_input_chapters, outputs=gr.Textbox())
|
200 |
-
|
201 |
-
with gr.Row():
|
202 |
-
url_input_portion = gr.Textbox(label="URL")
|
203 |
-
start_time_input = gr.Textbox(label="Start Time (e.g., 00:01:00)")
|
204 |
-
end_time_input = gr.Textbox(label="End Time (e.g., 00:05:00)")
|
205 |
-
portion_btn = gr.Button("Extract Only a Portion of a Video")
|
206 |
-
portion_btn.click(extract_only_a_portion_of_a_video, inputs=[url_input_portion, start_time_input, end_time_input], outputs=gr.Textbox())
|
207 |
-
|
208 |
-
with gr.Row():
|
209 |
-
url_input_metadata_update = gr.Textbox(label="URL")
|
210 |
-
metadata_update_btn = gr.Button("Update Metadata of Existing Files")
|
211 |
-
metadata_update_btn.click(update_metadata_of_existing_files, inputs=url_input_metadata_update, outputs=gr.Textbox())
|
212 |
-
|
213 |
-
with gr.Row():
|
214 |
-
url_input_rename = gr.Textbox(label="URL")
|
215 |
-
rename_btn = gr.Button("Auto-Rename Duplicate Files")
|
216 |
-
rename_btn.click(auto_rename_duplicate_files, inputs=url_input_rename, outputs=gr.Textbox())
|
217 |
-
|
218 |
-
with gr.Row():
|
219 |
-
file_path_input = gr.Textbox(label="File Path")
|
220 |
-
url_list_btn = gr.Button("Download from URL List File")
|
221 |
-
url_list_btn.click(download_from_url_list_file, inputs=file_path_input, outputs=gr.Textbox())
|
222 |
-
|
223 |
-
with gr.Row():
|
224 |
-
url_input_speed = gr.Textbox(label="URL")
|
225 |
-
speed_input = gr.Textbox(label="Speed (e.g., 1M)")
|
226 |
-
speed_btn = gr.Button("Download and Limit Download Speed")
|
227 |
-
speed_btn.click(download_and_limit_download_speed, inputs=[url_input_speed, speed_input], outputs=gr.Textbox())
|
228 |
-
|
229 |
-
with gr.Row():
|
230 |
-
url_input_vimeo = gr.Textbox(label="Vimeo Video URL")
|
231 |
-
vimeo_btn = gr.Button("Download from Vimeo")
|
232 |
-
vimeo_btn.click(download_from_vimeo, inputs=url_input_vimeo, outputs=gr.Textbox())
|
233 |
-
|
234 |
-
with gr.Row():
|
235 |
-
url_input_facebook = gr.Textbox(label="Facebook Video URL")
|
236 |
-
facebook_btn = gr.Button("Download from Facebook")
|
237 |
-
facebook_btn.click(download_from_facebook, inputs=url_input_facebook, outputs=gr.Textbox())
|
238 |
-
|
239 |
-
with gr.Row():
|
240 |
-
url_input_instagram = gr.Textbox(label="Instagram Video URL")
|
241 |
-
instagram_btn = gr.Button("Download from Instagram")
|
242 |
-
instagram_btn.click(download_from_instagram, inputs=url_input_instagram, outputs=gr.Textbox())
|
243 |
-
|
244 |
-
with gr.Row():
|
245 |
-
url_input_twitter = gr.Textbox(label="Twitter Video URL")
|
246 |
-
twitter_btn = gr.Button("Download from Twitter")
|
247 |
-
twitter_btn.click(download_from_twitter, inputs=url_input_twitter, outputs=gr.Textbox())
|
248 |
-
|
249 |
-
with gr.Row():
|
250 |
-
url_input_tiktok = gr.Textbox(label="TikTok Video URL")
|
251 |
-
tiktok_btn = gr.Button("Download from TikTok")
|
252 |
-
tiktok_btn.click(download_from_tiktok, inputs=url_input_tiktok, outputs=gr.Textbox())
|
253 |
-
|
254 |
-
with gr.Row():
|
255 |
-
url_input_reddit = gr.Textbox(label="Reddit Video URL")
|
256 |
-
reddit_btn = gr.Button("Download from Reddit")
|
257 |
-
reddit_btn.click(download_from_reddit, inputs=url_input_reddit, outputs=gr.Textbox())
|
258 |
-
|
259 |
-
with gr.Row():
|
260 |
-
url_input_dailymotion = gr.Textbox(label="Dailymotion Video URL")
|
261 |
-
dailymotion_btn = gr.Button("Download from Dailymotion")
|
262 |
-
dailymotion_btn.click(download_from_dailymotion, inputs=url_input_dailymotion, outputs=gr.Textbox())
|
263 |
-
|
264 |
-
with gr.Row():
|
265 |
-
url_input_transcript_text = gr.Textbox(label="YouTube Video URL")
|
266 |
-
transcript_text_btn = gr.Button("Download YouTube Transcript as Text")
|
267 |
-
transcript_text_btn.click(download_youtube_transcript_as_text, inputs=url_input_transcript_text, outputs=gr.Textbox())
|
268 |
-
|
269 |
-
with gr.Row():
|
270 |
-
url_input_transcript_md = gr.Textbox(label="YouTube Video URL")
|
271 |
-
transcript_md_btn = gr.Button("Download YouTube Transcript as Markdown")
|
272 |
-
transcript_md_btn.click(download_youtube_transcript_as_markdown, inputs=url_input_transcript_md, outputs=gr.Textbox())
|
273 |
-
|
274 |
-
with gr.Row():
|
275 |
-
url_input_video_info = gr.Textbox(label="YouTube Video URL")
|
276 |
-
video_info_btn = gr.Button("Download Video Info and Save as JSON")
|
277 |
-
video_info_btn.click(download_video_info_and_save_as_json, inputs=url_input_video_info, outputs=gr.Textbox())
|
278 |
-
|
279 |
-
with gr.Row():
|
280 |
-
url_input_list_formats = gr.Textbox(label="YouTube Video URL")
|
281 |
-
list_formats_without_downloading_btn = gr.Button("List Available Formats without Downloading")
|
282 |
-
list_formats_without_downloading_btn.click(list_available_formats_without_downloading, inputs=url_input_list_formats, outputs=gr.Textbox())
|
283 |
-
|
284 |
-
with gr.Row():
|
285 |
-
url_input_age_restricted = gr.Textbox(label="Age-Restricted Video URL")
|
286 |
-
email_input = gr.Textbox(label="Your YouTube Email")
|
287 |
-
password_input = gr.Textbox(label="Your Password", type="password")
|
288 |
-
age_restricted_btn = gr.Button("Download from YouTube Age-Restricted Content")
|
289 |
-
age_restricted_btn.click(download_from_youtube_age_restricted_content, inputs=[url_input_age_restricted, email_input, password_input], outputs=gr.Textbox())
|
290 |
-
|
291 |
-
with gr.Tab("SoundCloud Commands"):
|
292 |
-
with gr.Row():
|
293 |
-
url_input_soundcloud_formats = gr.Textbox(label="SoundCloud URL")
|
294 |
-
soundcloud_formats_btn = gr.Button("List Available Formats")
|
295 |
-
soundcloud_formats_btn.click(list_available_formats, inputs=url_input_soundcloud_formats, outputs=gr.Textbox())
|
296 |
-
|
297 |
-
with gr.Row():
|
298 |
-
url_input_soundcloud_hq = gr.Textbox(label="SoundCloud Track URL")
|
299 |
-
soundcloud_hq_btn = gr.Button("Download High-Quality MP3 from SoundCloud")
|
300 |
-
soundcloud_hq_btn.click(download_hq_from_soundcloud, inputs=url_input_soundcloud_hq, outputs=gr.Textbox())
|
301 |
-
|
302 |
-
with gr.Row():
|
303 |
-
url_input_soundcloud_metadata = gr.Textbox(label="SoundCloud Track URL")
|
304 |
-
soundcloud_metadata_btn = gr.Button("Download HQ with Metadata from SoundCloud")
|
305 |
-
soundcloud_metadata_btn.click(download_hq_from_soundcloud, inputs=url_input_soundcloud_metadata, outputs=gr.Textbox())
|
306 |
-
|
307 |
-
with gr.Row():
|
308 |
-
url_input_soundcloud_playlist = gr.Textbox(label="SoundCloud Playlist URL")
|
309 |
-
soundcloud_playlist_btn = gr.Button("Download Entire Playlist from SoundCloud")
|
310 |
-
soundcloud_playlist_btn.click(download_entire_playlist, inputs=url_input_soundcloud_playlist, outputs=gr.Textbox())
|
311 |
-
|
312 |
-
with gr.Row():
|
313 |
-
url_input_soundcloud_playlist_metadata = gr.Textbox(label="SoundCloud Playlist URL")
|
314 |
-
soundcloud_playlist_metadata_btn = gr.Button("Download Entire Playlist from SoundCloud with Metadata")
|
315 |
-
soundcloud_playlist_metadata_btn.click(download_entire_playlist, inputs=url_input_soundcloud_playlist_metadata, outputs=gr.Textbox())
|
316 |
-
|
317 |
-
with gr.Row():
|
318 |
-
url_input_soundcloud_multiple_playlists = gr.Textbox(label="SoundCloud Playlist URLs (space-separated)")
|
319 |
-
soundcloud_multiple_playlists_btn = gr.Button("Download Multiple Playlists with Metadata")
|
320 |
-
soundcloud_multiple_playlists_btn.click(download_multiple_individual_files, inputs=url_input_soundcloud_multiple_playlists, outputs=gr.Textbox())
|
321 |
-
|
322 |
-
with gr.Row():
|
323 |
-
url_input_soundcloud_playlist_range = gr.Textbox(label="SoundCloud Playlist URL")
|
324 |
-
start_input_soundcloud = gr.Textbox(label="Start Index")
|
325 |
-
end_input_soundcloud = gr.Textbox(label="End Index")
|
326 |
-
soundcloud_playlist_range_btn = gr.Button("Download Playlist with Specific Range")
|
327 |
-
soundcloud_playlist_range_btn.click(download_playlist_specific_range, inputs=[url_input_soundcloud_playlist_range, start_input_soundcloud, end_input_soundcloud], outputs=gr.Textbox())
|
328 |
-
|
329 |
-
with gr.Row():
|
330 |
-
url_input_soundcloud_album_art = gr.Textbox(label="SoundCloud Track URL")
|
331 |
-
soundcloud_album_art_btn = gr.Button("Download and Embed Album Art")
|
332 |
-
soundcloud_album_art_btn.click(embed_album_art_automatically, inputs=url_input_soundcloud_album_art, outputs=gr.Textbox())
|
333 |
-
|
334 |
-
with gr.Row():
|
335 |
-
url_input_soundcloud_skip = gr.Textbox(label="SoundCloud Track URL")
|
336 |
-
soundcloud_skip_btn = gr.Button("Skip Downloading Already Downloaded SoundCloud Files")
|
337 |
-
soundcloud_skip_btn.click(skip_already_downloaded_files, inputs=url_input_soundcloud_skip, outputs=gr.Textbox())
|
338 |
-
|
339 |
-
with gr.Row():
|
340 |
-
urls_input_soundcloud = gr.Textbox(label="SoundCloud Track URLs (space-separated)")
|
341 |
-
soundcloud_multiple_tracks_btn = gr.Button("Download Multiple Tracks from SoundCloud")
|
342 |
-
soundcloud_multiple_tracks_btn.click(download_multiple_individual_files, inputs=urls_input_soundcloud, outputs=gr.Textbox())
|
343 |
-
|
344 |
-
with gr.Row():
|
345 |
-
url_input_soundcloud_speed = gr.Textbox(label="SoundCloud Track URL")
|
346 |
-
speed_input_soundcloud = gr.Textbox(label="Speed (e.g., 1M)")
|
347 |
-
soundcloud_speed_btn = gr.Button("Limit Download Speed for SoundCloud")
|
348 |
-
soundcloud_speed_btn.click(download_and_limit_download_speed, inputs=[url_input_soundcloud_speed, speed_input_soundcloud], outputs=gr.Textbox())
|
349 |
-
|
350 |
-
with gr.Row():
|
351 |
-
url_input_soundcloud_chapters = gr.Textbox(label="SoundCloud Track URL")
|
352 |
-
soundcloud_chapters_btn = gr.Button("Download from SoundCloud and Split by Chapters (if available)")
|
353 |
-
soundcloud_chapters_btn.click(download_and_automatically_split_by_chapters, inputs=url_input_soundcloud_chapters, outputs=gr.Textbox())
|
354 |
-
|
355 |
-
with gr.Row():
|
356 |
-
url_input_soundcloud_portion = gr.Textbox(label="SoundCloud Track URL")
|
357 |
-
start_time_input_soundcloud = gr.Textbox(label="Start Time (e.g., 00:01:00)")
|
358 |
-
end_time_input_soundcloud = gr.Textbox(label="End Time (e.g., 00:05:00)")
|
359 |
-
soundcloud_portion_btn = gr.Button("Download SoundCloud Track and Extract a Specific Portion")
|
360 |
-
soundcloud_portion_btn.click(extract_only_a_portion_of_a_video, inputs=[url_input_soundcloud_portion, start_time_input_soundcloud, end_time_input_soundcloud], outputs=gr.Textbox())
|
361 |
-
|
362 |
-
with gr.Row():
|
363 |
-
url_input_soundcloud_metadata_update = gr.Textbox(label="SoundCloud Track URL")
|
364 |
-
soundcloud_metadata_update_btn = gr.Button("Update Metadata of Existing SoundCloud Downloads")
|
365 |
-
soundcloud_metadata_update_btn.click(update_metadata_of_existing_files, inputs=url_input_soundcloud_metadata_update, outputs=gr.Textbox())
|
366 |
-
|
367 |
-
with gr.Row():
|
368 |
-
url_input_soundcloud_rename = gr.Textbox(label="SoundCloud Track URL")
|
369 |
-
soundcloud_rename_btn = gr.Button("Auto-Rename Duplicate SoundCloud Files")
|
370 |
-
soundcloud_rename_btn.click(auto_rename_duplicate_files, inputs=url_input_soundcloud_rename, outputs=gr.Textbox())
|
371 |
-
|
372 |
-
with gr.Row():
|
373 |
-
file_path_input_soundcloud = gr.Textbox(label="File Path")
|
374 |
-
soundcloud_url_list_btn = gr.Button("Download from SoundCloud URL List File")
|
375 |
-
soundcloud_url_list_btn.click(download_from_url_list_file, inputs=file_path_input_soundcloud, outputs=gr.Textbox())
|
376 |
|
377 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Function to run yt-dlp commands
|
6 |
+
def run_yt_dlp(command, url, output_path, bitrate=None, start_time=None, end_time=None, playlist_items=None, archive_file=None):
|
7 |
+
base_command = ["yt-dlp", "-f", "bestaudio", "--extract-audio", "--audio-format", "mp3", "--audio-quality", "0", "-o", output_path]
|
8 |
+
|
9 |
+
if command == "list_formats":
|
10 |
+
base_command = ["yt-dlp", "-F", url]
|
11 |
+
elif command == "download_mp3_max_quality":
|
12 |
+
base_command.extend(["--postprocessor-args", "-b:a 320k", url])
|
13 |
+
elif command == "basic_high_quality_mp3":
|
14 |
+
base_command.append(url)
|
15 |
+
elif command == "custom_bitrate":
|
16 |
+
base_command.extend(["--postprocessor-args", f"-b:a {bitrate}k", url])
|
17 |
+
elif command == "add_metadata_tags":
|
18 |
+
base_command.extend(["--embed-metadata", url])
|
19 |
+
elif command == "download_playlist":
|
20 |
+
base_command.append(url)
|
21 |
+
elif command == "download_playlist_range":
|
22 |
+
base_command.extend(["--playlist-items", playlist_items, url])
|
23 |
+
elif command == "download_hq_soundcloud":
|
24 |
+
base_command.extend(["-o", "P:/Local Music/SoundCloud/%(uploader)s - %(title)s.%(ext)s", url])
|
25 |
+
elif command == "embed_album_art":
|
26 |
+
base_command.extend(["--embed-thumbnail", url])
|
27 |
+
elif command == "download_opus":
|
28 |
+
base_command.extend(["--audio-format", "opus", url])
|
29 |
+
elif command == "skip_downloaded_files":
|
30 |
+
base_command.extend(["--download-archive", archive_file, url])
|
31 |
+
elif command == "download_multiple_files":
|
32 |
+
base_command.extend(url.split())
|
33 |
+
elif command == "download_split_chapters":
|
34 |
+
base_command.extend(["--split-chapters", url])
|
35 |
+
elif command == "extract_portion":
|
36 |
+
base_command.extend(["-f", "bestvideo+bestaudio", "--external-downloader", "ffmpeg", "--external-downloader-args", f"ffmpeg_i:-ss {start_time} -to {end_time}", url])
|
37 |
+
elif command == "update_metadata":
|
38 |
+
base_command.extend(["--download-archive", archive_file, "--skip-download", "--embed-metadata", "--embed-thumbnail", url])
|
39 |
+
elif command == "auto_rename":
|
40 |
+
base_command.extend(["--force-overwrites", url])
|
41 |
+
elif command == "download_url_list":
|
42 |
+
base_command.extend(["-a", url])
|
43 |
+
elif command == "limit_speed":
|
44 |
+
base_command.extend(["--rate-limit", "1M", url])
|
45 |
+
elif command == "download_vimeo":
|
46 |
+
base_command.extend(["-o", "P:/Local Music/Vimeo/%(uploader)s - %(title)s.%(ext)s", url])
|
47 |
+
elif command == "download_facebook":
|
48 |
+
base_command.extend(["-o", "P:/Local Music/Facebook/%(uploader)s - %(title)s.%(ext)s", url])
|
49 |
+
elif command == "download_instagram":
|
50 |
+
base_command.extend(["-o", "P:/Local Music/Instagram/%(uploader)s - %(title)s.%(ext)s", url])
|
51 |
+
elif command == "download_twitter":
|
52 |
+
base_command.extend(["-o", "P:/Local Music/Twitter/%(uploader)s - %(title)s.%(ext)s", url])
|
53 |
+
elif command == "download_tiktok":
|
54 |
+
base_command.extend(["-o", "P:/Local Music/TikTok/%(uploader)s - %(title)s.%(ext)s", url])
|
55 |
+
elif command == "download_reddit":
|
56 |
+
base_command.extend(["-o", "P:/Local Music/Reddit/%(uploader)s - %(title)s.%(ext)s", url])
|
57 |
+
elif command == "download_dailymotion":
|
58 |
+
base_command.extend(["-o", "P:/Local Music/Dailymotion/%(uploader)s - %(title)s.%(ext)s", url])
|
59 |
+
elif command == "download_transcript_text":
|
60 |
+
base_command.extend(["--write-auto-subs", "--sub-lang", "en", "--skip-download", url])
|
61 |
+
elif command == "download_transcript_markdown":
|
62 |
+
base_command.extend(["--write-auto-subs", "--sub-lang", "en", "--skip-download", "--convert-subs", "srt", "-o", "P:/Local Music/%(title)s.md", url])
|
63 |
+
elif command == "download_video_info":
|
64 |
+
base_command.extend(["--write-info-json", "--skip-download", "-o", "P:/Local Music/%(title)s.json", url])
|
65 |
+
elif command == "list_formats_no_download":
|
66 |
+
base_command = ["yt-dlp", "-F", url]
|
67 |
+
elif command == "download_age_restricted":
|
68 |
+
base_command.extend(["--username", "YOUR_YOUTUBE_EMAIL", "--password", "YOUR_PASSWORD", "-f", "bestvideo+bestaudio", url])
|
69 |
+
|
70 |
+
try:
|
71 |
+
result = subprocess.run(base_command, capture_output=True, text=True)
|
72 |
+
return result.stdout
|
73 |
+
except Exception as e:
|
74 |
+
return str(e)
|
75 |
+
|
76 |
+
# Gradio Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
with gr.Blocks() as demo:
|
78 |
+
gr.Markdown("# yt-dlp Command Executor")
|
79 |
+
|
80 |
+
with gr.Row():
|
81 |
+
command = gr.Dropdown(choices=[
|
82 |
+
"list_formats",
|
83 |
+
"download_mp3_max_quality",
|
84 |
+
"basic_high_quality_mp3",
|
85 |
+
"custom_bitrate",
|
86 |
+
"add_metadata_tags",
|
87 |
+
"download_playlist",
|
88 |
+
"download_playlist_range",
|
89 |
+
"download_hq_soundcloud",
|
90 |
+
"embed_album_art",
|
91 |
+
"download_opus",
|
92 |
+
"skip_downloaded_files",
|
93 |
+
"download_multiple_files",
|
94 |
+
"download_split_chapters",
|
95 |
+
"extract_portion",
|
96 |
+
"update_metadata",
|
97 |
+
"auto_rename",
|
98 |
+
"download_url_list",
|
99 |
+
"limit_speed",
|
100 |
+
"download_vimeo",
|
101 |
+
"download_facebook",
|
102 |
+
"download_instagram",
|
103 |
+
"download_twitter",
|
104 |
+
"download_tiktok",
|
105 |
+
"download_reddit",
|
106 |
+
"download_dailymotion",
|
107 |
+
"download_transcript_text",
|
108 |
+
"download_transcript_markdown",
|
109 |
+
"download_video_info",
|
110 |
+
"list_formats_no_download",
|
111 |
+
"download_age_restricted"
|
112 |
+
], label="Command")
|
113 |
+
|
114 |
+
url = gr.Textbox(label="URL", placeholder="Enter the URL here")
|
115 |
+
|
116 |
+
with gr.Row():
|
117 |
+
output_path = gr.Textbox(label="Output Path", placeholder="Enter the output path here")
|
118 |
+
bitrate = gr.Textbox(label="Bitrate (for custom bitrate)", placeholder="Enter bitrate in kbps, e.g., 192")
|
119 |
+
start_time = gr.Textbox(label="Start Time (HH:MM:SS)", placeholder="Enter start time, e.g., 00:01:00")
|
120 |
+
end_time = gr.Textbox(label="End Time (HH:MM:SS)", placeholder="Enter end time, e.g., 00:05:00")
|
121 |
+
playlist_items = gr.Textbox(label="Playlist Items (e.g., 1-5)", placeholder="Enter range of items, e.g., 1-5")
|
122 |
+
archive_file = gr.Textbox(label="Archive File", placeholder="Enter path to archive file, e.g., P:/Local Music/downloaded.txt")
|
123 |
+
|
124 |
+
execute_button = gr.Button("Execute Command")
|
125 |
+
output = gr.Textbox(label="Output", lines=10)
|
126 |
+
|
127 |
+
execute_button.click(
|
128 |
+
fn=run_yt_dlp,
|
129 |
+
inputs=[command, url, output_path, bitrate, start_time, end_time, playlist_items, archive_file],
|
130 |
+
outputs=output
|
131 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
demo.launch()
|