Skip to content

Commit

Permalink
feat(gui): Update "Delete Uploads" dialog to let user select score cu…
Browse files Browse the repository at this point in the history
…toff for fuzzy matching (#105)
  • Loading branch information
apastel authored Feb 8, 2025
1 parent 2e7ddba commit 056bb14
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 44 deletions.
1 change: 0 additions & 1 deletion gui/src/main/python/add_all_to_playlist_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def __init__(self, parent):
self.setWindowTitle("Select Playlist to Add All Songs To")
self.enable_ok_button()
self.playlistList.itemSelectionChanged.connect(self.enable_ok_button)
self.shuffleCheckBox.hide()

try:
self.all_playlists = parent.ytmusic.get_library_playlists(limit=None)
Expand Down
25 changes: 25 additions & 0 deletions gui/src/main/python/delete_uploads_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from generated import ui_delete_uploads_dialog
from PySide6 import QtWidgets
from PySide6 import QtCore


class DeleteUploadsDialog(QtWidgets.QDialog, ui_delete_uploads_dialog.Ui_DeleteUploadsDialog):
def __init__(self, parent):
super().__init__(parent)
self.setupUi(self)

self.enable_score_cutoff()
self.addUploadsCheckBox.checkStateChanged.connect(self.enable_score_cutoff)

def accept(self):
delete_uploads_args = ["delete-uploads"]
if self.addUploadsCheckBox.isChecked():
delete_uploads_args += ["-as", str(self.scoreCutoffInput.value())]
self.parentWidget().launch_process(delete_uploads_args)
super().accept()

@QtCore.Slot()
def enable_score_cutoff(self):
self.scoreCutoffInput.setValue(85)
self.scoreCutoffLabel.setVisible(self.addUploadsCheckBox.isChecked())
self.scoreCutoffInput.setVisible(self.addUploadsCheckBox.isChecked())
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_auth_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'auth_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_checkbox_track_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'checkbox_track_listing.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
76 changes: 76 additions & 0 deletions gui/src/main/python/generated/ui_delete_uploads_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'delete_uploads_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QAbstractButton, QApplication, QCheckBox, QDialog,
QDialogButtonBox, QLabel, QSizePolicy, QSpinBox,
QWidget)

class Ui_DeleteUploadsDialog(object):
def setupUi(self, DeleteUploadsDialog):
if not DeleteUploadsDialog.objectName():
DeleteUploadsDialog.setObjectName(u"DeleteUploadsDialog")
DeleteUploadsDialog.resize(393, 215)
self.buttonBox = QDialogButtonBox(DeleteUploadsDialog)
self.buttonBox.setObjectName(u"buttonBox")
self.buttonBox.setGeometry(QRect(30, 160, 341, 32))
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
self.infoLabel = QLabel(DeleteUploadsDialog)
self.infoLabel.setObjectName(u"infoLabel")
self.infoLabel.setGeometry(QRect(40, 20, 281, 31))
self.addUploadsCheckBox = QCheckBox(DeleteUploadsDialog)
self.addUploadsCheckBox.setObjectName(u"addUploadsCheckBox")
self.addUploadsCheckBox.setGeometry(QRect(40, 80, 261, 16))
self.scoreCutoffLabel = QLabel(DeleteUploadsDialog)
self.scoreCutoffLabel.setObjectName(u"scoreCutoffLabel")
self.scoreCutoffLabel.setGeometry(QRect(40, 100, 131, 21))
self.scoreCutoffInput = QSpinBox(DeleteUploadsDialog)
self.scoreCutoffInput.setObjectName(u"scoreCutoffInput")
self.scoreCutoffInput.setGeometry(QRect(170, 100, 42, 22))
self.scoreCutoffInput.setMaximum(100)
self.scoreCutoffInput.setValue(85)
self.hoverOverLabel = QLabel(DeleteUploadsDialog)
self.hoverOverLabel.setObjectName(u"hoverOverLabel")
self.hoverOverLabel.setGeometry(QRect(60, 120, 261, 20))
font = QFont()
font.setPointSize(7)
self.hoverOverLabel.setFont(font)

self.retranslateUi(DeleteUploadsDialog)
self.buttonBox.accepted.connect(DeleteUploadsDialog.accept)
self.buttonBox.rejected.connect(DeleteUploadsDialog.reject)

QMetaObject.connectSlotsByName(DeleteUploadsDialog)
# setupUi

def retranslateUi(self, DeleteUploadsDialog):
DeleteUploadsDialog.setWindowTitle(QCoreApplication.translate("DeleteUploadsDialog", u"Dialog", None))
self.infoLabel.setText(QCoreApplication.translate("DeleteUploadsDialog", u"This will delete all your uploaded music.", None))
#if QT_CONFIG(tooltip)
self.addUploadsCheckBox.setToolTip(QCoreApplication.translate("DeleteUploadsDialog", u"This will attempt to add each album or song to your library from YouTube Music's online catalog before deleting it from your uploads. If a match could not be found, the album or song will remain in your uploads.", None))
#endif // QT_CONFIG(tooltip)
self.addUploadsCheckBox.setText(QCoreApplication.translate("DeleteUploadsDialog", u"Add uploads to library first", None))
#if QT_CONFIG(tooltip)
self.scoreCutoffLabel.setToolTip(QCoreApplication.translate("DeleteUploadsDialog", u"A value closer to 100 will be more strict regarding matches when searching YTMusic for the song/album. A value of 100 will basically only add exact matches. If you find that not many matches are being found, try lowering this value, but you may end up with albums in your library that are not exact matches. 85 is recommended to start out with.", None))
#endif // QT_CONFIG(tooltip)
self.scoreCutoffLabel.setText(QCoreApplication.translate("DeleteUploadsDialog", u"Match score cutoff:", None))
#if QT_CONFIG(tooltip)
self.scoreCutoffInput.setToolTip(QCoreApplication.translate("DeleteUploadsDialog", u"A value closer to 100 will be more strict regarding matches when searching YTMusic for the song/album. A value of 100 will basically only add exact matches. If you find that not many matches are being found, try lowering this value, but you may end up with albums in your library that are not exact matches. 85 is recommended to start out with.", None))
#endif // QT_CONFIG(tooltip)
self.hoverOverLabel.setText(QCoreApplication.translate("DeleteUploadsDialog", u"(Hover over these options for more info)", None))
# retranslateUi

2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'main_window.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
15 changes: 4 additions & 11 deletions gui/src/main/python/generated/ui_playlist_selection_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'playlist_selection_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand All @@ -15,9 +15,9 @@
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QAbstractButton, QApplication, QButtonGroup, QCheckBox,
QDialog, QDialogButtonBox, QLabel, QListWidget,
QListWidgetItem, QRadioButton, QSizePolicy, QWidget)
from PySide6.QtWidgets import (QAbstractButton, QApplication, QButtonGroup, QDialog,
QDialogButtonBox, QLabel, QListWidget, QListWidgetItem,
QRadioButton, QSizePolicy, QWidget)

class Ui_PlaylistSelectionDialog(object):
def setupUi(self, PlaylistSelectionDialog):
Expand All @@ -35,9 +35,6 @@ def setupUi(self, PlaylistSelectionDialog):
self.playlistList.setGeometry(QRect(25, 21, 351, 221))
self.playlistList.setSelectionRectVisible(False)
self.playlistList.setSortingEnabled(True)
self.shuffleCheckBox = QCheckBox(PlaylistSelectionDialog)
self.shuffleCheckBox.setObjectName(u"shuffleCheckBox")
self.shuffleCheckBox.setGeometry(QRect(90, 260, 70, 17))
self.radioButtonLibrary = QRadioButton(PlaylistSelectionDialog)
self.radioButtonGroup = QButtonGroup(PlaylistSelectionDialog)
self.radioButtonGroup.setObjectName(u"radioButtonGroup")
Expand Down Expand Up @@ -65,10 +62,6 @@ def setupUi(self, PlaylistSelectionDialog):

def retranslateUi(self, PlaylistSelectionDialog):
PlaylistSelectionDialog.setWindowTitle(QCoreApplication.translate("PlaylistSelectionDialog", u"Select Playlist(s)", None))
#if QT_CONFIG(tooltip)
self.shuffleCheckBox.setToolTip(QCoreApplication.translate("PlaylistSelectionDialog", u"Shuffle the playlist(s) instead of sorting.", None))
#endif // QT_CONFIG(tooltip)
self.shuffleCheckBox.setText(QCoreApplication.translate("PlaylistSelectionDialog", u"Shuffle", None))
self.radioButtonLibrary.setText(QCoreApplication.translate("PlaylistSelectionDialog", u"Library", None))
self.radioButtonUploads.setText(QCoreApplication.translate("PlaylistSelectionDialog", u"Uploads", None))
self.radioButtonLabel.setText(QCoreApplication.translate("PlaylistSelectionDialog", u"Add all songs from...", None))
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_progress_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'progress_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'settings_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_sort_playlist_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'sort_playlist_dialog.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/python/generated/ui_track_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'track_listing.ui'
##
## Created by: Qt User Interface Compiler version 6.8.1
## Created by: Qt User Interface Compiler version 6.8.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
18 changes: 11 additions & 7 deletions gui/src/main/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ytmusicapi.exceptions
from add_all_to_playlist_dialog import AddAllToPlaylistDialog
from browser_auth_dialog import BrowserAuthDialog
from delete_uploads_dialog import DeleteUploadsDialog
from fbs_runtime import PUBLIC_SETTINGS
from fbs_runtime.application_context import cached_property
from fbs_runtime.application_context import is_frozen
Expand All @@ -32,7 +33,6 @@
from PySide6.QtGui import QIcon
from PySide6.QtGui import QImage
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QCheckBox
from PySide6.QtWidgets import QLabel
from PySide6.QtWidgets import QMainWindow
from PySide6.QtWidgets import QMessageBox
Expand Down Expand Up @@ -310,7 +310,11 @@ def prepare_to_invoke(self):

def show_dialog(self, args: List[str]):
if self.p is None and self.is_signed_in():
if args[0] == "sort-playlist":
if args[0] == "delete-uploads":
self.delete_uploads_dialog = DeleteUploadsDialog(self)
self.delete_uploads_dialog.show()

elif args[0] == "sort-playlist":
self.sort_playlists_dialog = SortPlaylistsDialog(self)
self.sort_playlists_dialog.show()

Expand All @@ -335,11 +339,11 @@ def confirm(self, args: List[str]):
confirmation_dialog.setIcon(QMessageBox.Warning)
if args[0] == "remove-library":
text = 'This is the same as clicking "Remove from library" on all albums that you have added to your library by clicking "Add to library" within YT Music. This will not delete your uploads.' # noqa
elif args[0] == "delete-uploads":
text = "This will delete all your uploaded music. "
checkbox = QCheckBox("Add uploads to library first")
checkbox.toggled.connect(self.add_to_library_checked)
confirmation_dialog.setCheckBox(checkbox)
# elif args[0] == "delete-uploads":
# text = "This will delete all your uploaded music. "
# checkbox = QCheckBox("Add uploads to library first")
# checkbox.toggled.connect(self.add_to_library_checked)
# confirmation_dialog.setCheckBox(checkbox)
elif args[0] == "delete-playlists":
text = "This will delete all your playlists, which may also include playlists in regular YouTube.com that have music."
elif args[0] == "unlike-all":
Expand Down
1 change: 0 additions & 1 deletion gui/src/main/python/remove_duplicates_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self, parent):
self.buttonBox.button(QDialogButtonBox.Ok).setText("Next")
self.enable_ok_button()
self.playlistList.itemSelectionChanged.connect(self.enable_ok_button)
self.shuffleCheckBox.hide()
self.radioButtonLabel.setVisible(False)
self.radioButtonLibrary.setVisible(False)
self.radioButtonUploads.setVisible(False)
Expand Down
Loading

0 comments on commit 056bb14

Please sign in to comment.