All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 3m36s
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
||
"""Tunetti – YouTube Music Player.
|
||
|
||
Usage:
|
||
python main.py # normal mode
|
||
TUNETTI_VERBOSE=1 python main.py # full debug output
|
||
"""
|
||
|
||
import logging
|
||
import os
|
||
import sys
|
||
|
||
|
||
# ── Detect verbose mode from env ────────────────────────────────────────────
|
||
VERBOSE = os.environ.get("TUNETTI_VERBOSE", "").strip() in ("1", "true", "yes")
|
||
|
||
|
||
_LOG_LEVEL = logging.DEBUG if VERBOSE else logging.INFO
|
||
_LOG_FORMAT = (
|
||
"%(asctime)s.%(msecs)03d %(levelname).1s %(name)s %(message)s"
|
||
if VERBOSE else
|
||
"%(levelname).1s %(name)s %(message)s"
|
||
)
|
||
|
||
logging.basicConfig(
|
||
level=_LOG_LEVEL,
|
||
format=_LOG_FORMAT,
|
||
datefmt="%H:%M:%S",
|
||
stream=sys.stderr,
|
||
)
|
||
|
||
|
||
# Suppress noisy Qt FFmpeg warnings — these fire constantly when
|
||
# YouTube streams end prematurely (expected behaviour with short-lived
|
||
# streaming tokens). The env-var approach is unreliable across Qt
|
||
# versions, so we set filter rules *after* QApplication is created.
|
||
# In verbose mode the filters are omitted so you can see FFmpeg internals.
|
||
_QT_LOG_RULES = "" if VERBOSE else """\
|
||
qt.multimedia.ffmpeg.demuxer=false
|
||
qt.multimedia.ffmpeg.io=false
|
||
qt.multimedia.ffmpeg.tls=false
|
||
qt.multimedia.backend=false
|
||
qt.multimedia=false
|
||
"""
|
||
|
||
|
||
def main() -> None:
|
||
from gui import run_gui
|
||
|
||
# Propagate verbose flag to the player module so yt-dlp also
|
||
# produces debug output.
|
||
if VERBOSE:
|
||
import player as _player_mod
|
||
_player_mod.VERBOSE = True
|
||
log = logging.getLogger("tunetti")
|
||
log.debug("Verbose mode enabled — yt-dlp and Qt FFmpeg logging active")
|
||
|
||
run_gui(extra_qt_log_rules=_QT_LOG_RULES)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|