Files
youtube/templates/index.html

407 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Concert Splitter</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 600px;
width: 100%;
padding: 40px;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 28px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #555;
font-weight: 500;
font-size: 14px;
}
input[type="text"], textarea {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s;
}
input[type="text"]:focus, textarea:focus {
outline: none;
border-color: #667eea;
}
textarea {
resize: vertical;
min-height: 120px;
font-family: 'Courier New', monospace;
}
.helper-text {
font-size: 12px;
color: #888;
margin-top: 5px;
}
button {
width: 100%;
padding: 15px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.loading {
display: none;
text-align: center;
padding: 30px;
}
.loading.active {
display: block;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
color: #666;
font-size: 14px;
}
.results {
display: none;
margin-top: 30px;
padding: 20px;
background: #f8f9fa;
border-radius: 10px;
}
.results.active {
display: block;
}
.results h3 {
color: #333;
margin-bottom: 15px;
font-size: 18px;
}
.result-info {
background: white;
padding: 15px;
border-radius: 8px;
margin-bottom: 15px;
}
.result-row {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
font-size: 14px;
}
.result-label {
color: #666;
font-weight: 500;
}
.result-value {
color: #333;
}
.tracks-list {
max-height: 300px;
overflow-y: auto;
}
.track-item {
background: white;
padding: 12px;
border-radius: 6px;
margin-bottom: 8px;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
}
.track-filename {
color: #333;
flex: 1;
}
.track-status {
padding: 4px 12px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.track-status.created {
background: #d4edda;
color: #155724;
}
.track-status.skipped {
background: #fff3cd;
color: #856404;
}
.error {
display: none;
margin-top: 20px;
padding: 15px;
background: #f8d7da;
color: #721c24;
border-radius: 8px;
font-size: 14px;
}
.error.active {
display: block;
}
</style>
</head>
<body>
<div class="container">
<h1>🎵 YouTube Concert Splitter</h1>
<p class="subtitle">Download and split concerts into individual tracks</p>
<form id="splitForm">
<div class="form-group">
<label for="youtube_url">YouTube URL *</label>
<input
type="text"
id="youtube_url"
name="youtube_url"
placeholder="https://www.youtube.com/watch?v=..."
required
>
</div>
<div class="form-group">
<label for="artist">Artist Name *</label>
<input
type="text"
id="artist"
name="artist"
placeholder="Artist Name"
required
>
</div>
<div class="form-group">
<label for="album">Album/Concert Name *</label>
<input
type="text"
id="album"
name="album"
placeholder="Live at Madison Square Garden 2024"
required
>
</div>
<div class="form-group">
<label for="setlist">Setlist (optional - leave empty for single track)</label>
<textarea
id="setlist"
name="setlist"
placeholder="0:00 Opening Song&#10;3:45 Second Track&#10;7:20 Third Song&#10;..."
></textarea>
<div class="helper-text">Format: TIMESTAMP TITLE (one per line). Leave empty to save the entire video as a single track.</div>
</div>
<button type="submit">Split Concert</button>
</form>
<div class="loading" id="loading">
<div class="spinner"></div>
<div class="loading-text">Processing... This may take a few minutes.</div>
<div class="loading-text" style="margin-top: 10px; font-size: 12px;">Please be patient, downloading and converting can take time.</div>
</div>
<div class="error" id="error"></div>
<div class="results" id="results">
<h3>✅ Success!</h3>
<div class="result-info">
<div class="result-row">
<span class="result-label">Album:</span>
<span class="result-value" id="resultAlbum"></span>
</div>
<div class="result-row">
<span class="result-label">Artist:</span>
<span class="result-value" id="resultArtist"></span>
</div>
<div class="result-row">
<span class="result-label">Total Tracks:</span>
<span class="result-value" id="resultTotal"></span>
</div>
<div class="result-row">
<span class="result-label">Created:</span>
<span class="result-value" id="resultCreated"></span>
</div>
<div class="result-row">
<span class="result-label">Skipped:</span>
<span class="result-value" id="resultSkipped"></span>
</div>
<div class="result-row">
<span class="result-label">Output Directory:</span>
<span class="result-value" id="resultDir"></span>
</div>
</div>
<h3 style="margin-top: 20px;">Tracks</h3>
<div class="tracks-list" id="tracksList"></div>
</div>
</div>
<script>
document.getElementById('splitForm').addEventListener('submit', async (e) => {
e.preventDefault();
const form = e.target;
const formData = new FormData(form);
// Show loading, hide results and errors
document.getElementById('loading').classList.add('active');
document.getElementById('results').classList.remove('active');
document.getElementById('error').classList.remove('active');
form.querySelector('button').disabled = true;
try {
// Increase timeout to 10 minutes (600000ms)
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 600000);
const response = await fetch('/split', {
method: 'POST',
body: formData,
signal: controller.signal
});
clearTimeout(timeoutId);
// Check if response is JSON
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
throw new Error('Server returned non-JSON response. Check server logs.');
}
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || 'Unknown error occurred');
}
if (data.success) {
// Display results
document.getElementById('resultAlbum').textContent = data.album;
document.getElementById('resultArtist').textContent = data.artist;
document.getElementById('resultTotal').textContent = data.total_tracks;
document.getElementById('resultCreated').textContent = data.created_count;
document.getElementById('resultSkipped').textContent = data.skipped_count;
document.getElementById('resultDir').textContent = data.output_dir;
// Display tracks
const tracksList = document.getElementById('tracksList');
tracksList.innerHTML = '';
data.tracks.forEach(track => {
const trackItem = document.createElement('div');
trackItem.className = 'track-item';
trackItem.innerHTML = `
<span class="track-filename">${track.filename}</span>
<span class="track-status ${track.status}">${track.status}</span>
`;
tracksList.appendChild(trackItem);
});
document.getElementById('results').classList.add('active');
} else {
throw new Error(data.error || 'Processing failed');
}
} catch (error) {
console.error('Error:', error);
const errorDiv = document.getElementById('error');
if (error.name === 'AbortError') {
errorDiv.textContent = 'Request timed out. The download is taking too long. Please try with a shorter video or check your internet connection.';
} else {
errorDiv.textContent = error.message || 'An error occurred. Check the console for details.';
}
errorDiv.classList.add('active');
} finally {
document.getElementById('loading').classList.remove('active');
form.querySelector('button').disabled = false;
}
});
</script>
</body>
</html>