From dae0d525c742fce1693eaa246094770e7832252e Mon Sep 17 00:00:00 2001 From: Antigravity Date: Mon, 5 Oct 2026 12:40:58 +0300 Subject: [PATCH] chore: disable legacy audio proxy and hide audio controls --- app/dictionary.py | 11 +++----- app/main.py | 26 +++--------------- app/static/index.html | 12 ++++----- app/static/js/app.js | 62 ++++++------------------------------------- 4 files changed, 21 insertions(+), 90 deletions(-) diff --git a/app/dictionary.py b/app/dictionary.py index 61472cb..39c4161 100644 --- a/app/dictionary.py +++ b/app/dictionary.py @@ -46,7 +46,7 @@ async def fetch_wiktionary_wikitext(word: str) -> Dict[str, Any]: return { "ipa": ipa_cleaned, - "audio": audio_matches, + "audio": [], "ru_translations": ru_cleaned } except Exception: @@ -232,12 +232,9 @@ async def lookup_term(query: str) -> Dict[str, Any]: elif d_muse.get("ipa"): result["phonetic"] = d_muse["ipa"] - # 2. Audio URL / File - if free_dict.get("audio_url"): - result["audio_url"] = free_dict["audio_url"] - elif w_wiki.get("audio"): - result["audio_file"] = w_wiki["audio"][0] - result["audio_url"] = f"/api/audio?file={urllib.parse.quote(result['audio_file'])}" + # 2. Audio URL / File (Disabled) + result["audio_file"] = "" + result["audio_url"] = "" # 3. Part of Speech if w_defs.get("parts_of_speech"): diff --git a/app/main.py b/app/main.py index 66c3676..7d85a36 100644 --- a/app/main.py +++ b/app/main.py @@ -285,29 +285,9 @@ async def api_lookup( @app.api_route("/api/audio", methods=["GET", "HEAD"]) -async def api_audio_proxy(url: str = Query(..., min_length=1), user: dict = Depends(require_user)): - try: - parsed = urllib.parse.urlparse(url) - if parsed.scheme not in ("http", "https"): - raise HTTPException(status_code=400, detail="Invalid audio URL scheme") - if not parsed.netloc: - raise HTTPException(status_code=400, detail="Invalid audio host") - except Exception: - raise HTTPException(status_code=400, detail="Malformed audio URL") - - try: - async with httpx.AsyncClient(timeout=10.0, follow_redirects=True) as client: - audio_resp = await client.get(url, headers={"User-Agent": USER_AGENT}) - if audio_resp.status_code != 200: - raise HTTPException(status_code=audio_resp.status_code, detail="Audio upstream error") - media_type = audio_resp.headers.get("Content-Type", "audio/mpeg") - return Response( - content=audio_resp.content, - media_type=media_type, - headers={"Cache-Control": "public, max-age=604800"}, - ) - except Exception as e: - raise HTTPException(status_code=502, detail=f"Failed to fetch audio: {str(e)}") +async def api_audio_proxy(): + # Audio feature disabled + return Response(status_code=204) # --------------------------------------------------------------------------- diff --git a/app/static/index.html b/app/static/index.html index 5343b89..f365d7c 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -125,7 +125,7 @@

Word

/wɜːd/ - +
Noun @@ -236,7 +236,7 @@ - + @@ -290,7 +290,7 @@

reluctant

/rɪˈlʌktənt/ - +
@@ -311,7 +311,7 @@

reluctant

- +
неохотный, нежелающий
@@ -372,7 +372,7 @@

word

- +
@@ -588,7 +588,7 @@
diff --git a/app/static/js/app.js b/app/static/js/app.js index e2a73e2..73cf0d3 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -330,16 +330,11 @@ document.addEventListener('DOMContentLoaded', () => { }); // ----------------------------------------------------------------------- - // Audio Player Helper + // Audio Player Helper (Disabled) // ----------------------------------------------------------------------- function playAudio(url) { - if (!url) return; - try { - globalAudioPlayer.src = url; - globalAudioPlayer.play().catch(e => console.log('Audio playback error:', e)); - } catch (e) { - console.log('Audio error:', e); - } + // Audio playback disabled + return; } // ----------------------------------------------------------------------- @@ -576,15 +571,7 @@ document.addEventListener('DOMContentLoaded', () => { resPhonetic.textContent = data.phonetic || ''; resPhonetic.style.display = data.phonetic ? 'inline-block' : 'none'; resPos.textContent = data.part_of_speech || 'Phrase'; - - if (data.audio_url) { - audioPlayBtn.classList.remove('hidden'); - audioPlayBtn.onclick = () => playAudio(data.audio_url); - // Auto play once - playAudio(data.audio_url); - } else { - audioPlayBtn.classList.add('hidden'); - } + audioPlayBtn.classList.add('hidden'); if (data.definition_en) { resDefinition.textContent = data.definition_en; @@ -761,7 +748,6 @@ document.addEventListener('DOMContentLoaded', () => { ${escapeHtml(c.term)} ${c.phonetic ? `${escapeHtml(c.phonetic)}` : ''} ${c.part_of_speech ? `${escapeHtml(c.part_of_speech)}` : ''} - ${c.audio_url ? `` : ''}
@@ -779,15 +765,6 @@ document.addEventListener('DOMContentLoaded', () => {
`; - // Inline audio button - const audioBtn = cardEl.querySelector('.audio-inline-btn'); - if (audioBtn) { - audioBtn.addEventListener('click', (e) => { - e.stopPropagation(); - playAudio(decodeURIComponent(audioBtn.dataset.audio)); - }); - } - // Edit button cardEl.querySelector('.edit-card-btn').addEventListener('click', (e) => { e.stopPropagation(); @@ -1106,15 +1083,8 @@ document.addEventListener('DOMContentLoaded', () => { fcBackNotes.textContent = card.notes || ''; fcBackNotesBox.style.display = card.notes ? 'block' : 'none'; - if (card.audio_url) { - fcFrontAudioBtn.style.display = 'inline-flex'; - fcBackAudioBtn.style.display = 'inline-flex'; - fcFrontAudioBtn.onclick = (e) => { e.stopPropagation(); playAudio(card.audio_url); }; - fcBackAudioBtn.onclick = (e) => { e.stopPropagation(); playAudio(card.audio_url); }; - } else { - fcFrontAudioBtn.style.display = 'none'; - fcBackAudioBtn.style.display = 'none'; - } + fcFrontAudioBtn.style.display = 'none'; + fcBackAudioBtn.style.display = 'none'; } function flipFlashcard() { @@ -1123,11 +1093,6 @@ document.addEventListener('DOMContentLoaded', () => { flashcardInner.classList.add('is-flipped'); fcRatingBar.classList.remove('hidden'); fcFlipBtnWrap.style.display = 'none'; - - const card = srsQueue[srsCurrentIndex]; - if (card && card.audio_url) { - playAudio(card.audio_url); - } } flashcardFlipWrap.addEventListener('click', flipFlashcard); @@ -1186,13 +1151,7 @@ document.addEventListener('DOMContentLoaded', () => { quizContextHint.classList.add('hidden'); } - if (card.audio_url) { - quizAudioBtn.classList.remove('hidden'); - quizAudioBtn.onclick = () => playAudio(card.audio_url); - playAudio(card.audio_url); - } else { - quizAudioBtn.classList.add('hidden'); - } + quizAudioBtn.classList.add('hidden'); // Generate 4 options: target + 3 random from other cards or presets const correctText = card.translation; @@ -2000,12 +1959,7 @@ document.addEventListener('DOMContentLoaded', () => { popupLoading.classList.add('hidden'); popupContent.classList.remove('hidden'); - if (data.audio_url) { - popupAudioBtn.classList.remove('hidden'); - popupAudioBtn.onclick = () => playAudio(data.audio_url); - } else { - popupAudioBtn.classList.add('hidden'); - } + popupAudioBtn.classList.add('hidden'); } else { popupTranslation.textContent = 'Ошибка перевода'; popupLoading.classList.add('hidden');