Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>YouTube Study Notes AI</title> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| min-height: 100vh; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| padding: 20px; | |
| } | |
| .container { | |
| background: rgba(255, 255, 255, 0.95); | |
| backdrop-filter: blur(10px); | |
| border-radius: 24px; | |
| padding: 40px; | |
| max-width: 800px; | |
| width: 100%; | |
| box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); | |
| } | |
| .header { | |
| text-align: center; | |
| margin-bottom: 40px; | |
| } | |
| .header h1 { | |
| font-size: 2.5em; | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| background-clip: text; | |
| margin-bottom: 10px; | |
| } | |
| .header p { | |
| color: #666; | |
| font-size: 1.1em; | |
| } | |
| .input-section { | |
| margin-bottom: 30px; | |
| } | |
| .input-group { | |
| display: flex; | |
| gap: 10px; | |
| margin-bottom: 15px; | |
| } | |
| input[type="text"] { | |
| flex: 1; | |
| padding: 16px 20px; | |
| border: 2px solid #e0e0e0; | |
| border-radius: 12px; | |
| font-size: 1em; | |
| font-family: 'Inter', sans-serif; | |
| transition: all 0.3s ease; | |
| } | |
| input[type="text"]:focus { | |
| outline: none; | |
| border-color: #667eea; | |
| box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1); | |
| } | |
| .btn { | |
| padding: 16px 32px; | |
| border: none; | |
| border-radius: 12px; | |
| font-size: 1em; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| font-family: 'Inter', sans-serif; | |
| } | |
| .btn-primary { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| } | |
| .btn-primary:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4); | |
| } | |
| .btn-primary:disabled { | |
| opacity: 0.6; | |
| cursor: not-allowed; | |
| transform: none; | |
| } | |
| .status-section { | |
| background: #f8f9fa; | |
| border-radius: 16px; | |
| padding: 20px; | |
| margin-bottom: 30px; | |
| display: none; | |
| } | |
| .status-section.active { | |
| display: block; | |
| } | |
| .status-header { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| margin-bottom: 15px; | |
| } | |
| .status-icon { | |
| width: 24px; | |
| height: 24px; | |
| border-radius: 50%; | |
| border: 3px solid #667eea; | |
| border-top-color: transparent; | |
| animation: spin 1s linear infinite; | |
| } | |
| @keyframes spin { | |
| to { transform: rotate(360deg); } | |
| } | |
| .status-text { | |
| font-weight: 600; | |
| color: #333; | |
| } | |
| .progress-bar { | |
| width: 100%; | |
| height: 8px; | |
| background: #e0e0e0; | |
| border-radius: 4px; | |
| overflow: hidden; | |
| } | |
| .progress-fill { | |
| height: 100%; | |
| background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); | |
| width: 0%; | |
| transition: width 0.3s ease; | |
| } | |
| .video-info { | |
| margin-top: 15px; | |
| padding-top: 15px; | |
| border-top: 1px solid #e0e0e0; | |
| } | |
| .video-title { | |
| font-weight: 600; | |
| color: #333; | |
| margin-bottom: 5px; | |
| } | |
| .notes-section { | |
| display: none; | |
| } | |
| .notes-section.active { | |
| display: block; | |
| } | |
| .notes-preview { | |
| background: #ffffff; | |
| border: 2px solid #e0e0e0; | |
| border-radius: 16px; | |
| padding: 30px; | |
| max-height: 500px; | |
| overflow-y: auto; | |
| margin-bottom: 20px; | |
| } | |
| .notes-preview h1 { | |
| color: #667eea; | |
| margin-bottom: 20px; | |
| } | |
| .notes-preview h2 { | |
| color: #764ba2; | |
| margin-top: 25px; | |
| margin-bottom: 15px; | |
| } | |
| .notes-preview ul { | |
| margin-left: 20px; | |
| margin-bottom: 15px; | |
| } | |
| .notes-preview li { | |
| margin-bottom: 8px; | |
| line-height: 1.6; | |
| } | |
| .notes-preview strong { | |
| color: #667eea; | |
| } | |
| .download-btn { | |
| width: 100%; | |
| } | |
| .error-message { | |
| background: #fee; | |
| border: 2px solid #fcc; | |
| border-radius: 12px; | |
| padding: 15px; | |
| color: #c33; | |
| margin-bottom: 20px; | |
| display: none; | |
| } | |
| .error-message.active { | |
| display: block; | |
| } | |
| .example-links { | |
| text-align: center; | |
| margin-top: 20px; | |
| color: #666; | |
| font-size: 0.9em; | |
| } | |
| .example-links a { | |
| color: #667eea; | |
| text-decoration: none; | |
| font-weight: 500; | |
| } | |
| .example-links a:hover { | |
| text-decoration: underline; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="header"> | |
| <h1>📚 YouTube Study Notes AI</h1> | |
| <p>Transform educational videos into structured study notes</p> | |
| </div> | |
| <div class="error-message" id="errorMessage"></div> | |
| <div class="input-section"> | |
| <div class="input-group"> | |
| <input | |
| type="text" | |
| id="youtubeUrl" | |
| placeholder="Paste YouTube video URL here..." | |
| value="" | |
| > | |
| <button class="btn btn-primary" id="generateBtn" onclick="generateNotes()"> | |
| Generate Notes | |
| </button> | |
| </div> | |
| <div class="example-links"> | |
| Try with a short educational video for best results | |
| </div> | |
| </div> | |
| <div class="status-section" id="statusSection"> | |
| <div class="status-header"> | |
| <div class="status-icon" id="statusIcon"></div> | |
| <div class="status-text" id="statusText">Processing...</div> | |
| </div> | |
| <div class="progress-bar"> | |
| <div class="progress-fill" id="progressFill"></div> | |
| </div> | |
| <div class="video-info" id="videoInfo" style="display: none;"> | |
| <div class="video-title" id="videoTitle"></div> | |
| </div> | |
| </div> | |
| <div class="notes-section" id="notesSection"> | |
| <div class="notes-preview" id="notesPreview"></div> | |
| <button class="btn btn-primary download-btn" id="downloadBtn" onclick="downloadNotes()"> | |
| Download Notes (Markdown) | |
| </button> | |
| </div> | |
| </div> | |
| <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> | |
| <script> | |
| const API_URL = 'http://localhost:8000'; | |
| let currentTaskId = null; | |
| let statusCheckInterval = null; | |
| function showError(message) { | |
| const errorEl = document.getElementById('errorMessage'); | |
| errorEl.textContent = message; | |
| errorEl.classList.add('active'); | |
| } | |
| function hideError() { | |
| document.getElementById('errorMessage').classList.remove('active'); | |
| } | |
| function updateStatus(status, progress, message, videoTitle = null) { | |
| document.getElementById('statusText').textContent = message; | |
| document.getElementById('progressFill').style.width = progress + '%'; | |
| if (videoTitle) { | |
| document.getElementById('videoTitle').textContent = videoTitle; | |
| document.getElementById('videoInfo').style.display = 'block'; | |
| } | |
| } | |
| async function generateNotes() { | |
| const url = document.getElementById('youtubeUrl').value.trim(); | |
| if (!url) { | |
| showError('Please enter a YouTube URL'); | |
| return; | |
| } | |
| hideError(); | |
| // Show status section | |
| document.getElementById('statusSection').classList.add('active'); | |
| document.getElementById('notesSection').classList.remove('active'); | |
| // Disable button | |
| const btn = document.getElementById('generateBtn'); | |
| btn.disabled = true; | |
| btn.textContent = 'Processing...'; | |
| try { | |
| // Start note generation | |
| const response = await fetch(`${API_URL}/generate-notes`, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ | |
| youtube_url: url, | |
| language: 'en' | |
| }) | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Failed to start processing'); | |
| } | |
| const data = await response.json(); | |
| currentTaskId = data.task_id; | |
| // Start checking status | |
| statusCheckInterval = setInterval(checkStatus, 2000); | |
| } catch (error) { | |
| showError('Error: ' + error.message); | |
| btn.disabled = false; | |
| btn.textContent = 'Generate Notes'; | |
| document.getElementById('statusSection').classList.remove('active'); | |
| } | |
| } | |
| async function checkStatus() { | |
| if (!currentTaskId) return; | |
| try { | |
| const response = await fetch(`${API_URL}/status/${currentTaskId}`); | |
| if (!response.ok) { | |
| throw new Error('Failed to check status'); | |
| } | |
| const data = await response.json(); | |
| updateStatus( | |
| data.status, | |
| data.progress || 0, | |
| data.message, | |
| data.video_title | |
| ); | |
| if (data.status === 'completed') { | |
| // Stop checking | |
| clearInterval(statusCheckInterval); | |
| // Load and display notes | |
| await loadNotes(); | |
| // Reset button | |
| const btn = document.getElementById('generateBtn'); | |
| btn.disabled = false; | |
| btn.textContent = 'Generate Notes'; | |
| } else if (data.status === 'failed') { | |
| // Stop checking | |
| clearInterval(statusCheckInterval); | |
| showError('Processing failed: ' + data.message); | |
| // Reset button | |
| const btn = document.getElementById('generateBtn'); | |
| btn.disabled = false; | |
| btn.textContent = 'Generate Notes'; | |
| document.getElementById('statusSection').classList.remove('active'); | |
| } | |
| } catch (error) { | |
| clearInterval(statusCheckInterval); | |
| showError('Error checking status: ' + error.message); | |
| } | |
| } | |
| async function loadNotes() { | |
| try { | |
| const response = await fetch(`${API_URL}/download/${currentTaskId}`); | |
| if (!response.ok) { | |
| throw new Error('Failed to load notes'); | |
| } | |
| const markdown = await response.text(); | |
| // Render markdown to HTML | |
| const html = marked.parse(markdown); | |
| document.getElementById('notesPreview').innerHTML = html; | |
| // Show notes section | |
| document.getElementById('notesSection').classList.add('active'); | |
| document.getElementById('statusSection').classList.remove('active'); | |
| } catch (error) { | |
| showError('Error loading notes: ' + error.message); | |
| } | |
| } | |
| function downloadNotes() { | |
| if (!currentTaskId) return; | |
| window.open(`${API_URL}/download/${currentTaskId}`, '_blank'); | |
| } | |
| // Enter key support | |
| document.getElementById('youtubeUrl').addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') { | |
| generateNotes(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |