album art not working

This commit is contained in:
billypom on debian 2024-09-30 20:44:52 -04:00
parent 19c7407cdd
commit 49e8c12460
4 changed files with 21 additions and 12 deletions

View File

@ -7,7 +7,7 @@ from PyQt5.QtWidgets import (
QMenu,
QAction,
)
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QUrl, QPoint
from PyQt5.QtCore import QEvent, QMimeData, Qt, pyqtSignal, QUrl, QPoint
from PyQt5.QtGui import (
QDragEnterEvent,
QDragMoveEvent,
@ -23,7 +23,7 @@ class AlbumArtGraphicsView(QGraphicsView):
"""
albumArtDropped = pyqtSignal(str)
albumArtDeleted = pyqtSignal(str)
albumArtDeleted = pyqtSignal()
def __init__(self, parent=None):
super().__init__(parent)
@ -113,10 +113,11 @@ class AlbumArtGraphicsView(QGraphicsView):
"""Copies album art to the clipboard"""
if not self.scene().items():
return # dont care if no pic
# FIXME: i want types here. what is actually going on...
clipboard = self.qapp.clipboard()
pixmap_item = self.scene().items()[0]
clipboard.setPixmap(pixmap_item.pixmap())
if hasattr(pixmap_item, "pixmap"):
clipboard.setPixmap(pixmap_item.pixmap())
def paste_album_art_from_clipboard(self):
"""Handles pasting album art into a song via system clipboard"""

View File

@ -670,7 +670,6 @@ class MusicTable(QTableView):
self.selected_song_filepath = (
self.currentIndex().siblingAtColumn(self.table_headers.index("path")).data()
)
logging.info(self.selected_song_filepath)
def set_current_song_filepath(self) -> None:
"""Sets the filepath of the currently playing song"""

16
main.py
View File

@ -286,7 +286,6 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
"""Start playback of tableView.current_song_filepath track & moves playback slider"""
# get metadata
self.current_song_metadata = self.tableView.get_current_song_metadata()
logging.info("current song metadata: %s", self.current_song_metadata)
# read the file
url = QUrl.fromLocalFile(self.tableView.get_current_song_filepath())
# load the audio content
@ -364,12 +363,21 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
# delete APIC data
try:
audio = ID3(file)
print("AAAAAAAAAAAAAAAAAAAAA")
print(audio)
print("AAAAAAAAAAAAAAAAAAAAA")
if "APIC:" in audio:
del audio["APIC"]
del audio["APIC:"]
audio.save()
except Exception as e:
else:
logging.warning(
"delete_album_art_for_current_song() | no tag called APIC"
)
except Exception:
traceback.print_exc()
exctype, value = sys.exc_info()[:2]
logging.error(
f"delete_album_art_for_selected_songs() | Error processing {file}: {e}"
f"delete_album_art_for_current_song() | Error processing this file:\t {file}\n{exctype}\n{value}\n{traceback.format_exc()}"
)
def update_audio_visualization(self) -> None:

View File

@ -1,4 +1,5 @@
from mutagen.id3 import ID3, APIC
from mutagen.id3 import ID3
import logging
def get_album_art(file: str) -> bytes:
@ -6,7 +7,7 @@ def get_album_art(file: str) -> bytes:
# Parameters
`file` | str | Fully qualified path to file
# Returns
Data for album art or default file
bytes for album art or placeholder artwork
"""
default_image_path = "./assets/default_album_art.jpg"
try:
@ -19,5 +20,5 @@ def get_album_art(file: str) -> bytes:
except Exception as e:
print(f"Error retrieving album art: {e}")
with open(default_image_path, "rb") as f:
print(f"album art type: {type(f.read())}")
logging.info("loading placeholder album art")
return f.read()