subsonic: Consolidate read song code

This commit is contained in:
Jim Broadus 2020-05-12 22:41:03 -07:00 committed by John Maguire
parent ddba21a46f
commit 83fc376b08
1 changed files with 1 additions and 33 deletions

View File

@ -541,40 +541,8 @@ void SubsonicLibraryScanner::OnGetAlbumFinished(QNetworkReply* reply) {
return;
}
Song song;
QString id = reader.attributes().value("id").toString();
song.set_title(reader.attributes().value("title").toString());
song.set_album(reader.attributes().value("album").toString());
song.set_track(reader.attributes().value("track").toString().toInt());
song.set_disc(reader.attributes().value("discNumber").toString().toInt());
song.set_artist(reader.attributes().value("artist").toString());
Song song = service_->ReadSong(reader);
song.set_albumartist(album_artist);
song.set_bitrate(reader.attributes().value("bitRate").toString().toInt());
song.set_year(reader.attributes().value("year").toString().toInt());
song.set_genre(reader.attributes().value("genre").toString());
qint64 length = reader.attributes().value("duration").toString().toInt();
length *= kNsecPerSec;
song.set_length_nanosec(length);
QUrl url = QUrl(QString("subsonic://"));
QUrlQuery song_query(url.query());
song_query.addQueryItem("id", id);
url.setQuery(song_query);
QUrl cover_url = service_->BuildRequestUrl("getCoverArt");
QUrlQuery cover_url_query(cover_url.query());
cover_url_query.addQueryItem("id", id);
cover_url.setQuery(cover_url_query);
song.set_art_automatic(cover_url.toEncoded());
song.set_url(url);
song.set_filesize(reader.attributes().value("size").toString().toInt());
// We need to set these to satisfy the database constraints
song.set_directory_id(0);
song.set_mtime(0);
song.set_ctime(0);
if (reader.attributes().hasAttribute("playCount")) {
song.set_playcount(
reader.attributes().value("playCount").toString().toInt());
}
songs_ << song;
reader.skipCurrentElement();