fix the timeout waiting from web client
This commit is contained in:
@@ -1,166 +1,124 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>YouTube Concert Splitter</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
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: #fff;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 20px rgba(0,0,0,0.2);
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
max-width: 700px;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 10px;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
font-size: 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
color: #666;
|
||||
margin-bottom: 30px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form-group.full-width {
|
||||
grid-column: 1 / -1;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #444;
|
||||
color: #555;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
input[type="text"], textarea {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
input[type="text"]:focus {
|
||||
input[type="text"]:focus, textarea:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
font-family: 'Courier New', monospace;
|
||||
resize: vertical;
|
||||
min-height: 200px;
|
||||
transition: border-color 0.3s;
|
||||
box-sizing: border-box;
|
||||
min-height: 120px;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
textarea:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.help-text {
|
||||
.helper-text {
|
||||
font-size: 12px;
|
||||
color: #777;
|
||||
color: #888;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 14px 30px;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
button:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
background: #ccc;
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.loader-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.7);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.loader-content {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
.loading {
|
||||
display: none;
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
margin: 0 20px;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.loading.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
border: 6px solid #f3f3f3;
|
||||
border-top: 6px solid #667eea;
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid #667eea;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 20px;
|
||||
}
|
||||
@@ -170,401 +128,280 @@
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.loader-text {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.loader-subtext {
|
||||
font-size: 14px;
|
||||
.loading-text {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 15px;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #fee;
|
||||
color: #c33;
|
||||
border: 1px solid #fcc;
|
||||
}
|
||||
|
||||
.success {
|
||||
background: #efe;
|
||||
color: #3a3;
|
||||
border: 1px solid #cfc;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background: #fef7e0;
|
||||
color: #8a6d3b;
|
||||
border: 1px solid #faebcc;
|
||||
}
|
||||
|
||||
.results {
|
||||
margin-top: 20px;
|
||||
display: none;
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #e0e0e0;
|
||||
background: #f8f9fa;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.results.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.results h3 {
|
||||
margin-top: 0;
|
||||
color: #333;
|
||||
margin-bottom: 15px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.track-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.track-list li {
|
||||
padding: 8px;
|
||||
.result-info {
|
||||
background: white;
|
||||
margin-bottom: 5px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: #555;
|
||||
word-break: break-word;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.track-list li.skipped {
|
||||
background: #fff9e6;
|
||||
.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;
|
||||
}
|
||||
|
||||
.track-list li.created {
|
||||
background: #e8f5e9;
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
.download-info {
|
||||
margin-top: 15px;
|
||||
.error {
|
||||
display: none;
|
||||
margin-top: 20px;
|
||||
padding: 15px;
|
||||
background: #e8f4f8;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid #2196F3;
|
||||
word-break: break-all;
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.download-info strong {
|
||||
color: #1976D2;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-top: 15px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
padding: 10px;
|
||||
background: white;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
/* Mobile Responsive Styles */
|
||||
@media screen and (max-width: 768px) {
|
||||
body {
|
||||
padding: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 13px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
textarea {
|
||||
font-size: 16px; /* Prevents zoom on iOS */
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
min-height: 150px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.help-text {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 12px 20px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.loader-content {
|
||||
padding: 30px 20px;
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
.loader-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.loader-subtext {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.message {
|
||||
font-size: 13px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.results {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.results h3 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.results h4 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stats {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
min-width: 80px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.track-list li {
|
||||
font-size: 12px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.download-info {
|
||||
font-size: 12px;
|
||||
padding: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 480px) {
|
||||
.container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 18px;
|
||||
}
|
||||
.error.active {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🎵 YouTube Concert Splitter</h1>
|
||||
<p class="subtitle">Download and split concert videos into individual tracks</p>
|
||||
<div class="container">
|
||||
<h1>🎵 YouTube Concert Splitter</h1>
|
||||
<p class="subtitle">Download and split concerts into individual tracks</p>
|
||||
|
||||
<form id="splitterForm">
|
||||
<div class="form-group full-width">
|
||||
<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-row">
|
||||
<form id="splitForm">
|
||||
<div class="form-group">
|
||||
<label for="artist">Artist Name:</label>
|
||||
<input type="text"
|
||||
id="artist"
|
||||
name="artist"
|
||||
placeholder="e.g., Bob Dylan"
|
||||
required>
|
||||
<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="album">Album Name:</label>
|
||||
<input type="text"
|
||||
id="album"
|
||||
name="album"
|
||||
placeholder="e.g., Live at Madison Square Garden"
|
||||
required>
|
||||
<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 3:45 Second Track 7:20 Third Song ..."
|
||||
></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="form-group full-width">
|
||||
<label for="setlist">Setlist (timestamps and track titles) - Optional:</label>
|
||||
<textarea id="setlist"
|
||||
name="setlist"
|
||||
placeholder="0:00 Opening Song 3:45 Second Track 7:30 Third Song (Leave empty to download as single track - no splitting)"></textarea>
|
||||
<div class="help-text">
|
||||
<strong>Split Mode:</strong> Enter "TIMESTAMP TRACK_TITLE" per line (e.g., "0:00 Song Name")<br>
|
||||
<strong>Single Mode:</strong> Leave this field completely empty to download entire video as one track
|
||||
<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>
|
||||
|
||||
<button type="submit" id="submitBtn">Split Concert</button>
|
||||
</form>
|
||||
|
||||
<div id="message"></div>
|
||||
<div id="results"></div>
|
||||
</div>
|
||||
|
||||
<div id="loader" class="loader-overlay" style="display: none;">
|
||||
<div class="loader-content">
|
||||
<div class="spinner"></div>
|
||||
<div class="loader-text">Processing...</div>
|
||||
<div class="loader-subtext">Downloading and splitting tracks. This may take several minutes.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('splitterForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
<script>
|
||||
document.getElementById('splitForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// Clear previous messages
|
||||
document.getElementById('message').innerHTML = '';
|
||||
document.getElementById('results').innerHTML = '';
|
||||
const form = e.target;
|
||||
const formData = new FormData(form);
|
||||
|
||||
// Show loader
|
||||
document.getElementById('loader').style.display = 'flex';
|
||||
document.getElementById('submitBtn').disabled = true;
|
||||
// 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;
|
||||
|
||||
const url = document.getElementById('youtube_url').value;
|
||||
const artist = document.getElementById('artist').value;
|
||||
const album = document.getElementById('album').value;
|
||||
const setlist = document.getElementById('setlist').value;
|
||||
try {
|
||||
// Increase timeout to 10 minutes (600000ms)
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 600000);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('youtube_url', url);
|
||||
formData.append('artist', artist);
|
||||
formData.append('album', album);
|
||||
formData.append('setlist', setlist);
|
||||
const response = await fetch('/split', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
fetch('/split', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById('loader').style.display = 'none';
|
||||
document.getElementById('submitBtn').disabled = false;
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (data.error) {
|
||||
document.getElementById('message').innerHTML =
|
||||
`<div class="message error"><strong>Error:</strong> ${data.error}</div>`;
|
||||
} else {
|
||||
// Display success message with stats
|
||||
let html = '';
|
||||
|
||||
if (data.skipped_count > 0) {
|
||||
html += `<div class="message warning"><strong>Note:</strong> ${data.skipped_count} track(s) already existed and were skipped.</div>`;
|
||||
}
|
||||
|
||||
html += `<div class="message success"><strong>Success!</strong> Processing complete.</div>`;
|
||||
html += `<div class="results">`;
|
||||
html += `<h3>🎸 ${data.artist} - ${data.album}</h3>`;
|
||||
|
||||
html += `<div class="stats">`;
|
||||
html += `<div class="stat-item">`;
|
||||
html += `<div class="stat-number">${data.created_count}</div>`;
|
||||
html += `<div class="stat-label">Created</div>`;
|
||||
html += `</div>`;
|
||||
html += `<div class="stat-item">`;
|
||||
html += `<div class="stat-number">${data.skipped_count}</div>`;
|
||||
html += `<div class="stat-label">Skipped</div>`;
|
||||
html += `</div>`;
|
||||
html += `<div class="stat-item">`;
|
||||
html += `<div class="stat-number">${data.total_tracks}</div>`;
|
||||
html += `<div class="stat-label">Total Tracks</div>`;
|
||||
html += `</div>`;
|
||||
html += `</div>`;
|
||||
|
||||
html += `<div class="download-info"><strong>📁 Output Directory:</strong> ${data.output_dir}</div>`;
|
||||
html += `<h4>Track Details:</h4>`;
|
||||
html += `<ul class="track-list">`;
|
||||
data.tracks.forEach(track => {
|
||||
const className = track.status === 'created' ? 'created' : 'skipped';
|
||||
const icon = track.status === 'created' ? '✓' : '⊘';
|
||||
const statusText = track.status === 'created' ? 'Created' : 'Already exists';
|
||||
html += `<li class="${className}">${icon} ${track.filename} <em>(${statusText})</em></li>`;
|
||||
});
|
||||
html += `</ul>`;
|
||||
html += `</div>`;
|
||||
document.getElementById('results').innerHTML = html;
|
||||
// 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.');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('loader').style.display = 'none';
|
||||
document.getElementById('submitBtn').disabled = false;
|
||||
document.getElementById('message').innerHTML =
|
||||
`<div class="message error"><strong>Error:</strong> ${error.message}</div>`;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
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>
|
||||
Reference in New Issue
Block a user