empty cell if value in db row is NULL

This commit is contained in:
billypom on debian 2024-07-31 18:49:54 -04:00
parent 232d782cc3
commit 1bab037e77
4 changed files with 7 additions and 6 deletions

View File

@ -338,7 +338,7 @@ class MusicTable(QTableView):
# Populate the model
for row_data in data:
id, *rest_of_data = row_data
items = [QStandardItem(str(item)) for item in rest_of_data]
items = [QStandardItem(str(item) if item else "") for item in rest_of_data]
self.model.appendRow(items)
# store id using setData - useful for later faster db fetching
# row = self.model.rowCount() - 1

View File

@ -37,7 +37,7 @@ def add_files_to_library(files):
try:
track_number = audio["TRCK"].text[0]
except KeyError:
track_number = 0
track_number = None
try:
genre = audio["TCON"].text[0]
except KeyError:

View File

@ -6,7 +6,6 @@ import os
def get_id3_tags(file):
"""Get the ID3 tags for an audio file
# Parameters
`file` | str | Fully qualified path to file
@ -28,7 +27,7 @@ def get_id3_tags(file):
frame = TIT2(encoding=3, text=[title])
audio["TIT2"] = frame
except Exception as e:
print(f"get_id3_tags.py | Exception: {e}")
print(f"get_id3_tags.py | Could not assign file ID3 tag: {e}")
pass
try:
audio.save() # type: ignore

View File

@ -3,8 +3,10 @@ from mutagen.id3 import TYER, TDAT
def handle_year_and_date_id3_tag(date_str):
"""Handles date formatting on update in music table
Date format = YYYY-MM-DD"""
"""
Handles date formatting when updating a date record in the music table
Date format = YYYY-MM-DD
"""
match = re.match(r"(\d{4})[-/](\d{2})[-/](\d{2})", date_str)
if not match:
raise ValueError("Invalid date format")