Fixed saving (APE) tags for WavPack files
This commit is contained in:
parent
1562585561
commit
0abeefd470
@ -22,6 +22,7 @@ Unreleased:
|
|||||||
* Added DSF and DSDIFF/DFF support
|
* Added DSF and DSDIFF/DFF support
|
||||||
* Fixed tagreader crash when saving tags to MP3 files
|
* Fixed tagreader crash when saving tags to MP3 files
|
||||||
* Added support for reading/writing lyrics to tags
|
* Added support for reading/writing lyrics to tags
|
||||||
|
* Fixed saving (APE) tags for WavPack files
|
||||||
|
|
||||||
Version 0.2.1:
|
Version 0.2.1:
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@
|
|||||||
#include <taglib/tstring.h>
|
#include <taglib/tstring.h>
|
||||||
#include <taglib/tstringlist.h>
|
#include <taglib/tstringlist.h>
|
||||||
#include <taglib/audioproperties.h>
|
#include <taglib/audioproperties.h>
|
||||||
#include <taglib/trueaudiofile.h>
|
|
||||||
#include <taglib/attachedpictureframe.h>
|
#include <taglib/attachedpictureframe.h>
|
||||||
#include <taglib/textidentificationframe.h>
|
#include <taglib/textidentificationframe.h>
|
||||||
|
#include <taglib/unsynchronizedlyricsframe.h>
|
||||||
#include <taglib/xiphcomment.h>
|
#include <taglib/xiphcomment.h>
|
||||||
#include <taglib/commentsframe.h>
|
#include <taglib/commentsframe.h>
|
||||||
#include <taglib/unsynchronizedlyricsframe.h>
|
|
||||||
#include <taglib/tag.h>
|
#include <taglib/tag.h>
|
||||||
|
#include <taglib/apetag.h>
|
||||||
#include <taglib/id3v2tag.h>
|
#include <taglib/id3v2tag.h>
|
||||||
#include "taglib/id3v2frame.h"
|
#include "taglib/id3v2frame.h"
|
||||||
#include <taglib/flacfile.h>
|
#include <taglib/flacfile.h>
|
||||||
@ -64,6 +64,7 @@
|
|||||||
#include <taglib/mpcfile.h>
|
#include <taglib/mpcfile.h>
|
||||||
#include <taglib/mpegfile.h>
|
#include <taglib/mpegfile.h>
|
||||||
#include <taglib/opusfile.h>
|
#include <taglib/opusfile.h>
|
||||||
|
#include <taglib/trueaudiofile.h>
|
||||||
#ifdef HAVE_TAGLIB_DSFFILE
|
#ifdef HAVE_TAGLIB_DSFFILE
|
||||||
# include <taglib/dsffile.h>
|
# include <taglib/dsffile.h>
|
||||||
# include <taglib/dsdifffile.h>
|
# include <taglib/dsdifffile.h>
|
||||||
@ -94,8 +95,6 @@
|
|||||||
# define TAGLIB_HAS_FLAC_PICTURELIST
|
# define TAGLIB_HAS_FLAC_PICTURELIST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NumberToASFAttribute(x) TagLib::ASF::Attribute(QStringToTaglibString(QString::number(x)))
|
|
||||||
|
|
||||||
class FileRefFactory {
|
class FileRefFactory {
|
||||||
public:
|
public:
|
||||||
virtual ~FileRefFactory() {}
|
virtual ~FileRefFactory() {}
|
||||||
@ -184,7 +183,6 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
|
|||||||
// Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way;
|
// Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way;
|
||||||
// apart, so we keep specific behavior for some formats by adding another "else if" block below.
|
// apart, so we keep specific behavior for some formats by adding another "else if" block below.
|
||||||
if (TagLib::Ogg::XiphComment *tag = dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) {
|
if (TagLib::Ogg::XiphComment *tag = dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) {
|
||||||
|
|
||||||
ParseOggTag(tag->fieldListMap(), nullptr, &disc, &compilation, song);
|
ParseOggTag(tag->fieldListMap(), nullptr, &disc, &compilation, song);
|
||||||
#if TAGLIB_MAJOR_VERSION >= 1 && TAGLIB_MINOR_VERSION >= 11
|
#if TAGLIB_MAJOR_VERSION >= 1 && TAGLIB_MINOR_VERSION >= 11
|
||||||
if (!tag->pictureList().isEmpty()) song->set_art_automatic(kEmbeddedCover);
|
if (!tag->pictureList().isEmpty()) song->set_art_automatic(kEmbeddedCover);
|
||||||
@ -203,12 +201,12 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Decode(tag->comment(), nullptr, song->mutable_comment());
|
if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File *>(fileref->file())) {
|
else if (TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File *>(fileref->file())) {
|
||||||
song->set_bitdepth(file->audioProperties()->bitsPerSample());
|
song->set_bitdepth(file->audioProperties()->bitsPerSample());
|
||||||
Decode(tag->comment(), nullptr, song->mutable_comment());
|
//if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
|
else if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
|
||||||
@ -367,6 +365,7 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
|
|||||||
SetDefault(bitdepth);
|
SetDefault(bitdepth);
|
||||||
SetDefault(lastplayed);
|
SetDefault(lastplayed);
|
||||||
#undef SetDefault
|
#undef SetDefault
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -383,6 +382,7 @@ void TagReader::Decode(const TagLib::String &tag, const QTextCodec *codec, std::
|
|||||||
}
|
}
|
||||||
|
|
||||||
output->assign(DataCommaSizeFromQString(tmp));
|
output->assign(DataCommaSizeFromQString(tmp));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReader::Decode(const QString &tag, const QTextCodec *codec, std::string *output) {
|
void TagReader::Decode(const QString &tag, const QTextCodec *codec, std::string *output) {
|
||||||
@ -394,6 +394,7 @@ void TagReader::Decode(const QString &tag, const QTextCodec *codec, std::string
|
|||||||
const QString decoded(codec->toUnicode(tag.toUtf8()));
|
const QString decoded(codec->toUnicode(tag.toUtf8()));
|
||||||
output->assign(DataCommaSizeFromQString(decoded));
|
output->assign(DataCommaSizeFromQString(decoded));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReader::ParseFMPSFrame(const QString &name, const QString &value, pb::tagreader::SongMetadata *song) const {
|
void TagReader::ParseFMPSFrame(const QString &name, const QString &value, pb::tagreader::SongMetadata *song) const {
|
||||||
@ -512,7 +513,22 @@ bool TagReader::SaveFile(const QString &filename, const pb::tagreader::SongMetad
|
|||||||
fileref->tag()->setYear(song.year());
|
fileref->tag()->setYear(song.year());
|
||||||
fileref->tag()->setTrack(song.track());
|
fileref->tag()->setTrack(song.track());
|
||||||
|
|
||||||
if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
|
if (TagLib::FLAC::File *file = dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
|
||||||
|
TagLib::Ogg::XiphComment *tag = file->xiphComment();
|
||||||
|
SetVorbisComments(tag, song);
|
||||||
|
}
|
||||||
|
else if (TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File*>(fileref->file())) {
|
||||||
|
TagLib::APE::Tag *tag = file->APETag(true);
|
||||||
|
if (!tag) return false;
|
||||||
|
tag->setArtist(StdStringToTaglibString(song.artist()));
|
||||||
|
tag->setAlbum(StdStringToTaglibString(song.album()));
|
||||||
|
tag->setTitle(StdStringToTaglibString(song.title()));
|
||||||
|
tag->setGenre(StdStringToTaglibString(song.genre()));
|
||||||
|
tag->setComment(StdStringToTaglibString(song.comment()));
|
||||||
|
tag->setYear(song.year());
|
||||||
|
tag->setTrack(song.track());
|
||||||
|
}
|
||||||
|
else if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
|
||||||
TagLib::ID3v2::Tag *tag = file->ID3v2Tag(true);
|
TagLib::ID3v2::Tag *tag = file->ID3v2Tag(true);
|
||||||
if (!tag) return false;
|
if (!tag) return false;
|
||||||
SetTextFrame("TPOS", song.disc() <= 0 -1 ? QString() : QString::number(song.disc()), tag);
|
SetTextFrame("TPOS", song.disc() <= 0 -1 ? QString() : QString::number(song.disc()), tag);
|
||||||
@ -524,10 +540,6 @@ bool TagReader::SaveFile(const QString &filename, const pb::tagreader::SongMetad
|
|||||||
SetTextFrame("TCMP", std::string(song.compilation() ? "1" : "0"), tag);
|
SetTextFrame("TCMP", std::string(song.compilation() ? "1" : "0"), tag);
|
||||||
SetUnsyncLyricsFrame(song.lyrics(), tag);
|
SetUnsyncLyricsFrame(song.lyrics(), tag);
|
||||||
}
|
}
|
||||||
else if (TagLib::FLAC::File *file = dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
|
|
||||||
TagLib::Ogg::XiphComment *tag = file->xiphComment();
|
|
||||||
SetVorbisComments(tag, song);
|
|
||||||
}
|
|
||||||
else if (TagLib::MP4::File *file = dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
else if (TagLib::MP4::File *file = dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
||||||
TagLib::MP4::Tag *tag = file->tag();
|
TagLib::MP4::Tag *tag = file->tag();
|
||||||
tag->itemListMap()["disk"] = TagLib::MP4::Item(song.disc() <= 0 -1 ? 0 : song.disc(), 0);
|
tag->itemListMap()["disk"] = TagLib::MP4::Item(song.disc() <= 0 -1 ? 0 : song.disc(), 0);
|
||||||
@ -579,6 +591,7 @@ void TagReader::SetUserTextFrame(const std::string &description, const std::stri
|
|||||||
frame->setDescription(t_description);
|
frame->setDescription(t_description);
|
||||||
frame->setText(StdStringToTaglibString(value));
|
frame->setText(StdStringToTaglibString(value));
|
||||||
tag->addFrame(frame);
|
tag->addFrame(frame);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReader::SetTextFrame(const char *id, const QString &value, TagLib::ID3v2::Tag *tag) const {
|
void TagReader::SetTextFrame(const char *id, const QString &value, TagLib::ID3v2::Tag *tag) const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user