From b8195cd3dd0d670efc434f855db2737790e4aa8f Mon Sep 17 00:00:00 2001 From: billy Date: Tue, 8 Apr 2025 16:17:45 -0400 Subject: [PATCH] small documentation changes and stuff --- components/MusicTable.py | 11 ++++++----- utils/get_id3_tags.py | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/components/MusicTable.py b/components/MusicTable.py index 6756ddd..2abf03d 100644 --- a/components/MusicTable.py +++ b/components/MusicTable.py @@ -343,7 +343,6 @@ class MusicTable(QTableView): """ When a cell is clicked, do some stuff :) """ - print(f"click - ({index.row()}, {index.column()})") current_index = self.currentIndex() if index == current_index: return @@ -418,10 +417,12 @@ class MusicTable(QTableView): - data returned from the original worker process function are returned here 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] - window = DebugWindow(details) - window.exec_() + if details: + window = DebugWindow(details) + window.exec_() # ____________________ # | | @@ -774,7 +775,7 @@ class MusicTable(QTableView): def get_selected_song_metadata(self) -> ID3 | dict: """Returns the selected song's ID3 tags""" - return get_id3_tags(self.selected_song_filepath) + return get_id3_tags(self.selected_song_filepath)[0] def get_selected_songs_db_ids(self) -> list: """Returns a list of id's for the selected songs""" @@ -794,7 +795,7 @@ class MusicTable(QTableView): def get_current_song_metadata(self) -> ID3 | dict: """Returns the currently playing song's ID3 tags""" - return get_id3_tags(self.current_song_filepath) + return get_id3_tags(self.current_song_filepath)[0] def get_current_song_album_art(self) -> bytes: """Returns the APIC data (album art lol) for the currently playing song""" diff --git a/utils/get_id3_tags.py b/utils/get_id3_tags.py index 6507069..85be3e3 100644 --- a/utils/get_id3_tags.py +++ b/utils/get_id3_tags.py @@ -5,8 +5,18 @@ from mutagen.id3._frames import TIT2 from mutagen.id3._util import ID3NoHeaderError -def get_id3_tags(filename: str) -> tuple[object, str]: - """Get the ID3 tags for an audio file""" +def get_id3_tags(filename: str) -> tuple[ID3 | dict, str]: + """ + Get the ID3 tags for an audio file + Returns a tuple of: + - mutagen ID3 object OR python dictionary + - string reason for failure (failure = empty dict above) + + Args + - filename + Returns + - tuple(ID3/dict, fail_reason) + """ # debug(filename) if filename.endswith(".mp3"): @@ -37,7 +47,7 @@ def get_id3_tags(filename: str) -> tuple[object, str]: except Exception as e: error(f"Could not assign file ID3 tag: {e}") - return None, f"Could not assign ID3 tag to file: {e}" - return None, "non mp3 file" + return {}, f"Could not assign ID3 tag to file: {e}" + return {}, "non mp3 file"