Decoded Cantata streamed file URLs

This commit is contained in:
craig
2012-03-04 19:45:15 +00:00
committed by craig
parent c3693f9414
commit 48edc1d7b2
3 changed files with 28 additions and 0 deletions

View File

@@ -198,3 +198,16 @@ Song HttpServer::decodeUrl(const QString &url) const
return s;
}
QString HttpServer::decodeFileUrl(const QString &file) const
{
if (isAlive()) {
QUrl u(file);
if (u.hasQueryItem("cantata") && u.queryItemValue("cantata")=="file") {
return u.path();
}
}
return QString();
}

View File

@@ -52,6 +52,7 @@ public:
QByteArray encodeUrl(const Song &s) const;
QByteArray encodeUrl(const QString &file) const;
Song decodeUrl(const QString &url) const;
QString decodeFileUrl(const QString &file) const;
private:
QThread *thread;

View File

@@ -28,6 +28,7 @@
#include "treeview.h"
#include "settings.h"
#include "mpdstatus.h"
#include "httpserver.h"
#include <QtGui/QStyledItemDelegate>
#include <QtGui/QApplication>
#include <QtGui/QFontMetrics>
@@ -207,6 +208,19 @@ public:
case AlbumHeader: {
QString album=song.album;
if (stream && album.isEmpty() && song.albumArtist().isEmpty()) {
title=song.file;
if (HttpServer::self()->isOurs(title)) {
QString decoded=HttpServer::self()->decodeFileUrl(title);
if (!decoded.isEmpty()) {
title=decoded;
}
}
if (song.title.isEmpty()) {
trackTitle=QString();
}
break;
}
if (song.year>0) {
album+=QString(" (%1)").arg(song.year);
}