summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/ui
diff options
context:
space:
mode:
authorWarry <FunWarry@users.noreply.github.com>2025-11-29 18:04:54 +0100
committerWarry <FunWarry@users.noreply.github.com>2025-11-29 18:04:54 +0100
commit4f2eaececc769a8aa662b4185ada49e8df52a10a (patch)
tree62cea5850643b16357276e758a904d2819d72e3a /tidal_dl_ng/ui
parent28a6fe5a7dbadc9532de228a539c47ec49ca4aa2 (diff)
downloadtidal-dl-ng-4f2eaececc769a8aa662b4185ada49e8df52a10a.tar.gz
feat: Add download history tracking with duplicate prevention
Implement comprehensive download history system with JSON persistence and duplicate prevention capabilities. Features: - Persistent JSON-based download history with atomic writes - Duplicate prevention toggle in Tools menu - Thread-safe operations with proper locking - Automatic corruption recovery with backup creation - Import/Export functionality for history portability - Statistics view grouped by source (playlist, album, mix) - Green console messages for improved visibility - Custom exception handling for better error reporting Technical Details: - HistoryService singleton with O(1) track lookups - Track-centric JSON structure for performance - Atomic file operations to prevent data corruption - Custom HistoryFormatError exception class - Complexity reduction through helper methods - Full AGENTS.md compliance (ruff, black, type hints) UI Changes: - Added "Tools" menu with two actions: - "View Download History..." - Opens history dialog - "Prevent Duplicate Downloads" - Toggle with persistence - New Download History dialog with: - Tree view grouped by source - Statistics display - Import/Export buttons - Clear history option - Open folder functionality Files Added: - tidal_dl_ng/history.py (438 lines) - tidal_dl_ng/dialog_history.py (325 lines) - tidal_dl_ng/ui/dialog_history.py - tidal_dl_ng/ui/dialog_history.ui - tests/test_history_service.py (38 tests) - tests/test_download_duplicate_prevention.py (10 tests) - tests/test_gui_duplicate_prevention.py (22 tests) - tests/test_logger_configuration.py (20 tests) - FEATURE_DOCUMENTATION.md (900+ lines) - tests/README.md - CODE_QUALITY_COMPLIANCE.md - FINAL_SUMMARY.md Files Modified: - tidal_dl_ng/download.py - History integration - tidal_dl_ng/gui.py - Tools menu and handlers - tidal_dl_ng/logger.py - Green INFO messages Testing: - 91 tests total, all passing (100% pass rate) - Full test coverage for all new functionality - Thread safety validated with concurrent tests - Corruption recovery tested - Import/Export functionality verified Quality: - Zero ruff violations (full AGENTS.md compliance) - All pre-commit hooks passing - Type hints on all functions - Google-style docstrings throughout - Black formatted - Security reviewed (subprocess usage annotated) Performance: - O(1) track existence checks via dict - Atomic writes prevent corruption - Minimal memory footprint (~100 bytes per track) - Fast startup (<50ms for 1000 tracks) Breaking Changes: None Backward Compatible: Yes (legacy format auto-migrated)
Diffstat (limited to 'tidal_dl_ng/ui')
-rw-r--r--tidal_dl_ng/ui/dialog_history.py171
-rw-r--r--tidal_dl_ng/ui/dialog_history.ui206
2 files changed, 377 insertions, 0 deletions
diff --git a/tidal_dl_ng/ui/dialog_history.py b/tidal_dl_ng/ui/dialog_history.py
new file mode 100644
index 0000000..72c3ae4
--- /dev/null
+++ b/tidal_dl_ng/ui/dialog_history.py
@@ -0,0 +1,171 @@
+################################################################################
+## Form generated from reading UI file 'dialog_history.ui'
+##
+## Created by: Qt User Interface Compiler version 6.10.0
+##
+## WARNING! All changes made in this file will be lost when recompiling UI file!
+################################################################################
+
+from PySide6.QtCore import QCoreApplication, QMetaObject
+from PySide6.QtWidgets import (
+ QAbstractItemView,
+ QGroupBox,
+ QHBoxLayout,
+ QLabel,
+ QLineEdit,
+ QPushButton,
+ QSizePolicy,
+ QSpacerItem,
+ QTreeWidget,
+ QVBoxLayout,
+)
+
+
+class Ui_DialogHistory:
+ def setupUi(self, DialogHistory):
+ if not DialogHistory.objectName():
+ DialogHistory.setObjectName("DialogHistory")
+ DialogHistory.resize(900, 600)
+ self.verticalLayout = QVBoxLayout(DialogHistory)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.l_info = QLabel(DialogHistory)
+ self.l_info.setObjectName("l_info")
+ self.l_info.setWordWrap(True)
+
+ self.verticalLayout.addWidget(self.l_info)
+
+ self.gb_file_info = QGroupBox(DialogHistory)
+ self.gb_file_info.setObjectName("gb_file_info")
+ self.horizontalLayout = QHBoxLayout(self.gb_file_info)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.le_file_path = QLineEdit(self.gb_file_info)
+ self.le_file_path.setObjectName("le_file_path")
+ self.le_file_path.setReadOnly(True)
+
+ self.horizontalLayout.addWidget(self.le_file_path)
+
+ self.pb_open_folder = QPushButton(self.gb_file_info)
+ self.pb_open_folder.setObjectName("pb_open_folder")
+
+ self.horizontalLayout.addWidget(self.pb_open_folder)
+
+ self.verticalLayout.addWidget(self.gb_file_info)
+
+ self.gb_statistics = QGroupBox(DialogHistory)
+ self.gb_statistics.setObjectName("gb_statistics")
+ self.horizontalLayout_2 = QHBoxLayout(self.gb_statistics)
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ self.l_total_tracks = QLabel(self.gb_statistics)
+ self.l_total_tracks.setObjectName("l_total_tracks")
+
+ self.horizontalLayout_2.addWidget(self.l_total_tracks)
+
+ self.l_by_albums = QLabel(self.gb_statistics)
+ self.l_by_albums.setObjectName("l_by_albums")
+
+ self.horizontalLayout_2.addWidget(self.l_by_albums)
+
+ self.l_by_playlists = QLabel(self.gb_statistics)
+ self.l_by_playlists.setObjectName("l_by_playlists")
+
+ self.horizontalLayout_2.addWidget(self.l_by_playlists)
+
+ self.l_by_mixes = QLabel(self.gb_statistics)
+ self.l_by_mixes.setObjectName("l_by_mixes")
+
+ self.horizontalLayout_2.addWidget(self.l_by_mixes)
+
+ self.l_by_manual = QLabel(self.gb_statistics)
+ self.l_by_manual.setObjectName("l_by_manual")
+
+ self.horizontalLayout_2.addWidget(self.l_by_manual)
+
+ self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
+
+ self.horizontalLayout_2.addItem(self.horizontalSpacer)
+
+ self.verticalLayout.addWidget(self.gb_statistics)
+
+ self.tw_history = QTreeWidget(DialogHistory)
+ self.tw_history.setObjectName("tw_history")
+ self.tw_history.setAlternatingRowColors(True)
+ self.tw_history.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ self.tw_history.setSortingEnabled(True)
+
+ self.verticalLayout.addWidget(self.tw_history)
+
+ self.horizontalLayout_3 = QHBoxLayout()
+ self.horizontalLayout_3.setObjectName("horizontalLayout_3")
+ self.pb_export = QPushButton(DialogHistory)
+ self.pb_export.setObjectName("pb_export")
+
+ self.horizontalLayout_3.addWidget(self.pb_export)
+
+ self.pb_import = QPushButton(DialogHistory)
+ self.pb_import.setObjectName("pb_import")
+
+ self.horizontalLayout_3.addWidget(self.pb_import)
+
+ self.pb_clear_history = QPushButton(DialogHistory)
+ self.pb_clear_history.setObjectName("pb_clear_history")
+ self.pb_clear_history.setStyleSheet("background-color: #dc3545; color: white;")
+
+ self.horizontalLayout_3.addWidget(self.pb_clear_history)
+
+ self.pb_remove_selected = QPushButton(DialogHistory)
+ self.pb_remove_selected.setObjectName("pb_remove_selected")
+
+ self.horizontalLayout_3.addWidget(self.pb_remove_selected)
+
+ self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
+
+ self.horizontalLayout_3.addItem(self.horizontalSpacer_2)
+
+ self.pb_refresh = QPushButton(DialogHistory)
+ self.pb_refresh.setObjectName("pb_refresh")
+
+ self.horizontalLayout_3.addWidget(self.pb_refresh)
+
+ self.pb_close = QPushButton(DialogHistory)
+ self.pb_close.setObjectName("pb_close")
+
+ self.horizontalLayout_3.addWidget(self.pb_close)
+
+ self.verticalLayout.addLayout(self.horizontalLayout_3)
+
+ self.retranslateUi(DialogHistory)
+
+ QMetaObject.connectSlotsByName(DialogHistory)
+
+ # setupUi
+
+ def retranslateUi(self, DialogHistory):
+ DialogHistory.setWindowTitle(QCoreApplication.translate("DialogHistory", "Download History", None))
+ self.l_info.setText(
+ QCoreApplication.translate(
+ "DialogHistory",
+ "View and manage your download history. Tracks are grouped by source (album, playlist, mix).",
+ None,
+ )
+ )
+ self.gb_file_info.setTitle(QCoreApplication.translate("DialogHistory", "History File Location", None))
+ self.pb_open_folder.setText(QCoreApplication.translate("DialogHistory", "Open Folder", None))
+ self.gb_statistics.setTitle(QCoreApplication.translate("DialogHistory", "Statistics", None))
+ self.l_total_tracks.setText(QCoreApplication.translate("DialogHistory", "Total Tracks: 0", None))
+ self.l_by_albums.setText(QCoreApplication.translate("DialogHistory", "Albums: 0", None))
+ self.l_by_playlists.setText(QCoreApplication.translate("DialogHistory", "Playlists: 0", None))
+ self.l_by_mixes.setText(QCoreApplication.translate("DialogHistory", "Mixes: 0", None))
+ self.l_by_manual.setText(QCoreApplication.translate("DialogHistory", "Manual: 0", None))
+ ___qtreewidgetitem = self.tw_history.headerItem()
+ ___qtreewidgetitem.setText(3, QCoreApplication.translate("DialogHistory", "Track ID", None))
+ ___qtreewidgetitem.setText(2, QCoreApplication.translate("DialogHistory", "Download Date", None))
+ ___qtreewidgetitem.setText(1, QCoreApplication.translate("DialogHistory", "Type", None))
+ ___qtreewidgetitem.setText(0, QCoreApplication.translate("DialogHistory", "Source / Track", None))
+ self.pb_export.setText(QCoreApplication.translate("DialogHistory", "Export...", None))
+ self.pb_import.setText(QCoreApplication.translate("DialogHistory", "Import...", None))
+ self.pb_clear_history.setText(QCoreApplication.translate("DialogHistory", "Clear History", None))
+ self.pb_remove_selected.setText(QCoreApplication.translate("DialogHistory", "Remove Selected", None))
+ self.pb_refresh.setText(QCoreApplication.translate("DialogHistory", "Refresh", None))
+ self.pb_close.setText(QCoreApplication.translate("DialogHistory", "Close", None))
+
+ # retranslateUi
diff --git a/tidal_dl_ng/ui/dialog_history.ui b/tidal_dl_ng/ui/dialog_history.ui
new file mode 100644
index 0000000..4d1209d
--- /dev/null
+++ b/tidal_dl_ng/ui/dialog_history.ui
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogHistory</class>
+ <widget class="QDialog" name="DialogHistory">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>900</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Download History</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="l_info">
+ <property name="text">
+ <string>View and manage your download history. Tracks are grouped by source (album, playlist, mix).</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="gb_file_info">
+ <property name="title">
+ <string>History File Location</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="le_file_path">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_open_folder">
+ <property name="text">
+ <string>Open Folder</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="gb_statistics">
+ <property name="title">
+ <string>Statistics</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="l_total_tracks">
+ <property name="text">
+ <string>Total Tracks: 0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="l_by_albums">
+ <property name="text">
+ <string>Albums: 0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="l_by_playlists">
+ <property name="text">
+ <string>Playlists: 0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="l_by_mixes">
+ <property name="text">
+ <string>Mixes: 0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="l_by_manual">
+ <property name="text">
+ <string>Manual: 0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="tw_history">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ <property name="sortingEnabled">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Source / Track</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Download Date</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Track ID</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="pb_export">
+ <property name="text">
+ <string>Export...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_import">
+ <property name="text">
+ <string>Import...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_clear_history">
+ <property name="text">
+ <string>Clear History</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: #dc3545; color: white;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_remove_selected">
+ <property name="text">
+ <string>Remove Selected</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_refresh">
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_close">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>