stuff
This commit is contained in:
parent
2693973975
commit
d3313db6ab
@ -85,8 +85,8 @@ class MetadataWindow(QDialog):
|
|||||||
tag_sets[tag].append(song_data[tag].text[0])
|
tag_sets[tag].append(song_data[tag].text[0])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
debug("tag sets:")
|
# debug("tag sets:")
|
||||||
debug(tag_sets)
|
# debug(tag_sets)
|
||||||
|
|
||||||
# UI Creation
|
# UI Creation
|
||||||
current_layout = QHBoxLayout()
|
current_layout = QHBoxLayout()
|
||||||
|
|||||||
@ -379,6 +379,8 @@ class MusicTable(QTableView):
|
|||||||
|
|
||||||
def on_header_resized(self, logicalIndex, oldSize, newSize):
|
def on_header_resized(self, logicalIndex, oldSize, newSize):
|
||||||
"""Handles keeping headers inside the viewport"""
|
"""Handles keeping headers inside the viewport"""
|
||||||
|
# FIXME: how resize good
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/46775438/how-to-limit-qheaderview-size-when-resizing-sections
|
# https://stackoverflow.com/questions/46775438/how-to-limit-qheaderview-size-when-resizing-sections
|
||||||
col_count = self.model2.columnCount()
|
col_count = self.model2.columnCount()
|
||||||
qtableview_width = self.size().width()
|
qtableview_width = self.size().width()
|
||||||
@ -444,13 +446,16 @@ class MusicTable(QTableView):
|
|||||||
- data returned from the original worker process function are returned here
|
- data returned from the original worker process function are returned here
|
||||||
as the first item in a tuple
|
as the first item in a tuple
|
||||||
"""
|
"""
|
||||||
# FIXME:
|
|
||||||
# TODO: make this prettier, show a table in a window instead of raw text probably
|
|
||||||
_, details = args[0][:2]
|
_, details = args[0][:2]
|
||||||
details = dict(tuple(details)[0])
|
try:
|
||||||
if details:
|
details = dict(tuple(details)[0])
|
||||||
window = DebugWindow(details)
|
if details:
|
||||||
window.exec_()
|
window = DebugWindow(details)
|
||||||
|
window.exec_()
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'on_add_files_to_database_finished() | Something went wrong: {e}')
|
||||||
|
|
||||||
# ____________________
|
# ____________________
|
||||||
# | |
|
# | |
|
||||||
@ -498,7 +503,7 @@ class MusicTable(QTableView):
|
|||||||
question_dialog = QuestionBoxDetails(
|
question_dialog = QuestionBoxDetails(
|
||||||
title="Delete songs",
|
title="Delete songs",
|
||||||
description="Remove these songs from the library?",
|
description="Remove these songs from the library?",
|
||||||
details=formatted_selected_filepaths,
|
data=selected_filepaths,
|
||||||
)
|
)
|
||||||
reply = question_dialog.execute()
|
reply = question_dialog.execute()
|
||||||
if reply:
|
if reply:
|
||||||
@ -734,8 +739,7 @@ class MusicTable(QTableView):
|
|||||||
Loads the header widths from the last application close.
|
Loads the header widths from the last application close.
|
||||||
"""
|
"""
|
||||||
table_view_column_widths = str(self.config["table"]["column_widths"]).split(",")
|
table_view_column_widths = str(self.config["table"]["column_widths"]).split(",")
|
||||||
if not isinstance(table_view_column_widths[0], int):
|
debug(f'loaded header widths: {table_view_column_widths}')
|
||||||
return
|
|
||||||
if not isinstance(table_view_column_widths, list):
|
if not isinstance(table_view_column_widths, list):
|
||||||
for i in range(self.model2.columnCount() - 1):
|
for i in range(self.model2.columnCount() - 1):
|
||||||
self.setColumnWidth(i, int(table_view_column_widths[i]))
|
self.setColumnWidth(i, int(table_view_column_widths[i]))
|
||||||
|
|||||||
@ -1,41 +1,76 @@
|
|||||||
from PyQt5.QtCore import pyqtSignal
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
|
QAbstractScrollArea,
|
||||||
QDialog,
|
QDialog,
|
||||||
QHBoxLayout,
|
QHBoxLayout,
|
||||||
|
QHeaderView,
|
||||||
QPlainTextEdit,
|
QPlainTextEdit,
|
||||||
|
QTableWidget,
|
||||||
|
QTableWidgetItem,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QLabel,
|
QLabel,
|
||||||
QPushButton,
|
QPushButton,
|
||||||
)
|
)
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QFont
|
||||||
from components.ErrorDialog import ErrorDialog
|
from components.ErrorDialog import ErrorDialog
|
||||||
from utils import set_id3_tag
|
from logging import debug, error
|
||||||
from logging import debug
|
from pprint import pformat
|
||||||
|
|
||||||
|
|
||||||
class QuestionBoxDetails(QDialog):
|
class QuestionBoxDetails(QDialog):
|
||||||
def __init__(self, title: str, description: str, details):
|
def __init__(self, title: str, description: str, data):
|
||||||
super(QuestionBoxDetails, self).__init__()
|
super(QuestionBoxDetails, self).__init__()
|
||||||
self.title: str = title
|
self.title: str = title
|
||||||
self.description: str = description
|
self.description: str = description
|
||||||
self.details: str = details
|
self.data: str = data
|
||||||
self.reply: bool = False
|
self.reply: bool = False
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
self.setMinimumSize(400, 400)
|
self.setMinimumSize(400, 400)
|
||||||
|
self.setMaximumSize(600,1000)
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
h_layout = QHBoxLayout()
|
h_layout = QHBoxLayout()
|
||||||
|
|
||||||
# Labels & input fields
|
# Labels & input fields
|
||||||
label = QLabel(description)
|
label = QLabel(description)
|
||||||
layout.addWidget(label)
|
layout.addWidget(label)
|
||||||
self.text_field = QPlainTextEdit(self.details)
|
|
||||||
layout.addWidget(self.text_field)
|
if isinstance(self.data, str):
|
||||||
|
self.input_field = QPlainTextEdit(pformat(self.data))
|
||||||
|
layout.addWidget(self.input_field)
|
||||||
|
else:
|
||||||
|
table: QTableWidget = QTableWidget()
|
||||||
|
table.setSizeAdjustPolicy(QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)
|
||||||
|
table.horizontalHeader().setStretchLastSection(True)
|
||||||
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.Interactive)
|
||||||
|
if isinstance(self.data, list):
|
||||||
|
# big ol column
|
||||||
|
table.setRowCount(len(data))
|
||||||
|
table.setColumnCount(1)
|
||||||
|
for i, item in enumerate(self.data):
|
||||||
|
table.setItem(i, 0, QTableWidgetItem(str(item)))
|
||||||
|
layout.addWidget(table)
|
||||||
|
elif isinstance(self.data, dict):
|
||||||
|
try:
|
||||||
|
# | TIT2 | title goes here |
|
||||||
|
# | TDRC | 2025-05-05 |
|
||||||
|
table.setRowCount(len(data.keys()))
|
||||||
|
table.setColumnCount(2)
|
||||||
|
table.setHorizontalHeaderLabels(['Tag', 'Value'])
|
||||||
|
for i, (k, v) in enumerate(data.items()):
|
||||||
|
table.setItem(i, 0, QTableWidgetItem(str(k)))
|
||||||
|
table.setItem(i, 1, QTableWidgetItem(str(v)))
|
||||||
|
layout.addWidget(table)
|
||||||
|
except Exception as e:
|
||||||
|
data = str(self.data)
|
||||||
|
self.input_field = QPlainTextEdit(pformat(data + "\n\n" + str(e)))
|
||||||
|
layout.addWidget(self.input_field)
|
||||||
|
error(f'Tried to load self.data as dict but could not. {e}')
|
||||||
# ok
|
# ok
|
||||||
ok_button = QPushButton("ok")
|
ok_button = QPushButton("Confirm")
|
||||||
ok_button.clicked.connect(self.ok)
|
ok_button.clicked.connect(self.ok)
|
||||||
h_layout.addWidget(ok_button)
|
h_layout.addWidget(ok_button)
|
||||||
# cancel
|
# cancel
|
||||||
cancel_button = QPushButton("cancel")
|
cancel_button = QPushButton("no")
|
||||||
cancel_button.clicked.connect(self.cancel)
|
cancel_button.clicked.connect(self.cancel)
|
||||||
h_layout.addWidget(cancel_button)
|
h_layout.addWidget(cancel_button)
|
||||||
|
|
||||||
|
|||||||
8
main.py
8
main.py
@ -289,6 +289,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
for i in range(self.tableView.model2.columnCount()):
|
for i in range(self.tableView.model2.columnCount()):
|
||||||
list_of_column_widths.append(str(self.tableView.columnWidth(i)))
|
list_of_column_widths.append(str(self.tableView.columnWidth(i)))
|
||||||
column_widths_as_string = ",".join(list_of_column_widths)
|
column_widths_as_string = ",".join(list_of_column_widths)
|
||||||
|
debug(f'saving column widths: {column_widths_as_string}')
|
||||||
self.config["table"]["column_widths"] = column_widths_as_string
|
self.config["table"]["column_widths"] = column_widths_as_string
|
||||||
self.config["settings"]["volume"] = str(self.current_volume)
|
self.config["settings"]["volume"] = str(self.current_volume)
|
||||||
self.config["settings"]["window_size"] = (
|
self.config["settings"]["window_size"] = (
|
||||||
@ -296,8 +297,11 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Save the config
|
# Save the config
|
||||||
with open(self.cfg_file, "w") as configfile:
|
try:
|
||||||
self.config.write(configfile)
|
with open(self.cfg_file, "w") as configfile:
|
||||||
|
self.config.write(configfile)
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'wtf man {e}')
|
||||||
if a0 is not None:
|
if a0 is not None:
|
||||||
super().closeEvent(a0)
|
super().closeEvent(a0)
|
||||||
|
|
||||||
|
|||||||
@ -34,9 +34,9 @@ def add_files_to_database(files, progress_callback=None):
|
|||||||
filename = filepath.split("/")[-1]
|
filename = filepath.split("/")[-1]
|
||||||
|
|
||||||
audio, details = get_id3_tags(filepath)
|
audio, details = get_id3_tags(filepath)
|
||||||
print('got id3 tags')
|
# print('got id3 tags')
|
||||||
print(type(audio))
|
# print(type(audio))
|
||||||
print(audio)
|
# print(audio)
|
||||||
if not isinstance(audio, ID3):
|
if not isinstance(audio, ID3):
|
||||||
failed_dict[filepath] = details
|
failed_dict[filepath] = details
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -14,11 +14,12 @@ def delete_album_art(file: str) -> bool:
|
|||||||
True on success, False on failure
|
True on success, False on failure
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
debug("Deleting album art")
|
||||||
audio = ID3(file)
|
audio = ID3(file)
|
||||||
debug(audio)
|
debug(audio)
|
||||||
if "APIC:" in audio:
|
if "APIC:" in audio:
|
||||||
del audio["APIC:"]
|
del audio["APIC:"]
|
||||||
debug("Deleting album art")
|
debug("Deleting album art for real this time")
|
||||||
audio.save()
|
audio.save()
|
||||||
else:
|
else:
|
||||||
warning("delete_album_art_for_current_song() | no tag called APIC")
|
warning("delete_album_art_for_current_song() | no tag called APIC")
|
||||||
|
|||||||
@ -92,7 +92,7 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
True / False"""
|
True / False"""
|
||||||
debug(f"filepath: {filepath} | tag_name: {tag_name} | value: {value}")
|
# debug(f"filepath: {filepath} | tag_name: {tag_name} | value: {value}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try: # Load existing tags
|
try: # Load existing tags
|
||||||
@ -124,7 +124,7 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
|||||||
tag_name = id3_tag_mapping[tag_name]
|
tag_name = id3_tag_mapping[tag_name]
|
||||||
# Other
|
# Other
|
||||||
if tag_name in mutagen_id3_tag_mapping: # Tag accounted for
|
if tag_name in mutagen_id3_tag_mapping: # Tag accounted for
|
||||||
debug(f"tag_name = {tag_name}")
|
# debug(f"tag_name = {tag_name}")
|
||||||
tag_class = mutagen_id3_tag_mapping[tag_name]
|
tag_class = mutagen_id3_tag_mapping[tag_name]
|
||||||
if issubclass(tag_class, Frame):
|
if issubclass(tag_class, Frame):
|
||||||
frame = tag_class(encoding=3, text=[value])
|
frame = tag_class(encoding=3, text=[value])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user