🎉 | Project added
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 3m36s

This commit is contained in:
2026-05-31 23:03:55 +03:00
parent 336616de82
commit c0f1044144
10 changed files with 4334 additions and 0 deletions

62
main.py Normal file
View File

@@ -0,0 +1,62 @@
#!/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()