after delete album artwork, set default in qgraphicsview
This commit is contained in:
parent
485f99f6d5
commit
da7d679248
5
main.py
5
main.py
@ -47,6 +47,7 @@ from components import (
|
||||
CreatePlaylistWindow,
|
||||
ExportPlaylistWindow,
|
||||
)
|
||||
from utils.get_album_art import get_album_art
|
||||
|
||||
# good help with signals slots in threads
|
||||
# https://stackoverflow.com/questions/52993677/how-do-i-setup-signals-and-slots-in-pyqt-with-qthreads-in-both-directions
|
||||
@ -389,6 +390,10 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
error(
|
||||
f"delete_album_art_for_current_song() | Error processing this file:\t {file}\n{exctype}\n{value}\n{traceback.format_exc()}"
|
||||
)
|
||||
# Load the default album artwork in the qgraphicsview
|
||||
album_art_data = self.tableView.get_current_song_album_art()
|
||||
album_art_data = get_album_art(None)
|
||||
self.albumGraphicsView.load_album_art(album_art_data)
|
||||
|
||||
def update_audio_visualization(self) -> None:
|
||||
"""Handles upading points on the pyqtgraph visual"""
|
||||
|
||||
@ -2,7 +2,7 @@ from mutagen.id3 import ID3
|
||||
from logging import debug, error
|
||||
|
||||
|
||||
def get_album_art(file: str) -> bytes:
|
||||
def get_album_art(file: str | None) -> bytes:
|
||||
"""Get the album art for an audio file
|
||||
# Parameters
|
||||
`file` | str | Fully qualified path to file
|
||||
@ -10,15 +10,16 @@ def get_album_art(file: str) -> bytes:
|
||||
bytes for album art or placeholder artwork
|
||||
"""
|
||||
default_image_path = "./assets/default_album_art.jpg"
|
||||
try:
|
||||
audio = ID3(file)
|
||||
for tag in audio.getall("APIC"):
|
||||
if tag.type == 3: # 3 is the type for front cover
|
||||
return tag.data
|
||||
if audio.getall("APIC"):
|
||||
return audio.getall("APIC")[0].data
|
||||
except Exception as e:
|
||||
error(f"Error retrieving album art: {e}")
|
||||
if file:
|
||||
try:
|
||||
audio = ID3(file)
|
||||
for tag in audio.getall("APIC"):
|
||||
if tag.type == 3: # 3 is the type for front cover
|
||||
return tag.data
|
||||
if audio.getall("APIC"):
|
||||
return audio.getall("APIC")[0].data
|
||||
except Exception as e:
|
||||
error(f"Error retrieving album art: {e}")
|
||||
with open(default_image_path, "rb") as f:
|
||||
debug("loading placeholder album art")
|
||||
return f.read()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user