1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 20:09:50 +01:00

Don't re-read song tags from files while loading a playlist if they're already avaiable in the library. Fixes issue #1165

This commit is contained in:
David Sansome 2010-12-25 14:41:31 +00:00
parent ced9a8b6e2
commit eca62e037b
5 changed files with 34 additions and 32 deletions

View File

@ -45,10 +45,12 @@ SongList AsxIniParser::Load(QIODevice *device, const QDir &dir) const {
// Load the song from the library if it's there.
Song library_song = LoadLibrarySong(song.filename());
if (library_song.is_valid())
if (library_song.is_valid()) {
ret << library_song;
else
} else {
song.InitFromFile(song.filename(), -1);
ret << song;
}
}
}

View File

@ -174,30 +174,27 @@ SongList CueParser::Load(QIODevice* device, const QDir& dir) const {
Song current;
if (!ParseTrackLocation(entry.file, dir, &current)) {
qWarning() << "failed to parse location in .cue file from " << dir_path;
} else {
// overwrite the stuff, we may have read from the file, using
// the .cue's metadata
if(i + 1 < entries.size()) {
// incorrect indices?
if(!UpdateSong(entry, entries.at(i + 1).index, &current)) {
continue;
}
} else {
// incorrect index?
if(!UpdateLastSong(entry, &current)) {
continue;
}
Song song = LoadLibrarySong(current.filename());
if (!song.is_valid()) {
song.InitFromFile(current.filename(), -1);
}
// overwrite the stuff, we may have read from the file, using
// the .cue's metadata
if(i + 1 < entries.size()) {
// incorrect indices?
if(!UpdateSong(entry, entries.at(i + 1).index, &song)) {
continue;
}
} else {
// incorrect index?
if(!UpdateLastSong(entry, &song)) {
continue;
}
}
Song final;
// TODO: make this work
// load this song from the library if it's there
// Song final = LoadLibrarySong(current.filename());
Song to_add = final.is_valid() ? final : current;
ret << to_add;
ret << song;
}
}

View File

@ -58,10 +58,6 @@ SongList M3UParser::Load(QIODevice* device, const QDir& dir) const {
}
} else {
Song song;
song.Init(current_metadata.title,
current_metadata.artist,
QString(), // Unknown album.
current_metadata.length);
// Track location.
if (!ParseTrackLocation(line, dir, &song)) {
@ -69,10 +65,16 @@ SongList M3UParser::Load(QIODevice* device, const QDir& dir) const {
} else {
// Load the song from the library if it's there.
Song library_song = LoadLibrarySong(song.filename());
if (library_song.is_valid())
if (library_song.is_valid()) {
ret << library_song;
else
} else {
song.Init(current_metadata.title,
current_metadata.artist,
QString(), // Unknown album.
current_metadata.length);
song.InitFromFile(song.filename(), -1);
ret << song;
}
current_metadata.artist.clear();
current_metadata.title.clear();

View File

@ -54,7 +54,6 @@ bool ParserBase::ParseTrackLocation(const QString& filename_or_url,
QString absolute_path = dir.absoluteFilePath(proper_path);
song->set_filename(absolute_path);
}
song->InitFromFile(song->filename(), -1);
return true;
}

View File

@ -44,9 +44,11 @@ SongList PLSParser::Load(QIODevice *device, const QDir &dir) const {
// Load the song from the library if it's there.
Song library_song = LoadLibrarySong(songs[n].filename());
if (library_song.is_valid())
if (library_song.is_valid()) {
songs[n] = library_song;
} else {
songs[n].InitFromFile(songs[n].filename(), -1);
}
} else if (key.startsWith("title")) {
songs[n].set_title(value);
} else if (key.startsWith("length")) {