diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index 1e065a1a7..3a97ce484 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -63,23 +63,10 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning } } - // Strawberry always wants / separators internally. - // Using QDir::fromNativeSeparators() only works on the same platform the playlist was created on/for, using replace() lets playlists work on any platform. - filename = filename.replace(QLatin1Char('\\'), QLatin1Char('/')); - - // Make the path absolute - if (!QDir::isAbsolutePath(filename)) { - filename = dir.absoluteFilePath(filename); - } - - // Use the canonical path - if (QFile::exists(filename)) { - filename = QFileInfo(filename).canonicalFilePath(); - } - + filename = QDir::cleanPath(filename); const QUrl url = QUrl::fromLocalFile(filename); - // Search in the collection + // Search the collection if (collection_backend_ && collection_search) { Song collection_song; if (track > 0) { @@ -88,6 +75,19 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning if (!collection_song.is_valid()) { collection_song = collection_backend_->GetSongByUrl(url, beginning); } + // Try absolute path + if (!collection_song.is_valid() && !QDir::isAbsolutePath(filename)) { + QString absolute_filename = dir.absoluteFilePath(filename); + if (absolute_filename != filename) { + const QUrl absolute_url = QUrl::fromLocalFile(absolute_filename); + if (track > 0) { + collection_song = collection_backend_->GetSongByUrlAndTrack(absolute_url, track); + } + if (!collection_song.is_valid()) { + collection_song = collection_backend_->GetSongByUrl(absolute_url, beginning); + } + } + } // If it was found in the collection then use it, otherwise load metadata from disk. if (collection_song.is_valid()) { *song = collection_song; diff --git a/src/playlistparsers/parserbase.h b/src/playlistparsers/parserbase.h index d7b825189..e121f9d72 100644 --- a/src/playlistparsers/parserbase.h +++ b/src/playlistparsers/parserbase.h @@ -63,7 +63,6 @@ class ParserBase : public QObject { protected: // Loads a song. If filename_or_url is a URL (with a scheme other than "file") then it is set on the song and the song marked as a stream. - // If it is a filename or a file:// URL then it is made absolute and canonical and set as a file:// url on the song. // Also sets the song's metadata by searching in the Collection, or loading from the file as a fallback. // This function should always be used when loading a playlist. Song LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_search) const;