Fred808 commited on
Commit
88be4ca
Β·
verified Β·
1 Parent(s): 9483663

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +97 -8
main.py CHANGED
@@ -545,7 +545,7 @@ downloader = BatchYouTubeDownloader()
545
 
546
  @app.get("/", response_class=HTMLResponse)
547
  async def read_root():
548
- """Serve the main HTML interface with batch support"""
549
  html_content = """
550
  <!DOCTYPE html>
551
  <html lang="en">
@@ -587,6 +587,13 @@ async def read_root():
587
  padding: 20px;
588
  margin: 20px 0;
589
  }
 
 
 
 
 
 
 
590
  .btn {
591
  background: linear-gradient(135deg, #667eea, #764ba2);
592
  color: white;
@@ -613,13 +620,55 @@ async def read_root():
613
  background: #e8f5e8;
614
  border: 1px solid #4caf50;
615
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  </style>
617
  </head>
618
  <body>
619
  <div class="container">
620
  <div class="header">
621
  <h1>πŸ“¦ Batch YouTube Video Downloader</h1>
622
- <p>Download single videos or process multiple URLs in batches</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  </div>
624
 
625
  <div class="section">
@@ -649,6 +698,12 @@ async def read_root():
649
  <div class="section">
650
  <h3>πŸ“‹ API Endpoints</h3>
651
 
 
 
 
 
 
 
652
  <h4>Single Video Operations:</h4>
653
  <ul>
654
  <li><code>POST /video/info</code> - Get single video information</li>
@@ -661,12 +716,16 @@ async def read_root():
661
  <li><code>POST /batch/download</code> - Start batch download</li>
662
  <li><code>GET /batch/status/{batch_id}</code> - Check batch progress</li>
663
  </ul>
664
-
665
- <h4>Cookie Management:</h4>
666
- <ul>
667
- <li><code>POST /upload-cookies</code> - Upload cookie file</li>
668
- <li><code>GET /cookie-status</code> - Check cookie status</li>
669
- </ul>
 
 
 
 
670
  </div>
671
 
672
  <div style="text-align: center;">
@@ -675,6 +734,36 @@ async def read_root():
675
  <a href="/cookie-status" class="btn">πŸͺ Cookie Status</a>
676
  </div>
677
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
678
  </body>
679
  </html>
680
  """
 
545
 
546
  @app.get("/", response_class=HTMLResponse)
547
  async def read_root():
548
+ """Serve the main HTML interface with batch support and cookie upload"""
549
  html_content = """
550
  <!DOCTYPE html>
551
  <html lang="en">
 
587
  padding: 20px;
588
  margin: 20px 0;
589
  }
590
+ .upload-area {
591
+ border: 2px dashed #dee2e6;
592
+ border-radius: 8px;
593
+ padding: 20px;
594
+ text-align: center;
595
+ margin: 15px 0;
596
+ }
597
  .btn {
598
  background: linear-gradient(135deg, #667eea, #764ba2);
599
  color: white;
 
620
  background: #e8f5e8;
621
  border: 1px solid #4caf50;
622
  }
623
+ .warning {
624
+ background: #fff3cd;
625
+ border: 1px solid #ffeaa7;
626
+ border-radius: 5px;
627
+ padding: 15px;
628
+ margin: 20px 0;
629
+ color: #856404;
630
+ }
631
+ .success {
632
+ background: #d4edda;
633
+ border: 1px solid #c3e6cb;
634
+ border-radius: 5px;
635
+ padding: 15px;
636
+ margin: 20px 0;
637
+ color: #155724;
638
+ }
639
+ input[type="file"] {
640
+ margin: 10px 0;
641
+ }
642
  </style>
643
  </head>
644
  <body>
645
  <div class="container">
646
  <div class="header">
647
  <h1>πŸ“¦ Batch YouTube Video Downloader</h1>
648
+ <p>Download single videos or process multiple URLs in batches with cookie support</p>
649
+ </div>
650
+
651
+ <div class="warning">
652
+ <strong>⚠️ Cookie Issues?</strong> If your cookies aren't working, they might be:
653
+ <ul>
654
+ <li>Expired (YouTube cookies expire frequently)</li>
655
+ <li>Wrong format (must be Netscape format)</li>
656
+ <li>Missing essential cookies</li>
657
+ <li>From a different IP/location</li>
658
+ </ul>
659
+ </div>
660
+
661
+ <div class="section">
662
+ <h3>πŸ“€ Upload Cookie File</h3>
663
+ <div class="upload-area">
664
+ <form id="cookieForm" enctype="multipart/form-data">
665
+ <p>Select your YouTube cookies.txt file (Netscape format):</p>
666
+ <input type="file" id="cookieFile" name="cookie_file" accept=".txt" required>
667
+ <br>
668
+ <button type="submit" class="btn">Upload Cookies</button>
669
+ </form>
670
+ </div>
671
+ <div id="uploadResult"></div>
672
  </div>
673
 
674
  <div class="section">
 
698
  <div class="section">
699
  <h3>πŸ“‹ API Endpoints</h3>
700
 
701
+ <h4>Cookie Management:</h4>
702
+ <ul>
703
+ <li><code>POST /upload-cookies</code> - Upload cookie file</li>
704
+ <li><code>GET /cookie-status</code> - Check cookie status</li>
705
+ </ul>
706
+
707
  <h4>Single Video Operations:</h4>
708
  <ul>
709
  <li><code>POST /video/info</code> - Get single video information</li>
 
716
  <li><code>POST /batch/download</code> - Start batch download</li>
717
  <li><code>GET /batch/status/{batch_id}</code> - Check batch progress</li>
718
  </ul>
719
+ </div>
720
+
721
+ <div class="section">
722
+ <h3>πŸ” How to Export Cookies</h3>
723
+ <ol>
724
+ <li>Install a cookie export extension (like "Get cookies.txt LOCALLY")</li>
725
+ <li>Go to YouTube and make sure you're logged in</li>
726
+ <li>Use the extension to export cookies in Netscape format</li>
727
+ <li>Save the file and upload it here</li>
728
+ </ol>
729
  </div>
730
 
731
  <div style="text-align: center;">
 
734
  <a href="/cookie-status" class="btn">πŸͺ Cookie Status</a>
735
  </div>
736
  </div>
737
+
738
+ <script>
739
+ document.getElementById('cookieForm').addEventListener('submit', async function(e) {
740
+ e.preventDefault();
741
+
742
+ const formData = new FormData();
743
+ const fileInput = document.getElementById('cookieFile');
744
+ formData.append('cookie_file', fileInput.files[0]);
745
+
746
+ const resultDiv = document.getElementById('uploadResult');
747
+ resultDiv.innerHTML = '<p>Uploading...</p>';
748
+
749
+ try {
750
+ const response = await fetch('/upload-cookies', {
751
+ method: 'POST',
752
+ body: formData
753
+ });
754
+
755
+ const result = await response.json();
756
+
757
+ if (result.success) {
758
+ resultDiv.innerHTML = '<div class="success"><strong>βœ… Success!</strong> ' + result.message + '</div>';
759
+ } else {
760
+ resultDiv.innerHTML = '<div class="warning"><strong>❌ Error:</strong> ' + result.message + '</div>';
761
+ }
762
+ } catch (error) {
763
+ resultDiv.innerHTML = '<div class="warning"><strong>❌ Error:</strong> Failed to upload cookies</div>';
764
+ }
765
+ });
766
+ </script>
767
  </body>
768
  </html>
769
  """