Web - 1
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
main_window.py — Linedance afspiller hovedvindue.
|
||||
"""
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
|
||||
@@ -565,9 +567,11 @@ class MainWindow(QMainWindow):
|
||||
pass
|
||||
|
||||
QTimer.singleShot(5000, self.start_background_scan)
|
||||
# Start AcoustID fingerprinting efter 60 sekunder hvis aktiveret
|
||||
if self._settings.get("acoustid_enabled", False):
|
||||
QTimer.singleShot(60000, self._start_acoustid)
|
||||
# Start AcoustID fingerprinting efter 10 sekunder hvis aktiveret
|
||||
acoustid_on = self._settings.get("acoustid_enabled", False)
|
||||
logger.info(f"AcoustID indstilling: {acoustid_on}")
|
||||
if acoustid_on:
|
||||
QTimer.singleShot(10000, self._start_acoustid)
|
||||
|
||||
def _start_acoustid(self):
|
||||
"""Start AcoustID fingerprinting i baggrunden."""
|
||||
@@ -590,7 +594,10 @@ class MainWindow(QMainWindow):
|
||||
f"AcoustID: {done}/{total} — {title}", 3000
|
||||
)
|
||||
|
||||
self._acoustid_worker.start(on_progress=on_progress)
|
||||
self._acoustid_worker.start(
|
||||
api_key=self._settings.get("acoustid_api_key", ""),
|
||||
on_progress=on_progress,
|
||||
)
|
||||
self._set_status("AcoustID fingerprinting startet i baggrunden", 4000)
|
||||
|
||||
def start_background_scan(self):
|
||||
|
||||
@@ -29,6 +29,7 @@ SETTINGS_KEY_PREV_DEVICE = "playback/audio_device_preview"
|
||||
SETTINGS_KEY_AFTER_SONG = "playback/after_song_mode"
|
||||
SETTINGS_KEY_AFTER_DELAY = "playback/after_song_delay"
|
||||
SETTINGS_KEY_ACOUSTID = "playback/acoustid_enabled"
|
||||
SETTINGS_KEY_ACOUSTID_KEY = "playback/acoustid_api_key"
|
||||
|
||||
|
||||
def load_settings() -> dict:
|
||||
@@ -51,7 +52,8 @@ def load_settings() -> dict:
|
||||
"audio_device_preview":s.value(SETTINGS_KEY_PREV_DEVICE, ""),
|
||||
"after_song_mode": s.value(SETTINGS_KEY_AFTER_SONG, "manual"),
|
||||
"after_song_delay": s.value(SETTINGS_KEY_AFTER_DELAY, 2, type=int),
|
||||
"acoustid_enabled": s.value(SETTINGS_KEY_ACOUSTID, False, type=bool),
|
||||
"acoustid_enabled": s.value(SETTINGS_KEY_ACOUSTID, False, type=bool),
|
||||
"acoustid_api_key": s.value(SETTINGS_KEY_ACOUSTID_KEY, ""),
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +76,8 @@ def save_settings(values: dict):
|
||||
s.setValue(SETTINGS_KEY_PREV_DEVICE, values.get("audio_device_preview", ""))
|
||||
s.setValue(SETTINGS_KEY_AFTER_SONG, values.get("after_song_mode", "manual"))
|
||||
s.setValue(SETTINGS_KEY_AFTER_DELAY, values.get("after_song_delay", 2))
|
||||
s.setValue(SETTINGS_KEY_ACOUSTID, values.get("acoustid_enabled", False))
|
||||
s.setValue(SETTINGS_KEY_ACOUSTID, values.get("acoustid_enabled", False))
|
||||
s.setValue(SETTINGS_KEY_ACOUSTID_KEY, values.get("acoustid_api_key", ""))
|
||||
|
||||
|
||||
class SettingsDialog(QDialog):
|
||||
@@ -272,10 +275,17 @@ class SettingsDialog(QDialog):
|
||||
self._chk_acoustid.setToolTip(
|
||||
"Analyserer sange uden MBID og slår dem op i AcoustID-databasen.\n"
|
||||
"Kræver fpcalc (Chromaprint) installeret.\n"
|
||||
"Startes automatisk 60 sekunder efter opstart."
|
||||
"Startes automatisk 10 sekunder efter opstart."
|
||||
)
|
||||
grp4_layout.addWidget(self._chk_acoustid)
|
||||
|
||||
key_row = QHBoxLayout()
|
||||
key_row.addWidget(QLabel("API-nøgle:"))
|
||||
self._acoustid_key = QLineEdit()
|
||||
self._acoustid_key.setPlaceholderText("Hent gratis på acoustid.org/api-key")
|
||||
key_row.addWidget(self._acoustid_key)
|
||||
grp4_layout.addLayout(key_row)
|
||||
|
||||
note4 = QLabel(
|
||||
"fpcalc skal installeres separat:\n"
|
||||
" Linux: sudo apt install libchromaprint-tools\n"
|
||||
@@ -476,6 +486,7 @@ class SettingsDialog(QDialog):
|
||||
self._radio_manual.setChecked(True)
|
||||
self._spin_after_delay.setValue(v.get("after_song_delay", 2))
|
||||
self._chk_acoustid.setChecked(v.get("acoustid_enabled", False))
|
||||
self._acoustid_key.setText(v.get("acoustid_api_key", ""))
|
||||
|
||||
# ── Gem ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -502,6 +513,7 @@ class SettingsDialog(QDialog):
|
||||
),
|
||||
"after_song_delay": self._spin_after_delay.value(),
|
||||
"acoustid_enabled": self._chk_acoustid.isChecked(),
|
||||
"acoustid_api_key": self._acoustid_key.text().strip(),
|
||||
}
|
||||
save_settings(values)
|
||||
self._values = values
|
||||
|
||||
Reference in New Issue
Block a user