does not work

This commit is contained in:
Andrey Kondratev
2025-08-27 18:37:44 +05:00
parent 3d6836dc30
commit 98787a382e
17 changed files with 9526 additions and 245 deletions

View File

@@ -10,20 +10,20 @@
<body>
<div class="container">
<header>
<h1><µ Quixotic</h1>
<p>0948 8 A:0G09 <C7K:C 87 YouTube</p>
<h1>🎵 Quixotic</h1>
<p>Найди и скачай музыку из YouTube</p>
</header>
<div class="search-section">
<div class="search-container">
<input type="text" id="searchInput" placeholder="2548B5 =0720=85 ?5A=8..." autocomplete="off">
<button id="searchBtn">=
<input type="text" id="searchInput" placeholder="Введите название песни..." autocomplete="off">
<button id="searchBtn">🔍</button>
</div>
</div>
<div id="loading" class="loading hidden">
<div class="spinner"></div>
<div class="spinner"></div>
<p>Поиск...</p>
</div>
<div id="results" class="results-container">
@@ -31,7 +31,7 @@
</div>
<div id="noResults" class="no-results hidden">
<div id="noResults" class="no-results hidden">
<p>Ничего не найдено. Попробуйте другой запрос.</p>
</div>
</div>

View File

@@ -100,10 +100,12 @@ class QuixoticApp {
}
async convertVideo(videoId, title) {
console.log('Convert video called:', { videoId, title });
const videoElement = event.currentTarget;
videoElement.classList.add('converting');
try {
console.log('Sending convert request...');
const response = await fetch('/api/convert', {
method: 'POST',
headers: {
@@ -116,29 +118,55 @@ class QuixoticApp {
})
});
console.log('Response status:', response.status);
if (!response.ok) {
throw new Error('Conversion failed');
throw new Error(`Conversion failed with status: ${response.status}`);
}
const data = await response.json();
console.log('Response data:', data);
if (this.tg) {
this.tg.sendData(JSON.stringify({
action: 'send_audio',
audioUrl: data.audioUrl,
title: title
}));
if (data.audioUrl) {
// MP3 conversion successful!
console.log('MP3 conversion successful:', data.audioUrl);
if (this.tg) {
// Send to Telegram chat
this.tg.sendData(JSON.stringify({
action: 'send_audio',
audioUrl: data.audioUrl,
title: title
}));
this.showMessage('✓ MP3 готов! Отправляем в чат...', 'success');
} else {
// For testing in browser - download file
const link = document.createElement('a');
link.href = data.audioUrl;
link.download = `${title}.mp3`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.showMessage('✓ MP3 скачан!', 'success');
}
} else {
// Fallback for testing without Telegram
window.open(data.audioUrl, '_blank');
// Should not happen since we removed fallbacks
throw new Error('No audio URL received');
}
} catch (error) {
console.error('Conversion error:', error);
if (this.tg) {
this.tg.showAlert('H81:0 ?@8 :>=25@B0F88. >?@>1C9B5 5I5 @07.');
} else {
alert('H81:0 ?@8 :>=25@B0F88. >?@>1C9B5 5I5 @07.');
// Show specific error message
let errorMsg = 'Ошибка конвертации. Попробуйте другое видео.';
if (error.message.includes('No audio URL')) {
errorMsg = 'Не удалось получить аудио файл.';
} else if (error.message.includes('410')) {
errorMsg = 'Видео недоступно для скачивания.';
} else if (error.message.includes('403')) {
errorMsg = 'Видео заблокировано для скачивания.';
}
this.showMessage(`${errorMsg}`, 'warning');
} finally {
videoElement.classList.remove('converting');
}
@@ -151,6 +179,30 @@ class QuixoticApp {
return `${mins}:${secs.toString().padStart(2, '0')}`;
}
showMessage(message, type = 'info') {
// Remove existing message if any
const existingMessage = document.querySelector('.status-message');
if (existingMessage) {
existingMessage.remove();
}
// Create message element
const messageEl = document.createElement('div');
messageEl.className = `status-message status-${type}`;
messageEl.textContent = message;
// Add to page
const container = document.querySelector('.container');
container.insertBefore(messageEl, container.firstChild);
// Auto-remove after 5 seconds
setTimeout(() => {
if (messageEl.parentNode) {
messageEl.remove();
}
}, 5000);
}
escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;

View File

@@ -113,6 +113,7 @@ header p {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.2s, box-shadow 0.2s;
cursor: pointer;
position: relative;
}
.video-item:hover {
@@ -178,7 +179,7 @@ header p {
}
.converting::after {
content: ">=25@B0F8O...";
content: "Converting to MP3...";
position: absolute;
top: 50%;
left: 50%;
@@ -190,6 +191,44 @@ header p {
font-size: 0.8rem;
}
.status-message {
padding: 12px 16px;
margin-bottom: 16px;
border-radius: 8px;
font-size: 0.9rem;
font-weight: 500;
animation: slideIn 0.3s ease-out;
}
.status-success {
background-color: #d4edda;
border: 1px solid #c3e6cb;
color: #155724;
}
.status-warning {
background-color: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
}
.status-info {
background-color: #d1ecf1;
border: 1px solid #bee5eb;
color: #0c5460;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 480px) {
.video-item {
flex-direction: column;