🐛 | Fix tests
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m44s

This commit is contained in:
2026-06-03 19:05:17 +03:00
parent 93f5239ef7
commit 2870f790bd
4 changed files with 298 additions and 23 deletions

View File

@@ -40,8 +40,29 @@ import threading
from typing import Optional
import yt_dlp
from PySide6.QtCore import QObject, QThread, Signal, Slot, QUrl
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
# ═══════════════════════════════════════════════════════════════════════════
# Qt imports are guarded so the module can be imported for its pure helper
# functions (``_best_thumbnail``, ``_build_song_dict``, etc.) even when the
# system lacks PulseAudio / EGL / other Qt multimedia native libraries.
# The player classes (``AudioPlayer``, ``DownloadWorker``, ``SearchWorker``)
# will **not** be functional in that case — they need the real Qt runtime.
# ═══════════════════════════════════════════════════════════════════════════
_HAS_QT = True
try:
from PySide6.QtCore import QObject, QThread, Signal, Slot, QUrl
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
except (ImportError, OSError):
_HAS_QT = False
QObject = object
QThread = type("QThread", (), {"start": lambda s: None,
"quit": lambda s: None,
"wait": lambda s, t=3000: True})
Signal = lambda *a: lambda f: f
Slot = lambda *a: lambda f: f
QUrl = None
QMediaPlayer = None
QAudioOutput = None
log = logging.getLogger("tunetti.player")