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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +91 -59
app.py CHANGED
@@ -326,6 +326,7 @@ def get_video_qualities(video_url):
326
  utils.colab_check = lambda: True
327
 
328
  custom_css = """
 
329
  :root {
330
  --primary-hue: 210;
331
  --secondary-hue: 160;
@@ -336,11 +337,35 @@ custom_css = """
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; max-height: calc(100vh - 150px); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  .input-section, .segment-controls, .options-section, .output-section {
345
  background-color: var(--neutral-color);
346
  border-radius: var(--border-radius);
@@ -350,6 +375,18 @@ custom_css = """
350
  max-height: 100%;
351
  overflow-y: auto;
352
  }
 
 
 
 
 
 
 
 
 
 
 
 
353
  .segment-input, .time-input, .button-row {
354
  display: flex;
355
  flex-wrap: wrap;
@@ -359,10 +396,6 @@ custom_css = """
359
  .time-input { width: 60px !important; text-align: center; }
360
  .time-label, .separator { font-weight: bold; color: var(--primary-color); margin-bottom: 0.5rem; }
361
  .button-row { justify-content: space-between; }
362
- @media (max-width: 768px) {
363
- .main-content { flex-direction: column; }
364
- .input-section, .segment-controls, .options-section, .output-section { flex: 1 1 100%; }
365
- }
366
  .url-input { flex-grow: 1; }
367
  .quality-dropdown { width: 100px !important; }
368
  """
@@ -383,61 +416,60 @@ with gr.Blocks(
383
  ),
384
  css=custom_css
385
  ) as iface:
386
- with gr.Column(elem_classes="container"):
387
- gr.Markdown("# 🎬 YouTube Segment Downloader", elem_classes="header")
388
-
389
- with gr.Row(elem_classes="main-content"):
390
- with gr.Column(elem_classes="input-section"):
391
- with gr.Row():
392
- video_url = gr.Textbox(
393
- label="YouTube URL",
394
- placeholder="Paste URL here",
395
- elem_classes="url-input"
396
- )
397
- quality = gr.Dropdown(
398
- label="Quality",
399
- choices=[],
400
- interactive=True,
401
- elem_classes="quality-dropdown",
402
- visible=False
403
- )
404
- url_status = gr.Markdown(visible=False)
405
-
406
- with gr.Column(elem_classes="segment-controls"):
407
- gr.Markdown("### Add Segments", elem_classes="time-label")
408
- with gr.Row(elem_classes="segment-input"):
409
- start_hours = gr.Number(label="Start HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
410
- start_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
411
- start_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
412
-
413
- gr.Markdown("to", elem_classes="separator")
414
-
415
- end_hours = gr.Number(label="End HH", minimum=0, maximum=23, step=1, value=0, elem_classes="time-input")
416
- end_minutes = gr.Number(label="MM", minimum=0, maximum=59, step=1, value=0, elem_classes="time-input")
417
- end_seconds = gr.Number(label="SS", minimum=0, maximum=59, step=1, value=0, elem_classes="time_input")
418
-
419
- add_btn = gr.Button("Add Segment", variant="primary")
420
-
421
- segments = gr.Dataframe(
422
- headers=["Segment"],
423
- row_count=3,
424
- col_count=1,
425
- datatype=["str"],
426
  interactive=True,
427
- label="Segments"
 
428
  )
 
429
 
430
- with gr.Column(elem_classes="options-section"):
431
- combine = gr.Checkbox(label="Combine segments", value=True)
432
- audio_only = gr.Checkbox(label="Audio only", value=False)
433
- remove_index = gr.Number(label="Remove segment", minimum=0, step=1, value=0)
434
- remove_btn = gr.Button("Remove", variant="secondary")
435
- old_index = gr.Number(label="Move from", minimum=0, step=1, value=0)
436
- new_index = gr.Number(label="to", minimum=0, step=1, value=0)
437
- move_btn = gr.Button("Move", variant="secondary")
 
 
 
 
438
 
439
- submit_btn = gr.Button("🚀 Download", variant="primary")
 
 
 
 
 
 
 
 
 
440
 
 
 
 
 
 
 
 
 
 
 
 
441
  with gr.Column(elem_classes="output-section"):
442
  progress = gr.Slider(label="Progress", minimum=0, maximum=100, step=1, interactive=False)
443
  status = gr.Textbox(label="Status", lines=1)
 
326
  utils.colab_check = lambda: True
327
 
328
  custom_css = """
329
+ /* Root styles */
330
  :root {
331
  --primary-hue: 210;
332
  --secondary-hue: 160;
 
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);
 
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;
 
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
  """
 
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)