id3 even better

This commit is contained in:
tsi-billypom 2025-04-18 11:14:01 -04:00
parent 53fed6e2b9
commit 87af077527
3 changed files with 30 additions and 3 deletions

View File

@ -1,9 +1,28 @@
from configparser import ConfigParser
from pathlib import Path
from appdirs import user_config_dir
class HeaderTags:
"""
Utility class to converting between different "standards" for tags (headers, id3, etc)
`db`: dict = "db name": "db name string"
`gui`: dict = "db name": "gui string"
`id3`: dict = "db name": "id3 tag string"
`id3_keys`: dict = "id3 tag string": "db name"
`editable_db_tags`: list = "list of db names that are user editable"
`user_headers`: list = "list of db headers that the user has chosen to see in gui"
"""
def __init__(self):
cfg_file = (
Path(user_config_dir(appname="musicpom", appauthor="billypom"))
/ "config.ini"
)
self.config = ConfigParser()
self.config.read(cfg_file)
self.user_headers = str(self.config["table"]["columns"]).split(",")
self.db: dict = {
"title": "title",
"artist": "artist",
@ -55,3 +74,11 @@ class HeaderTags:
"genre",
"album_date",
]
def get_user_gui_headers(self) -> list:
"""Returns a list of headers for the GUI"""
gui_headers = []
for db, gui in self.gui.items():
if db in self.user_headers:
gui_headers.append(gui)
return gui_headers

View File

@ -663,8 +663,8 @@ class MusicTable(QTableView):
self.disconnect_layout_changed()
self.vertical_scroll_position = self.verticalScrollBar().value() # type: ignore
self.model2.clear()
self.model2.setHorizontalHeaderLabels(list(self.headers.gui.values()))
fields = ", ".join(list(self.headers.db.values()))
self.model2.setHorizontalHeaderLabels(self.headers.get_user_gui_headers())
fields = ", ".join(self.headers.user_headers)
if playlist_id: # Load a playlist
# Fetch playlist data
selected_playlist_id = playlist_id[0]

View File

@ -17,7 +17,7 @@ volume = 100
window_size=1152,894
[table]
# Music table options
# Music table user options
columns = title,artist,album,track_number,genre,codec,album_date,filepath
column_widths = 181,116,222,76,74,72,287,150
# 0 = no sort, 1 = ascending, 2 = descending