id3 even better
This commit is contained in:
parent
53fed6e2b9
commit
87af077527
@ -1,9 +1,28 @@
|
|||||||
|
from configparser import ConfigParser
|
||||||
|
from pathlib import Path
|
||||||
|
from appdirs import user_config_dir
|
||||||
|
|
||||||
|
|
||||||
class HeaderTags:
|
class HeaderTags:
|
||||||
"""
|
"""
|
||||||
Utility class to converting between different "standards" for tags (headers, id3, etc)
|
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):
|
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 = {
|
self.db: dict = {
|
||||||
"title": "title",
|
"title": "title",
|
||||||
"artist": "artist",
|
"artist": "artist",
|
||||||
@ -55,3 +74,11 @@ class HeaderTags:
|
|||||||
"genre",
|
"genre",
|
||||||
"album_date",
|
"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
|
||||||
|
|||||||
@ -663,8 +663,8 @@ class MusicTable(QTableView):
|
|||||||
self.disconnect_layout_changed()
|
self.disconnect_layout_changed()
|
||||||
self.vertical_scroll_position = self.verticalScrollBar().value() # type: ignore
|
self.vertical_scroll_position = self.verticalScrollBar().value() # type: ignore
|
||||||
self.model2.clear()
|
self.model2.clear()
|
||||||
self.model2.setHorizontalHeaderLabels(list(self.headers.gui.values()))
|
self.model2.setHorizontalHeaderLabels(self.headers.get_user_gui_headers())
|
||||||
fields = ", ".join(list(self.headers.db.values()))
|
fields = ", ".join(self.headers.user_headers)
|
||||||
if playlist_id: # Load a playlist
|
if playlist_id: # Load a playlist
|
||||||
# Fetch playlist data
|
# Fetch playlist data
|
||||||
selected_playlist_id = playlist_id[0]
|
selected_playlist_id = playlist_id[0]
|
||||||
|
|||||||
@ -17,7 +17,7 @@ volume = 100
|
|||||||
window_size=1152,894
|
window_size=1152,894
|
||||||
|
|
||||||
[table]
|
[table]
|
||||||
# Music table options
|
# Music table user options
|
||||||
columns = title,artist,album,track_number,genre,codec,album_date,filepath
|
columns = title,artist,album,track_number,genre,codec,album_date,filepath
|
||||||
column_widths = 181,116,222,76,74,72,287,150
|
column_widths = 181,116,222,76,74,72,287,150
|
||||||
# 0 = no sort, 1 = ascending, 2 = descending
|
# 0 = no sort, 1 = ascending, 2 = descending
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user