Changeset View
Changeset View
Standalone View
Standalone View
src/extractors/taglibextractor.cpp
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | 106 | { | |||
---|---|---|---|---|---|
159 | } | 159 | } | ||
160 | if (savedProperties.contains("COMPILATION")) { | 160 | if (savedProperties.contains("COMPILATION")) { | ||
161 | result->add(Property::Compilation, TStringToQString(savedProperties["COMPILATION"].toString()).trimmed()); | 161 | result->add(Property::Compilation, TStringToQString(savedProperties["COMPILATION"].toString()).trimmed()); | ||
162 | } | 162 | } | ||
163 | if (savedProperties.contains("LYRICS")) { | 163 | if (savedProperties.contains("LYRICS")) { | ||
164 | result->add(Property::Lyrics, TStringToQString(savedProperties["LYRICS"].toString()).trimmed()); | 164 | result->add(Property::Lyrics, TStringToQString(savedProperties["LYRICS"].toString()).trimmed()); | ||
165 | } | 165 | } | ||
166 | if (savedProperties.contains("ARTIST")) { | 166 | if (savedProperties.contains("ARTIST")) { | ||
167 | const auto artistString = TStringToQString(savedProperties["ARTIST"].toString(";")).trimmed(); | 167 | const auto artists = savedProperties["ARTIST"]; | ||
168 | const auto artists = contactsFromString(artistString); | | |||
169 | for (const auto& artist : artists) { | 168 | for (const auto& artist : artists) { | ||
170 | result->add(Property::Artist, artist); | 169 | result->add(Property::Artist, TStringToQString(artist).trimmed()); | ||
bruns: There is a small mismatch between this one (and all others below) and e.g. "LYRICS" above - one… | |||||
171 | } | 170 | } | ||
172 | } | 171 | } | ||
173 | if (savedProperties.contains("GENRE")) { | 172 | if (savedProperties.contains("GENRE")) { | ||
174 | const auto genreString = TStringToQString(savedProperties["GENRE"].toString(";")).trimmed(); | 173 | const auto genres = savedProperties["GENRE"]; | ||
175 | const auto genres = contactsFromString(genreString); | | |||
176 | for (const auto& genre : genres) { | 174 | for (const auto& genre : genres) { | ||
177 | result->add(Property::Genre, genre); | 175 | result->add(Property::Genre, TStringToQString(genre).trimmed()); | ||
178 | } | 176 | } | ||
179 | } | 177 | } | ||
180 | if (savedProperties.contains("ALBUMARTIST")) { | 178 | if (savedProperties.contains("ALBUMARTIST")) { | ||
181 | const auto albumArtistsString = TStringToQString(savedProperties["ALBUMARTIST"].toString(";")).trimmed(); | 179 | const auto albumArtists = savedProperties["ALBUMARTIST"]; | ||
182 | const auto albumArtists = contactsFromString(albumArtistsString); | 180 | for (const auto& albumArtist : albumArtists) { | ||
183 | for (const auto& res : albumArtists) { | 181 | result->add(Property::AlbumArtist, TStringToQString(albumArtist).trimmed()); | ||
184 | result->add(Property::AlbumArtist, res); | | |||
185 | } | 182 | } | ||
186 | } | 183 | } | ||
187 | if (savedProperties.contains("COMPOSER")) { | 184 | if (savedProperties.contains("COMPOSER")) { | ||
188 | const auto composersString = TStringToQString(savedProperties["COMPOSER"].toString(";")).trimmed(); | 185 | const auto composers = savedProperties["COMPOSER"]; | ||
189 | const auto composers = contactsFromString(composersString); | 186 | for (const auto& composer : composers) { | ||
190 | for (const auto& comp : composers) { | 187 | result->add(Property::Composer, TStringToQString(composer).trimmed()); | ||
191 | result->add(Property::Composer, comp); | | |||
192 | } | 188 | } | ||
193 | } | 189 | } | ||
194 | if (savedProperties.contains("LYRICIST")) { | 190 | if (savedProperties.contains("LYRICIST")) { | ||
195 | const auto lyricistsString = TStringToQString(savedProperties["LYRICIST"].toString(";")).trimmed(); | 191 | const auto lyricists = savedProperties["LYRICIST"]; | ||
196 | const auto lyricists = contactsFromString(lyricistsString); | 192 | for (const auto& lyricist : lyricists) { | ||
197 | for (const auto& lyr : lyricists) { | 193 | result->add(Property::Lyricist, TStringToQString(lyricist).trimmed()); | ||
198 | result->add(Property::Lyricist, lyr); | | |||
199 | } | 194 | } | ||
200 | } | 195 | } | ||
201 | if (savedProperties.contains("CONDUCTOR")) { | 196 | if (savedProperties.contains("CONDUCTOR")) { | ||
202 | const auto conductorString = TStringToQString(savedProperties["CONDUCTOR"].toString(";")).trimmed(); | 197 | const auto conductors = savedProperties["CONDUCTOR"]; | ||
203 | const auto conductors = contactsFromString(conductorString); | 198 | for (const auto& conductor : conductors) { | ||
204 | for (const auto& con: conductors) { | 199 | result->add(Property::Conductor, TStringToQString(conductor).trimmed()); | ||
205 | result->add(Property::Conductor, con); | | |||
206 | } | 200 | } | ||
207 | } | 201 | } | ||
208 | if (savedProperties.contains("ARRANGER")) { | 202 | if (savedProperties.contains("ARRANGER")) { | ||
209 | const auto arrangerString = TStringToQString(savedProperties["ARRANGER"].toString(";")).trimmed(); | 203 | const auto arrangers = savedProperties["ARRANGER"]; | ||
210 | const auto arrangers = contactsFromString(arrangerString); | 204 | for (const auto& arranger : arrangers) { | ||
211 | for (const auto& arr: arrangers) { | 205 | result->add(Property::Arranger, TStringToQString(arranger).trimmed()); | ||
212 | result->add(Property::Arranger, arr); | | |||
213 | } | 206 | } | ||
214 | } | 207 | } | ||
215 | if (savedProperties.contains("PERFORMER")) { | 208 | if (savedProperties.contains("PERFORMER")) { | ||
216 | const auto performersString = TStringToQString(savedProperties["PERFORMER"].toString(";")).trimmed(); | 209 | const auto performers = savedProperties["PERFORMER"]; | ||
217 | const auto performers = contactsFromString(performersString); | 210 | for (const auto& performer : performers) { | ||
218 | for (const auto& per: performers) { | 211 | result->add(Property::Performer, TStringToQString(performer).trimmed()); | ||
219 | result->add(Property::Performer, per); | | |||
220 | } | 212 | } | ||
221 | } | 213 | } | ||
222 | if (savedProperties.contains("AUTHOR")) { | 214 | if (savedProperties.contains("AUTHOR")) { | ||
223 | const auto authorString = TStringToQString(savedProperties["AUTHOR"].toString(";")).trimmed(); | 215 | const auto authors = savedProperties["AUTHOR"]; | ||
224 | const auto authors = contactsFromString(authorString); | 216 | for (const auto& author: authors) { | ||
225 | for (const auto& aut: authors) { | 217 | result->add(Property::Author, TStringToQString(author).trimmed()); | ||
226 | result->add(Property::Author, aut); | | |||
227 | } | 218 | } | ||
228 | } | 219 | } | ||
229 | 220 | | |||
230 | if (savedProperties.contains("REPLAYGAIN_TRACK_GAIN")) { | 221 | if (savedProperties.contains("REPLAYGAIN_TRACK_GAIN")) { | ||
231 | auto trackGainString = TStringToQString(savedProperties["REPLAYGAIN_TRACK_GAIN"].toString(";")).trimmed(); | 222 | auto trackGainString = TStringToQString(savedProperties["REPLAYGAIN_TRACK_GAIN"].toString(";")).trimmed(); | ||
232 | // remove " dB" suffix | 223 | // remove " dB" suffix | ||
233 | if (trackGainString.endsWith(QStringLiteral(" dB"), Qt::CaseInsensitive)) { | 224 | if (trackGainString.endsWith(QStringLiteral(" dB"), Qt::CaseInsensitive)) { | ||
234 | trackGainString.chop(3); | 225 | trackGainString.chop(3); | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 345 | } else if (rating == 1) { | |||
355 | rating = 2; | 346 | rating = 2; | ||
356 | } else { | 347 | } else { | ||
357 | rating = static_cast<int>(0.09 * rating + 2); | 348 | rating = static_cast<int>(0.09 * rating + 2); | ||
358 | } | 349 | } | ||
359 | result->add(Property::Rating, rating); | 350 | result->add(Property::Rating, rating); | ||
360 | } | 351 | } | ||
361 | 352 | | |||
362 | lstASF = asfTags->attribute("Author"); | 353 | lstASF = asfTags->attribute("Author"); | ||
363 | if (!lstASF.isEmpty()) { | 354 | if (!lstASF.isEmpty()) { | ||
bruns: is this always just one value, or a list as well? | |||||
as far as I know, asf only allows single entry tags, so just a single value astippich: as far as I know, asf only allows single entry tags, so just a single value | |||||
364 | const auto attribute = lstASF.front(); | 355 | const auto attribute = lstASF.front(); | ||
365 | const auto authors = contactsFromString(TStringToQString(attribute.toString()).trimmed()); | 356 | result->add(Property::Author, TStringToQString(attribute.toString()).trimmed()); | ||
366 | for (const auto& aut: authors) { | | |||
367 | result->add(Property::Author, aut); | | |||
368 | } | | |||
369 | } | 357 | } | ||
370 | 358 | | |||
371 | // Lyricist is called "WRITER" for wma/asf files | 359 | // Lyricist is called "WRITER" for wma/asf files | ||
372 | lstASF = asfTags->attribute("WM/Writer"); | 360 | lstASF = asfTags->attribute("WM/Writer"); | ||
373 | if (!lstASF.isEmpty()) { | 361 | if (!lstASF.isEmpty()) { | ||
374 | const auto attribute = lstASF.front(); | 362 | const auto attribute = lstASF.front(); | ||
375 | const auto lyricists = contactsFromString(TStringToQString(attribute.toString()).trimmed()); | 363 | result->add(Property::Lyricist, TStringToQString(attribute.toString()).trimmed()); | ||
376 | for (const auto& lyr : lyricists) { | | |||
377 | result->add(Property::Lyricist, lyr); | | |||
378 | } | | |||
379 | } | 364 | } | ||
380 | 365 | | |||
381 | /* | 366 | /* | ||
382 | * TagLib exports "WM/PUBLISHER" as "LABEL" in the PropertyMap, | 367 | * TagLib exports "WM/PUBLISHER" as "LABEL" in the PropertyMap, | ||
383 | * add it manually to Publisher. | 368 | * add it manually to Publisher. | ||
384 | */ | 369 | */ | ||
385 | lstASF = asfTags->attribute("WM/Publisher"); | 370 | lstASF = asfTags->attribute("WM/Publisher"); | ||
386 | if (!lstASF.isEmpty()) { | 371 | if (!lstASF.isEmpty()) { | ||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |
There is a small mismatch between this one (and all others below) and e.g. "LYRICS" above - one uses trimmed(), the other does not.
IMHO, all properties should be trimmed (though we risk not being roundtrip-save).