album art not working
This commit is contained in:
parent
19c7407cdd
commit
49e8c12460
@ -7,7 +7,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QMenu,
|
QMenu,
|
||||||
QAction,
|
QAction,
|
||||||
)
|
)
|
||||||
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QUrl, QPoint
|
from PyQt5.QtCore import QEvent, QMimeData, Qt, pyqtSignal, QUrl, QPoint
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QDragEnterEvent,
|
QDragEnterEvent,
|
||||||
QDragMoveEvent,
|
QDragMoveEvent,
|
||||||
@ -23,7 +23,7 @@ class AlbumArtGraphicsView(QGraphicsView):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
albumArtDropped = pyqtSignal(str)
|
albumArtDropped = pyqtSignal(str)
|
||||||
albumArtDeleted = pyqtSignal(str)
|
albumArtDeleted = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -113,9 +113,10 @@ class AlbumArtGraphicsView(QGraphicsView):
|
|||||||
"""Copies album art to the clipboard"""
|
"""Copies album art to the clipboard"""
|
||||||
if not self.scene().items():
|
if not self.scene().items():
|
||||||
return # dont care if no pic
|
return # dont care if no pic
|
||||||
# FIXME: i want types here. what is actually going on...
|
|
||||||
clipboard = self.qapp.clipboard()
|
clipboard = self.qapp.clipboard()
|
||||||
pixmap_item = self.scene().items()[0]
|
pixmap_item = self.scene().items()[0]
|
||||||
|
if hasattr(pixmap_item, "pixmap"):
|
||||||
clipboard.setPixmap(pixmap_item.pixmap())
|
clipboard.setPixmap(pixmap_item.pixmap())
|
||||||
|
|
||||||
def paste_album_art_from_clipboard(self):
|
def paste_album_art_from_clipboard(self):
|
||||||
|
|||||||
@ -670,7 +670,6 @@ class MusicTable(QTableView):
|
|||||||
self.selected_song_filepath = (
|
self.selected_song_filepath = (
|
||||||
self.currentIndex().siblingAtColumn(self.table_headers.index("path")).data()
|
self.currentIndex().siblingAtColumn(self.table_headers.index("path")).data()
|
||||||
)
|
)
|
||||||
logging.info(self.selected_song_filepath)
|
|
||||||
|
|
||||||
def set_current_song_filepath(self) -> None:
|
def set_current_song_filepath(self) -> None:
|
||||||
"""Sets the filepath of the currently playing song"""
|
"""Sets the filepath of the currently playing song"""
|
||||||
|
|||||||
16
main.py
16
main.py
@ -286,7 +286,6 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
"""Start playback of tableView.current_song_filepath track & moves playback slider"""
|
"""Start playback of tableView.current_song_filepath track & moves playback slider"""
|
||||||
# get metadata
|
# get metadata
|
||||||
self.current_song_metadata = self.tableView.get_current_song_metadata()
|
self.current_song_metadata = self.tableView.get_current_song_metadata()
|
||||||
logging.info("current song metadata: %s", self.current_song_metadata)
|
|
||||||
# read the file
|
# read the file
|
||||||
url = QUrl.fromLocalFile(self.tableView.get_current_song_filepath())
|
url = QUrl.fromLocalFile(self.tableView.get_current_song_filepath())
|
||||||
# load the audio content
|
# load the audio content
|
||||||
@ -364,12 +363,21 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# delete APIC data
|
# delete APIC data
|
||||||
try:
|
try:
|
||||||
audio = ID3(file)
|
audio = ID3(file)
|
||||||
|
print("AAAAAAAAAAAAAAAAAAAAA")
|
||||||
|
print(audio)
|
||||||
|
print("AAAAAAAAAAAAAAAAAAAAA")
|
||||||
if "APIC:" in audio:
|
if "APIC:" in audio:
|
||||||
del audio["APIC"]
|
del audio["APIC:"]
|
||||||
audio.save()
|
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(
|
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:
|
def update_audio_visualization(self) -> None:
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from mutagen.id3 import ID3, APIC
|
from mutagen.id3 import ID3
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def get_album_art(file: str) -> bytes:
|
def get_album_art(file: str) -> bytes:
|
||||||
@ -6,7 +7,7 @@ def get_album_art(file: str) -> bytes:
|
|||||||
# Parameters
|
# Parameters
|
||||||
`file` | str | Fully qualified path to file
|
`file` | str | Fully qualified path to file
|
||||||
# Returns
|
# Returns
|
||||||
Data for album art or default file
|
bytes for album art or placeholder artwork
|
||||||
"""
|
"""
|
||||||
default_image_path = "./assets/default_album_art.jpg"
|
default_image_path = "./assets/default_album_art.jpg"
|
||||||
try:
|
try:
|
||||||
@ -19,5 +20,5 @@ def get_album_art(file: str) -> bytes:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error retrieving album art: {e}")
|
print(f"Error retrieving album art: {e}")
|
||||||
with open(default_image_path, "rb") as f:
|
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()
|
return f.read()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user