diff --git a/lib/library.cpp b/lib/library.cpp index d2275f7a..440557e5 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -218,22 +218,33 @@ const std::string library :: Track :: primary_key() void library :: Track :: read(File &f) { + std::stringstream ss; + unsigned int minutes, seconds; + f >> library_id >> artist_id >> album_id >> genre_id; f >> track >> last_year >> last_month >> last_day; f >> play_count >> length; - length_str = f.getline(); title = f.getline(); filepath = f.getline(); + title_lower = filter :: lowercase(title); full_path = library_db.at(library_id)->root_path + "/" + filepath; library_db.at(library_id)->size++; + + minutes = length / 60; + seconds = length % 60; + ss << minutes << ":"; + if (seconds < 10) + ss << "0"; + ss << seconds; + length_str = ss.str(); } void library :: Track :: write(File &f) { f << library_id << " " << artist_id << " " << album_id << " " << genre_id; f << " " << track << " " << last_year << " " << last_month << " " << last_day; - f << " " << play_count << " " << length << " " << length_str << std :: endl; + f << " " << play_count << " " << length; // << std :: endl; f << title << std :: endl; f << filepath; }