Update app.py
Browse files
app.py
CHANGED
@@ -326,80 +326,95 @@ def get_video_qualities(video_url):
|
|
326 |
utils.colab_check = lambda: True
|
327 |
|
328 |
custom_css = """
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
}
|
346 |
-
.main-content {
|
347 |
-
display: flex;
|
348 |
-
flex-wrap: wrap;
|
349 |
-
gap: 1rem;
|
350 |
-
overflow-y: auto;
|
351 |
-
flex: 1;
|
352 |
-
}
|
353 |
-
.input-section, .options-section {
|
354 |
flex: 1 1 300px;
|
355 |
-
min-width: 300px;
|
356 |
}
|
357 |
-
.
|
358 |
-
flex-basis: 100%;
|
359 |
-
}
|
360 |
-
.segment-input {
|
361 |
display: flex;
|
362 |
flex-wrap: wrap;
|
363 |
gap: 0.5rem;
|
364 |
align-items: center;
|
365 |
}
|
366 |
-
.time-input {
|
367 |
-
|
368 |
-
}
|
369 |
@media (max-width: 768px) {
|
370 |
-
.main-content {
|
371 |
-
|
372 |
-
}
|
373 |
-
.input-section, .options-section {
|
374 |
-
flex-basis: 100%;
|
375 |
-
}
|
376 |
}
|
|
|
|
|
377 |
"""
|
378 |
|
379 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
with gr.Column(elem_classes="container"):
|
381 |
gr.Markdown("# 🎬 YouTube Segment Downloader", elem_classes="header")
|
382 |
|
383 |
with gr.Row(elem_classes="main-content"):
|
384 |
with gr.Column(elem_classes="input-section"):
|
385 |
-
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
url_status = gr.Markdown(visible=False)
|
388 |
|
389 |
-
with gr.Column():
|
390 |
-
gr.Markdown("### Add Segments")
|
391 |
with gr.Row(elem_classes="segment-input"):
|
392 |
start_hours = gr.Number(label="Start HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
|
393 |
start_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
394 |
start_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
395 |
|
396 |
-
gr.Markdown("to")
|
397 |
|
398 |
end_hours = gr.Number(label="End HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
|
399 |
end_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
400 |
-
end_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="
|
401 |
|
402 |
-
add_btn = gr.Button("Add Segment")
|
403 |
|
404 |
segments = gr.Dataframe(
|
405 |
headers=["Segment"],
|
@@ -414,10 +429,10 @@ with gr.Blocks(css=custom_css) as iface:
|
|
414 |
combine = gr.Checkbox(label="Combine segments", value=True)
|
415 |
audio_only = gr.Checkbox(label="Audio only", value=False)
|
416 |
remove_index = gr.Number(label="Remove segment", minimum=0, step=1, value=0)
|
417 |
-
remove_btn = gr.Button("Remove")
|
418 |
old_index = gr.Number(label="Move from", minimum=0, step=1, value=0)
|
419 |
new_index = gr.Number(label="to", minimum=0, step=1, value=0)
|
420 |
-
move_btn = gr.Button("Move")
|
421 |
|
422 |
submit_btn = gr.Button("🚀 Download", variant="primary")
|
423 |
|
|
|
326 |
utils.colab_check = lambda: True
|
327 |
|
328 |
custom_css = """
|
329 |
+
:root {
|
330 |
+
--primary-hue: 210;
|
331 |
+
--secondary-hue: 160;
|
332 |
+
--neutral-hue: 0;
|
333 |
+
--primary-color: hsl(var(--primary-hue), 70%, 55%);
|
334 |
+
--secondary-color: hsl(var(--secondary-hue), 70%, 55%);
|
335 |
+
--neutral-color: hsl(var(--neutral-hue), 0%, 95%);
|
336 |
+
--text-color: hsl(var(--neutral-hue), 0%, 20%);
|
337 |
+
--border-radius: 8px;
|
338 |
}
|
339 |
+
body { font-family: 'Inter', sans-serif; margin: 0; padding: 0; height: 100vh; overflow: hidden; }
|
340 |
+
#component-0 { height: 100vh; overflow-y: auto; padding: 1rem; box-sizing: border-box; }
|
341 |
+
.container { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; height: 100%; }
|
342 |
+
.header { text-align: center; margin-bottom: 1rem; }
|
343 |
+
.main-content { display: flex; flex-wrap: wrap; gap: 1rem; flex-grow: 1; overflow-y: auto; }
|
344 |
+
.input-section, .segment-controls, .options-section, .output-section {
|
345 |
+
background-color: var(--neutral-color);
|
346 |
+
border-radius: var(--border-radius);
|
347 |
+
padding: 1rem;
|
348 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
flex: 1 1 300px;
|
|
|
350 |
}
|
351 |
+
.segment-input, .time-input, .button-row {
|
|
|
|
|
|
|
352 |
display: flex;
|
353 |
flex-wrap: wrap;
|
354 |
gap: 0.5rem;
|
355 |
align-items: center;
|
356 |
}
|
357 |
+
.time-input { width: 60px !important; text-align: center; }
|
358 |
+
.time-label, .separator { font-weight: bold; color: var(--primary-color); margin-bottom: 0.5rem; }
|
359 |
+
.button-row { justify-content: space-between; }
|
360 |
@media (max-width: 768px) {
|
361 |
+
.main-content { flex-direction: column; }
|
362 |
+
.input-section, .segment-controls, .options-section, .output-section { flex: 1 1 100%; }
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
+
.url-input { flex-grow: 1; }
|
365 |
+
.quality-dropdown { width: 100px !important; }
|
366 |
"""
|
367 |
|
368 |
+
with gr.Blocks(
|
369 |
+
title="YouTube Segment Downloader",
|
370 |
+
theme=gr.themes.Soft(
|
371 |
+
primary_hue="blue",
|
372 |
+
secondary_hue="green",
|
373 |
+
neutral_hue="gray"
|
374 |
+
).set(
|
375 |
+
body_text_color="*neutral_800",
|
376 |
+
background_fill_primary="*neutral_50",
|
377 |
+
button_primary_background_fill="*primary_500",
|
378 |
+
button_primary_background_fill_hover="*primary_600",
|
379 |
+
button_secondary_background_fill="*secondary_500",
|
380 |
+
button_secondary_background_fill_hover="*secondary_600",
|
381 |
+
),
|
382 |
+
css=custom_css
|
383 |
+
) as iface:
|
384 |
with gr.Column(elem_classes="container"):
|
385 |
gr.Markdown("# 🎬 YouTube Segment Downloader", elem_classes="header")
|
386 |
|
387 |
with gr.Row(elem_classes="main-content"):
|
388 |
with gr.Column(elem_classes="input-section"):
|
389 |
+
with gr.Row():
|
390 |
+
video_url = gr.Textbox(
|
391 |
+
label="YouTube URL",
|
392 |
+
placeholder="Paste URL here",
|
393 |
+
elem_classes="url-input"
|
394 |
+
)
|
395 |
+
quality = gr.Dropdown(
|
396 |
+
label="Quality",
|
397 |
+
choices=[],
|
398 |
+
interactive=True,
|
399 |
+
elem_classes="quality-dropdown",
|
400 |
+
visible=False
|
401 |
+
)
|
402 |
url_status = gr.Markdown(visible=False)
|
403 |
|
404 |
+
with gr.Column(elem_classes="segment-controls"):
|
405 |
+
gr.Markdown("### Add Segments", elem_classes="time-label")
|
406 |
with gr.Row(elem_classes="segment-input"):
|
407 |
start_hours = gr.Number(label="Start HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
|
408 |
start_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
409 |
start_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
410 |
|
411 |
+
gr.Markdown("to", elem_classes="separator")
|
412 |
|
413 |
end_hours = gr.Number(label="End HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
|
414 |
end_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
|
415 |
+
end_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time_input")
|
416 |
|
417 |
+
add_btn = gr.Button("Add Segment", variant="primary")
|
418 |
|
419 |
segments = gr.Dataframe(
|
420 |
headers=["Segment"],
|
|
|
429 |
combine = gr.Checkbox(label="Combine segments", value=True)
|
430 |
audio_only = gr.Checkbox(label="Audio only", value=False)
|
431 |
remove_index = gr.Number(label="Remove segment", minimum=0, step=1, value=0)
|
432 |
+
remove_btn = gr.Button("Remove", variant="secondary")
|
433 |
old_index = gr.Number(label="Move from", minimum=0, step=1, value=0)
|
434 |
new_index = gr.Number(label="to", minimum=0, step=1, value=0)
|
435 |
+
move_btn = gr.Button("Move", variant="secondary")
|
436 |
|
437 |
submit_btn = gr.Button("🚀 Download", variant="primary")
|
438 |
|