summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/gui/dialog_playlist_manager.py
diff options
context:
space:
mode:
authorWarry <FunWarry@users.noreply.github.com>2025-12-29 20:05:34 +0100
committerWarry <FunWarry@users.noreply.github.com>2025-12-29 20:05:34 +0100
commitf413240b51f574c01144e6ae672b24c412a949e1 (patch)
treeee26239282d17057a5eabd7a7b130c248b380f9d /tidal_dl_ng/gui/dialog_playlist_manager.py
parent296c6c7d6b319b38958b2aacb9904f18f6f46fd1 (diff)
downloadtidal-dl-ng-f413240b51f574c01144e6ae672b24c412a949e1.tar.gz
feat: Enhance playlist management and GUI logic
- Improved playlist item fetching by adding robust pagination and low-level request hooks for better testing and flexibility. - Refactored track ID extraction logic into reusable helpers for clarity. - Improved initialization for dialog components to avoid circular dependencies in the GUI. - Added new unit tests to validate playlist operations, including track addition/removal and API integration. - Updated metadata functions to simplify dictionary access using `.get` for better readability. - Ensured PySide6 system dependencies are installed in GitHub Actions to address CI compatibility issues. - Streamlined UI package initialization to improve modularity and robustness of imports.
Diffstat (limited to 'tidal_dl_ng/gui/dialog_playlist_manager.py')
-rw-r--r--tidal_dl_ng/gui/dialog_playlist_manager.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tidal_dl_ng/gui/dialog_playlist_manager.py b/tidal_dl_ng/gui/dialog_playlist_manager.py
index 7d61306..0066e72 100644
--- a/tidal_dl_ng/gui/dialog_playlist_manager.py
+++ b/tidal_dl_ng/gui/dialog_playlist_manager.py
@@ -17,7 +17,6 @@ from tidalapi import Session, Track
from tidal_dl_ng.gui.playlist_membership import ThreadSafePlaylistCache
from tidal_dl_ng.helper.playlist_api import add_track_to_playlist, remove_track_from_playlist
from tidal_dl_ng.logger import logger_gui
-from tidal_dl_ng.ui.dialog_playlist_manager import Ui_DialogPlaylistManager
from tidal_dl_ng.worker import Worker
@@ -77,6 +76,9 @@ class PlaylistManagerDialog(QtWidgets.QDialog):
self._original_states: dict[str, bool] = {}
self._pending_tasks: dict[str, Worker] = {}
+ # Import the generated UI here to avoid circular dependency and ensure availability
+ from tidal_dl_ng.ui.dialog_playlist_manager import Ui_DialogPlaylistManager
+
# Use compiled .ui
self.ui = Ui_DialogPlaylistManager()
self.ui.setupUi(self)
@@ -90,6 +92,9 @@ class PlaylistManagerDialog(QtWidgets.QDialog):
# Populate playlists list into verticalLayoutList
self._populate_playlists_ui()
+ # Expose container layout for tests
+ self.container_layout = self.ui.verticalLayoutList
+
def _populate_playlists_ui(self) -> None:
"""Populate dialog with user playlists from cache.
@@ -325,3 +330,19 @@ class PlaylistManagerDialog(QtWidgets.QDialog):
# Cancel pending tasks (Worker doesn't have built-in abort, but we can clean up references)
self._pending_tasks.clear()
super().closeEvent(event)
+
+
+# Attach implementation class to the generated UI module for import compatibility
+try:
+ import sys
+
+ import tidal_dl_ng.ui.dialog_playlist_manager as _ui_mod
+
+ _ui_mod.PlaylistManagerDialog = PlaylistManagerDialog
+ # Ensure module is in sys.modules for proper imports
+ sys.modules["tidal_dl_ng.ui.dialog_playlist_manager"] = _ui_mod
+except Exception as e:
+ # If UI module isn't importable in some contexts, log and continue
+ from tidal_dl_ng.logger import logger_gui
+
+ logger_gui.debug(f"Could not attach PlaylistManagerDialog to UI module: {e}")