RO-Rtechs commited on
Commit
5dd4749
·
verified ·
1 Parent(s): 506f8a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -108
app.py CHANGED
@@ -326,154 +326,117 @@ def get_video_qualities(video_url):
326
  utils.colab_check = lambda: True
327
 
328
  custom_css = """
329
- /* Root styles */
330
- :root {
331
- --primary-hue: 210;
332
- --secondary-hue: 160;
333
- --neutral-hue: 0;
334
- --primary-color: hsl(var(--primary-hue), 70%, 55%);
335
- --secondary-color: hsl(var(--secondary-hue), 70%, 55%);
336
- --neutral-color: hsl(var(--neutral-hue), 0%, 95%);
337
- --text-color: hsl(var(--neutral-hue), 0%, 20%);
338
- --border-radius: 8px;
339
- }
340
-
341
- /* Body and main container */
342
  body, #component-0 {
343
- margin: 0;
344
- padding: 0;
345
  height: 100vh;
 
346
  overflow: hidden;
 
 
347
  }
348
-
349
- /* Gradio container */
350
  .gradio-container {
351
- width: 100%;
352
- max-width: 100%;
353
- padding: 0;
354
- margin: 0 auto;
 
355
  }
356
-
 
 
 
 
 
 
357
  /* Main content area */
358
  .main-content {
 
359
  display: flex;
360
- flex-wrap: wrap;
361
- gap: 1rem;
362
- height: calc(100vh - 80px); /* Adjust based on your header height */
363
- overflow-y: auto;
364
  padding: 1rem;
365
- box-sizing: border-box;
366
  }
367
-
368
- /* Individual sections */
369
- .input-section, .segment-controls, .options-section, .output-section {
370
- background-color: var(--neutral-color);
371
- border-radius: var(--border-radius);
372
- padding: 1rem;
373
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
374
- flex: 1 1 300px;
375
- max-height: 100%;
 
 
 
 
 
 
376
  overflow-y: auto;
 
377
  }
378
-
379
- /* Responsive design */
380
  @media (max-width: 768px) {
381
  .main-content {
382
  flex-direction: column;
383
  }
384
- .input-section, .segment-controls, .options-section, .output-section {
385
- flex: 1 1 auto;
386
- }
387
  }
388
-
389
- /* Other styles (unchanged) */
390
  .segment-input, .time-input, .button-row {
391
  display: flex;
392
- flex-wrap: wrap;
393
  gap: 0.5rem;
394
- align-items: center;
395
  }
396
- .time-input { width: 60px !important; text-align: center; }
397
- .time-label, .separator { font-weight: bold; color: var(--primary-color); margin-bottom: 0.5rem; }
398
- .button-row { justify-content: space-between; }
399
  .url-input { flex-grow: 1; }
400
  .quality-dropdown { width: 100px !important; }
401
  """
402
 
403
- with gr.Blocks(
404
- title="YouTube Segment Downloader",
405
- theme=gr.themes.Soft(
406
- primary_hue="blue",
407
- secondary_hue="green",
408
- neutral_hue="gray"
409
- ).set(
410
- body_text_color="*neutral_800",
411
- background_fill_primary="*neutral_50",
412
- button_primary_background_fill="*primary_500",
413
- button_primary_background_fill_hover="*primary_600",
414
- button_secondary_background_fill="*secondary_500",
415
- button_secondary_background_fill_hover="*secondary_600",
416
- ),
417
- css=custom_css
418
- ) as iface:
419
  gr.Markdown("# 🎬 YouTube Segment Downloader", elem_classes="header")
420
 
421
  with gr.Row(elem_classes="main-content"):
422
  with gr.Column(elem_classes="input-section"):
423
- with gr.Row():
424
- video_url = gr.Textbox(
425
- label="YouTube URL",
426
- placeholder="Paste URL here",
427
- elem_classes="url-input"
428
- )
429
- quality = gr.Dropdown(
430
- label="Quality",
431
- choices=[],
432
- interactive=True,
433
- elem_classes="quality-dropdown",
434
- visible=False
435
- )
436
- url_status = gr.Markdown(visible=False)
437
-
438
- with gr.Column(elem_classes="segment-controls"):
439
- gr.Markdown("### Add Segments", elem_classes="time-label")
440
  with gr.Row(elem_classes="segment-input"):
441
  start_hours = gr.Number(label="Start HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
442
  start_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
443
  start_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
444
-
445
- gr.Markdown("to", elem_classes="separator")
446
-
447
  end_hours = gr.Number(label="End HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
448
  end_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
449
- end_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time_input")
450
 
451
  add_btn = gr.Button("Add Segment", variant="primary")
452
-
453
- segments = gr.Dataframe(
454
- headers=["Segment"],
455
- row_count=3,
456
- col_count=1,
457
- datatype=["str"],
458
- interactive=True,
459
- label="Segments"
460
- )
461
-
462
  with gr.Column(elem_classes="options-section"):
463
- combine = gr.Checkbox(label="Combine segments", value=True)
464
- audio_only = gr.Checkbox(label="Audio only", value=False)
465
- remove_index = gr.Number(label="Remove segment", minimum=0, step=1, value=0)
466
- remove_btn = gr.Button("Remove", variant="secondary")
467
- old_index = gr.Number(label="Move from", minimum=0, step=1, value=0)
468
- new_index = gr.Number(label="to", minimum=0, step=1, value=0)
469
- move_btn = gr.Button("Move", variant="secondary")
470
-
471
- submit_btn = gr.Button("🚀 Download", variant="primary")
472
-
473
  with gr.Column(elem_classes="output-section"):
474
- progress = gr.Slider(label="Progress", minimum=0, maximum=100, step=1, interactive=False)
475
- status = gr.Textbox(label="Status", lines=1)
476
- output_file = gr.File(label="Downloaded File")
 
477
 
478
  add_btn.click(
479
  add_segment,
 
326
  utils.colab_check = lambda: True
327
 
328
  custom_css = """
329
+ /* Reset and base styles */
330
+ * { box-sizing: border-box; margin: 0; padding: 0; }
331
+
 
 
 
 
 
 
 
 
 
 
332
  body, #component-0 {
 
 
333
  height: 100vh;
334
+ max-height: 100vh;
335
  overflow: hidden;
336
+ display: flex;
337
+ flex-direction: column;
338
  }
339
+
340
+ /* Gradio container modifications */
341
  .gradio-container {
342
+ flex-grow: 1;
343
+ display: flex;
344
+ flex-direction: column;
345
+ max-height: 100vh;
346
+ overflow: hidden;
347
  }
348
+
349
+ /* Header */
350
+ .header {
351
+ padding: 1rem;
352
+ background-color: #f0f0f0;
353
+ }
354
+
355
  /* Main content area */
356
  .main-content {
357
+ flex-grow: 1;
358
  display: flex;
359
+ overflow: hidden;
 
 
 
360
  padding: 1rem;
361
+ gap: 1rem;
362
  }
363
+
364
+ /* Columns */
365
+ .input-section, .options-section, .output-section {
366
+ flex: 1;
367
+ display: flex;
368
+ flex-direction: column;
369
+ overflow: hidden;
370
+ background-color: #ffffff;
371
+ border-radius: 8px;
372
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
373
+ }
374
+
375
+ /* Scrollable areas */
376
+ .scroll-area {
377
+ flex-grow: 1;
378
  overflow-y: auto;
379
+ padding: 1rem;
380
  }
381
+
382
+ /* Responsive adjustments */
383
  @media (max-width: 768px) {
384
  .main-content {
385
  flex-direction: column;
386
  }
 
 
 
387
  }
388
+
389
+ /* Additional styles */
390
  .segment-input, .time-input, .button-row {
391
  display: flex;
 
392
  gap: 0.5rem;
393
+ margin-bottom: 1rem;
394
  }
395
+ .time-input { width: 60px !important; }
 
 
396
  .url-input { flex-grow: 1; }
397
  .quality-dropdown { width: 100px !important; }
398
  """
399
 
400
+ with gr.Blocks(title="YouTube Segment Downloader", theme=gr.themes.Default(), css=custom_css) as iface:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  gr.Markdown("# 🎬 YouTube Segment Downloader", elem_classes="header")
402
 
403
  with gr.Row(elem_classes="main-content"):
404
  with gr.Column(elem_classes="input-section"):
405
+ with gr.Box(elem_classes="scroll-area"):
406
+ with gr.Row():
407
+ video_url = gr.Textbox(label="YouTube URL", placeholder="Paste URL here", elem_classes="url-input")
408
+ quality = gr.Dropdown(label="Quality", choices=[], interactive=True, elem_classes="quality-dropdown", visible=False)
409
+ url_status = gr.Markdown(visible=False)
410
+
411
+ gr.Markdown("### Add Segments")
 
 
 
 
 
 
 
 
 
 
412
  with gr.Row(elem_classes="segment-input"):
413
  start_hours = gr.Number(label="Start HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
414
  start_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
415
  start_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
416
+ gr.Markdown("to")
 
 
417
  end_hours = gr.Number(label="End HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
418
  end_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
419
+ end_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
420
 
421
  add_btn = gr.Button("Add Segment", variant="primary")
422
+ segments = gr.Dataframe(headers=["Segment"], row_count=3, col_count=1, datatype=["str"], interactive=True, label="Segments")
423
+
 
 
 
 
 
 
 
 
424
  with gr.Column(elem_classes="options-section"):
425
+ with gr.Box(elem_classes="scroll-area"):
426
+ combine = gr.Checkbox(label="Combine segments", value=True)
427
+ audio_only = gr.Checkbox(label="Audio only", value=False)
428
+ remove_index = gr.Number(label="Remove segment", minimum=0, step=1, value=0)
429
+ remove_btn = gr.Button("Remove", variant="secondary")
430
+ old_index = gr.Number(label="Move from", minimum=0, step=1, value=0)
431
+ new_index = gr.Number(label="to", minimum=0, step=1, value=0)
432
+ move_btn = gr.Button("Move", variant="secondary")
433
+ submit_btn = gr.Button("🚀 Download", variant="primary")
434
+
435
  with gr.Column(elem_classes="output-section"):
436
+ with gr.Box(elem_classes="scroll-area"):
437
+ progress = gr.Slider(label="Progress", minimum=0, maximum=100, step=1, interactive=False)
438
+ status = gr.Textbox(label="Status", lines=1)
439
+ output_file = gr.File(label="Downloaded File")
440
 
441
  add_btn.click(
442
  add_segment,