small documentation changes and stuff

This commit is contained in:
billy 2025-04-08 16:17:45 -04:00
parent 40d78066c6
commit b8195cd3dd
2 changed files with 20 additions and 9 deletions

View File

@ -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"""

View File

@ -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"