If an album has no cover, use the generic image

This commit is contained in:
Raoul Snyman 2021-06-24 19:33:00 -07:00
parent 2c04c298e3
commit cb979e162b

View File

@ -2,6 +2,7 @@
The :mod:`threads` module contains functions to make working with QThreads easier
"""
import requests
import qtawesome as qta
from PyQt5 import QtCore, QtGui, QtWidgets
@ -66,9 +67,12 @@ class AlbumWorker(ThreadWorker):
}
album_item = QtWidgets.QListWidgetItem(self.ALBUM_TEMPLATE.format(**details))
self.window.albumListWidget.addItem(album_item)
if album['cover'] and album['cover'].get('urls') and album['cover']['urls'].get('medium_square_crop'):
artwork_worker = AlbumArtWorker()
artwork_worker.album_item = album_item
artwork_worker.artwork_url = album['cover']['urls']['medium_square_crop']
self.window.run_thread(artwork_worker, 'album-{}'.format(album['title']))
else:
album_item.setIcon(qta.icon('mdi.album'))
self.window.update_album_total(self.window.albumListWidget.count())
self.quit.emit()