Give streams key 0
This commit is contained in:
@@ -1576,7 +1576,7 @@ void MainWindow::updateCurrentSong(const Song &song)
|
||||
|
||||
current=song;
|
||||
|
||||
if (current.file.startsWith("http") && HttpServer::self()->isOurs(current.file)) {
|
||||
if (current.isCantataStream()) {
|
||||
Song mod=HttpServer::self()->decodeUrl(current.file);
|
||||
if (!mod.title.isEmpty()) {
|
||||
current=mod;
|
||||
|
||||
@@ -261,7 +261,7 @@ QList<Song> MPDParseUtils::parseSongs(const QByteArray &data)
|
||||
if (i == lines.size() - 1 || lines.at(i + 1).startsWith("file:")) {
|
||||
Song song=parseSong(line);
|
||||
|
||||
if (song.file.startsWith("http") && HttpServer::self()->isOurs(song.file)) {
|
||||
if (song.isCantataStream()) {
|
||||
Song mod=HttpServer::self()->decodeUrl(song.file);
|
||||
if (!mod.title.isEmpty()) {
|
||||
mod.id=song.id;
|
||||
|
||||
13
mpd/song.cpp
13
mpd/song.cpp
@@ -28,6 +28,7 @@
|
||||
#include "song.h"
|
||||
#include "mpdparseutils.h"
|
||||
#include "musiclibraryitemalbum.h"
|
||||
#include "httpserver.h"
|
||||
#ifdef ENABLE_KDE_SUPPORT
|
||||
#include <KDE/KLocale>
|
||||
#else
|
||||
@@ -139,12 +140,17 @@ void Song::setKey()
|
||||
static quint16 currentKey=0;
|
||||
static QMap<QString, quint16> keys;
|
||||
|
||||
if (isStream() && !isCantataStream()) {
|
||||
key=0;
|
||||
return;
|
||||
}
|
||||
|
||||
QString albumAndArtist=albumArtist()+QLatin1String("::")+album;
|
||||
QMap<QString, quint16>::ConstIterator it=keys.find(albumAndArtist);
|
||||
if (it!=keys.end()) {
|
||||
key=it.value();
|
||||
} else {
|
||||
currentKey++;
|
||||
currentKey++; // Key 0 is for streams, so we need to increment before setting...
|
||||
keys.insert(albumAndArtist, currentKey);
|
||||
key=currentKey;
|
||||
}
|
||||
@@ -314,3 +320,8 @@ bool Song::capitalise()
|
||||
|
||||
return artist!=origArtist || albumartist!=origAlbumArtist || album!=origAlbum || title!=origTitle;
|
||||
}
|
||||
|
||||
bool Song::isCantataStream() const
|
||||
{
|
||||
return !file.isEmpty() && file.startsWith("http") && HttpServer::self()->isOurs(file);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ struct Song
|
||||
static QString capitalize(const QString &s);
|
||||
bool capitalise();
|
||||
bool isStream() const { return file.isEmpty() || file.contains("://"); }
|
||||
bool isCantataStream() const;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Song)
|
||||
|
||||
Reference in New Issue
Block a user