- Only attempt to load a cover from MPD dir if the song actually has a file path

- For streamed songs, add actual path to URL query
This commit is contained in:
craig.p.drummond@gmail.com
2012-05-12 20:07:32 +00:00
parent 385b8a298a
commit efd74979d3
2 changed files with 13 additions and 3 deletions

View File

@@ -33,6 +33,7 @@
#include <QtCore/QCryptographicHash>
#include <QtCore/QThread>
#include <QtCore/QMutex>
#include <QtCore/QUrl>
#include <QtNetwork/QNetworkReply>
#include <QtGui/QIcon>
#include <QtGui/QImage>
@@ -420,11 +421,17 @@ void Covers::clearDummyCache(const Song &song)
Covers::Image Covers::getImage(const Song &song)
{
QString dirName;
QString songFile=song.file;
bool haveAbsPath=song.file.startsWith('/');
if (haveAbsPath || !Settings::self()->mpdDir().isEmpty()) {
dirName=song.file.endsWith('/') ? (haveAbsPath ? QString() : Settings::self()->mpdDir())+song.file
: MPDParseUtils::getDir((haveAbsPath ? QString() : Settings::self()->mpdDir())+song.file);
if (song.isCantataStream()) {
QUrl u(songFile);
songFile=u.hasQueryItem("file") ? u.queryItemValue("file") : QString();
}
if (!songFile.isEmpty() &&
(haveAbsPath || !Settings::self()->mpdDir().isEmpty())) {
dirName=songFile.endsWith('/') ? (haveAbsPath ? QString() : Settings::self()->mpdDir())+songFile
: MPDParseUtils::getDir((haveAbsPath ? QString() : Settings::self()->mpdDir())+songFile);
initCoverNames();
foreach (const QString &fileName, coverFileNames) {
if (QFile::exists(dirName+fileName)) {

View File

@@ -138,6 +138,9 @@ QByteArray HttpServer::encodeUrl(const Song &s) const
if (s.track) {
url.addQueryItem("track", QString::number(s.track));
}
if (!s.file.isEmpty()) {
url.addQueryItem("file", s.file);
}
url.addQueryItem("cantata", "song");
return url.toEncoded();
}