ParserBase: Use original paths
This commit is contained in:
parent
4a24605361
commit
2953f9eefc
@ -63,23 +63,10 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strawberry always wants / separators internally.
|
filename = QDir::cleanPath(filename);
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QUrl url = QUrl::fromLocalFile(filename);
|
const QUrl url = QUrl::fromLocalFile(filename);
|
||||||
|
|
||||||
// Search in the collection
|
// Search the collection
|
||||||
if (collection_backend_ && collection_search) {
|
if (collection_backend_ && collection_search) {
|
||||||
Song collection_song;
|
Song collection_song;
|
||||||
if (track > 0) {
|
if (track > 0) {
|
||||||
@ -88,6 +75,19 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||||||
if (!collection_song.is_valid()) {
|
if (!collection_song.is_valid()) {
|
||||||
collection_song = collection_backend_->GetSongByUrl(url, beginning);
|
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 it was found in the collection then use it, otherwise load metadata from disk.
|
||||||
if (collection_song.is_valid()) {
|
if (collection_song.is_valid()) {
|
||||||
*song = collection_song;
|
*song = collection_song;
|
||||||
|
@ -63,7 +63,6 @@ class ParserBase : public QObject {
|
|||||||
|
|
||||||
protected:
|
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.
|
// 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.
|
// 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.
|
// 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;
|
Song LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_search) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user