Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use embedded cover art when needed #44

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions mpd-interface/mpdconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,9 +1569,21 @@ void MPDConnection::getCover(const Song& song)
QByteArray imageData;
bool firstRun = true;
QString path = Utils::getDir(song.file);
bool embedded = false;
while (dataToRead != 0) {
Response response = sendCommand("albumart " + encodeName(path) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead)));
if (!response.ok) {
Response response;
if (embedded) {
response = sendCommand("readpicture " + encodeName(song.file) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead)));
}
else {
response = sendCommand("albumart " + encodeName(path) + " " + QByteArray::number(firstRun ? 0 : (imageSize - dataToRead)));
}
if (!response.ok && !embedded && supportsReadPicture()) {
DBUG << "albumart query failed; trying embedded";
embedded = true;
continue;
}
else if (!response.ok) {
DBUG << "albumart query failed";
break;
}
Expand Down
1 change: 1 addition & 0 deletions mpd-interface/mpdconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class MPDConnection : public QObject {
bool modifiedFindSupported() const { return ver >= CANTATA_MAKE_VERSION(0, 19, 0); }
bool replaygainSupported() const { return ver >= CANTATA_MAKE_VERSION(0, 16, 0); }
bool supportsCoverDownload() const { return ver >= CANTATA_MAKE_VERSION(0, 21, 0) && isMpd(); }
bool supportsReadPicture() const { return ver >= CANTATA_MAKE_VERSION(0, 22, 0) && isMpd(); }
bool localFilePlaybackSupported() const;
bool stickersSupported() const { return canUseStickers; }

Expand Down
Loading