Changeset View
Changeset View
Standalone View
Standalone View
src/writers/taglibwriter.cpp
Show All 13 Lines | |||||
14 | 14 | | |||
15 | TagLib::String q2t(const QString& q) | 15 | TagLib::String q2t(const QString& q) | ||
16 | { | 16 | { | ||
17 | return TagLib::String(q.toStdWString()); | 17 | return TagLib::String(q.toStdWString()); | ||
18 | } | 18 | } | ||
19 | 19 | | |||
20 | QStringList TagLibWriter::writeMimetypes() const | 20 | QStringList TagLibWriter::writeMimetypes() const | ||
21 | { | 21 | { | ||
22 | QStringList types = { | 22 | QStringList types = { | ||
23 | QStringLiteral("audio/flac"), | ||||
24 | QStringLiteral("audio/mp4"), | ||||
svuorela: Unrelated. but consider making this static ? | |||||
Never really though about that, but should be static, yes. None of the writers and extractors I looked at currently do this, so if I find time I will do that for all at once and separately astippich: Never really though about that, but should be static, yes. None of the writers and extractors I… | |||||
23 | QStringLiteral("audio/mpeg"), | 25 | QStringLiteral("audio/mpeg"), | ||
Can you also order these alphabetically based on the main mime type (aliases immediate after)? bruns: Can you also order these alphabetically based on the main mime type (aliases immediate after)? | |||||
24 | QStringLiteral("audio/mpeg3"), | 26 | QStringLiteral("audio/mpeg3"), | ||
25 | QStringLiteral("audio/x-mpeg"), | 27 | QStringLiteral("audio/ogg"), | ||
26 | QStringLiteral("audio/opus"), | 28 | QStringLiteral("audio/opus"), | ||
27 | QStringLiteral("audio/x-opus+ogg") | 29 | QStringLiteral("audio/x-mpeg"), | ||
30 | QStringLiteral("audio/x-musepack"), | ||||
audio/wav and the next three are not backed by tests AFAICS, can you add these in a separate review, accompanied by tests files? bruns: audio/wav and the next three are not backed by tests AFAICS, can you add these in a separate… | |||||
31 | QStringLiteral("audio/x-opus+ogg"), | ||||
32 | QStringLiteral("audio/x-vorbis+ogg"), | ||||
28 | }; | 33 | }; | ||
29 | 34 | | |||
30 | return types; | 35 | return types; | ||
31 | } | 36 | } | ||
32 | 37 | | |||
33 | void TagLibWriter::write(const WriteData& data) | 38 | void TagLibWriter::write(const WriteData& data) | ||
34 | { | 39 | { | ||
35 | const QString fileUrl = data.inputUrl(); | 40 | const QString fileUrl = data.inputUrl(); | ||
36 | const PropertyMap properties = data.getAllProperties(); | 41 | const PropertyMap properties = data.getAllProperties(); | ||
37 | 42 | | |||
38 | TagLib::FileRef file(fileUrl.toUtf8().constData(), true); | 43 | TagLib::FileRef file(fileUrl.toUtf8().constData(), true); | ||
39 | if (file.isNull()) { | 44 | if (file.isNull()) { | ||
40 | return; | 45 | return; | ||
41 | } | 46 | } | ||
42 | 47 | | |||
43 | TagLib::Tag* tags = file.tag(); | 48 | TagLib::Tag* tags = file.tag(); | ||
44 | 49 | | |||
45 | TagLib::String title; | 50 | TagLib::String title; | ||
46 | TagLib::String artists; | 51 | TagLib::String artist; | ||
52 | TagLib::String album; | ||||
53 | TagLib::String genre; | ||||
54 | TagLib::String comment; | ||||
47 | 55 | | |||
48 | if (properties.contains(Property::Title)) { | 56 | if (properties.contains(Property::Title)) { | ||
49 | title = q2t(properties.value(Property::Title).toString()); | 57 | title = q2t(properties.value(Property::Title).toString()); | ||
50 | tags->setTitle(title); | 58 | tags->setTitle(title); | ||
51 | } | 59 | } | ||
52 | 60 | | |||
53 | if (properties.contains(Property::Artist)) { | 61 | if (properties.contains(Property::Artist)) { | ||
54 | artists = q2t(properties.value(Property::Artist).toString()); | 62 | artist = q2t(properties.value(Property::Artist).toString()); | ||
55 | tags->setArtist(artists); | 63 | tags->setArtist(artist); | ||
64 | } | ||||
65 | | ||||
66 | if (properties.contains(Property::Album)) { | ||||
67 | album = q2t(properties.value(Property::Album).toString()); | ||||
68 | tags->setAlbum(album); | ||||
56 | } | 69 | } | ||
57 | 70 | | |||
71 | if (properties.contains(Property::TrackNumber)) { | ||||
72 | int trackNumber = properties.value(Property::TrackNumber).toInt(); | ||||
73 | //taglib requires uint | ||||
74 | if (trackNumber >= 0) { | ||||
75 | tags->setTrack(trackNumber); | ||||
76 | } | ||||
77 | } | ||||
78 | | ||||
79 | if (properties.contains(Property::ReleaseYear)) { | ||||
80 | int year = properties.value(Property::ReleaseYear).toInt(); | ||||
81 | //taglib requires uint | ||||
82 | if (year >= 0) { | ||||
83 | tags->setYear(year); | ||||
84 | } | ||||
85 | } | ||||
86 | | ||||
87 | if (properties.contains(Property::Genre)) { | ||||
88 | genre = q2t(properties.value(Property::Genre).toString()); | ||||
89 | tags->setGenre(genre); | ||||
90 | } | ||||
91 | | ||||
92 | if (properties.contains(Property::Comment)) { | ||||
93 | comment = q2t(properties.value(Property::Comment).toString()); | ||||
94 | tags->setComment(comment); | ||||
95 | } | ||||
96 | | ||||
97 | | ||||
58 | file.save(); | 98 | file.save(); | ||
59 | } | 99 | } |
Unrelated. but consider making this static ?