MythTV  master
metaioid3.h
Go to the documentation of this file.
1 #ifndef METAIOID3_H_
2 #define METAIOID3_H_
3 
4 // libmythmetadata
5 #include "metaiotaglib.h"
6 #include "musicmetadata.h"
7 
8 // Taglib
9 #include <id3v1tag.h>
10 #include <id3v2tag.h>
11 #include <textidentificationframe.h>
12 #include <attachedpictureframe.h>
13 #include <popularimeterframe.h>
14 #include <tfile.h>
15 
16 // QT
17 #include <QList>
18 
19 using TagLib::ID3v2::UserTextIdentificationFrame;
20 using TagLib::ID3v2::TextIdentificationFrame;
21 using TagLib::ID3v2::PopularimeterFrame;
22 using TagLib::ID3v2::AttachedPictureFrame;
23 
34 {
35  public:
36  MetaIOID3(void) = default;
37  ~MetaIOID3(void) override { CloseFile(); }
38 
39  bool write(const QString &filename, MusicMetadata* mdata) override; // MetaIOTagLib
40  bool writeVolatileMetadata(const QString &filename, MusicMetadata* mdata) override; // MetaIO
41 
42  bool writeAlbumArt(const QString &filename, const AlbumArtImage *albumart) override; // MetaIO
43  bool removeAlbumArt(const QString &filename, const AlbumArtImage *albumart) override; // MetaIO
44 
45  MusicMetadata* read(const QString &filename) override; // MetaIOTagLib
46  AlbumArtList getAlbumArtList(const QString &filename) override; // MetaIO
47  QImage *getAlbumArt(const QString &filename, ImageType type) override; // MetaIO
48 
49  bool supportsEmbeddedImages(void) override { return true; } // MetaIO
50 
51  bool changeImageType(const QString &filename, const AlbumArtImage *albumart,
52  ImageType newType) override; // MetaIO
53 
54  bool TagExists(const QString &filename) override; // MetaIO
55 
56  private:
57  bool OpenFile(const QString &filename, bool forWriting = false);
58  bool SaveFile();
59  void CloseFile();
60 
61  TagLib::ID3v2::Tag* GetID3v2Tag(bool create = false);
62  TagLib::ID3v1::Tag* GetID3v1Tag(bool create = false);
63 
64  static bool writePlayCount(TagLib::ID3v2::Tag *tag, int playcount);
65  static bool writeRating(TagLib::ID3v2::Tag *tag, int rating);
66  static bool writeLastPlay(TagLib::ID3v2::Tag *tag, QDateTime lastPlay);
67 
68  static AlbumArtList readAlbumArt(TagLib::ID3v2::Tag *tag);
69  static UserTextIdentificationFrame* find(TagLib::ID3v2::Tag *tag,
70  const String &description);
71  static PopularimeterFrame* findPOPM(TagLib::ID3v2::Tag *tag, const String &email);
72  static AttachedPictureFrame* findAPIC(TagLib::ID3v2::Tag *tag,
73  const AttachedPictureFrame::Type &type,
74  const String &description = String::null);
75  static QString getExtFromMimeType(const QString &mimeType);
76 
77  TagLib::File *m_file {nullptr};
78 
79  enum TagType { kMPEG, kFLAC };
80  TagType m_fileType {kMPEG};
81 };
82 
83 #endif
MetaIO::getAlbumArt
virtual QImage * getAlbumArt(const QString &filename, ImageType type)
Definition: metaio.h:103
MetaIOTagLib::write
bool write(const QString &filename, MusicMetadata *mdata) override=0
Writes all metadata back to a file.
MetaIO::writeAlbumArt
virtual bool writeAlbumArt(const QString &filename, const AlbumArtImage *albumart)
Definition: metaio.h:77
MusicMetadata
Definition: musicmetadata.h:81
MetaIO::changeImageType
virtual bool changeImageType(const QString &filename, const AlbumArtImage *albumart, ImageType newType)
Definition: metaio.h:93
MetaIOTagLib::read
MusicMetadata * read(const QString &filename) override=0
Reads MusicMetadata from a file.
MetaIOID3::MetaIOID3
MetaIOID3(void)=default
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:39
MetaIO::removeAlbumArt
virtual bool removeAlbumArt(const QString &filename, const AlbumArtImage *albumart)
Definition: metaio.h:85
MetaIOID3::TagType
TagType
Definition: metaioid3.h:79
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
MetaIOTagLib
Base for Taglib metadata classes.
Definition: metaiotaglib.h:21
metaiotaglib.h
MetaIO::getAlbumArtList
virtual AlbumArtList getAlbumArtList(const QString &filename)
Reads the list of embedded images in the tag.
Definition: metaio.h:71
MetaIOID3::supportsEmbeddedImages
bool supportsEmbeddedImages(void) override
Does the tag support embedded cover art.
Definition: metaioid3.h:49
AlbumArtList
QList< AlbumArtImage * > AlbumArtList
Definition: musicmetadata.h:56
MetaIO::writeVolatileMetadata
virtual bool writeVolatileMetadata(const QString &filename, MusicMetadata *mdata)
Writes rating and playcount back to a file.
Definition: metaio.h:38
AlbumArtImage
Definition: musicmetadata.h:40
MetaIO::TagExists
virtual bool TagExists(const QString &filename)
Definition: metaio.h:135
MetaIOID3::~MetaIOID3
~MetaIOID3(void) override
Definition: metaioid3.h:37
email
const String email
Definition: metaioid3.cpp:22
MetaIOID3
Read and write metadata in MPEG (mp3) ID3V2 tags.
Definition: metaioid3.h:34
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
ImageType
ImageType
Definition: musicmetadata.h:29
musicmetadata.h
find
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
Definition: dvbstreamhandler.cpp:356