8 #include <audioproperties.h>
26 if (!tag || !metadata)
29 if (!metadata->
Artist().isEmpty())
30 tag->setArtist(QStringToTString(metadata->
Artist()));
32 if (!metadata->
Title().isEmpty())
33 tag->setTitle(QStringToTString(metadata->
Title()));
35 if (!metadata->
Album().isEmpty())
36 tag->setAlbum(QStringToTString(metadata->
Album()));
38 if (metadata->
Year() > 999 && metadata->
Year() < 10000)
39 tag->setYear(metadata->
Year());
41 if (!metadata->
Genre().isEmpty())
42 tag->setGenre(QStringToTString(metadata->
Genre()));
44 if (0 != metadata->
Track())
45 tag->setTrack(metadata->
Track());
56 if (!tag || ! metadata)
62 metadata->
setTitle(TStringToQString(tag->title()).trimmed());
63 metadata->
setArtist(TStringToQString(tag->artist()).trimmed());
64 metadata->
setAlbum(TStringToQString(tag->album()).trimmed());
67 metadata->
setGenre(TStringToQString(tag->genre()).trimmed());
71 if (metadata->
Title().isEmpty())
75 if (metadata->
Title().isEmpty() && metadata->
Artist().isEmpty())
77 LOG(VB_GENERAL, LOG_ERR,
78 QString(
"MetaIOTagLib: Failed to read metadata from '%1'")
91 std::chrono::milliseconds milliseconds = 0ms;
94 milliseconds = std::chrono::milliseconds(
file->audioProperties()->lengthInMilliseconds());
107 std::chrono::milliseconds milliseconds = 0ms;
108 QByteArray fname =
filename.toLocal8Bit();
109 auto *
file =
new TagLib::FileRef(fname.constData());
111 if (
file &&
file->audioProperties())
112 milliseconds = std::chrono::milliseconds(
file->audioProperties()->lengthInMilliseconds());
115 if (milliseconds <= 1s)
117 LOG(VB_GENERAL, LOG_ERR,
118 QString(
"MetaIOTagLib: Failed to read length "
119 "from '%1'. It may be corrupt.").arg(
filename));