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) : MetaIOTagLib() {}
37  virtual ~MetaIOID3(void) { 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
QList< AlbumArtImage * > AlbumArtList
Definition: musicmetadata.h:54
bool write(const QString &filename, MusicMetadata *mdata) override=0
Writes all metadata back to a file.
virtual AlbumArtList getAlbumArtList(const QString &filename)
Reads the list of embedded images in the tag.
Definition: metaio.h:71
bool supportsEmbeddedImages(void) override
Does the tag support embedded cover art.
Definition: metaioid3.h:49
virtual bool writeVolatileMetadata(const QString &filename, MusicMetadata *mdata)
Writes rating and playcount back to a file.
Definition: metaio.h:38
virtual QImage * getAlbumArt(const QString &filename, ImageType type)
Definition: metaio.h:103
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)
virtual ~MetaIOID3(void)
Definition: metaioid3.h:37
virtual bool changeImageType(const QString &filename, const AlbumArtImage *albumart, ImageType newType)
Definition: metaio.h:93
virtual bool writeAlbumArt(const QString &filename, const AlbumArtImage *albumart)
Definition: metaio.h:77
virtual bool removeAlbumArt(const QString &filename, const AlbumArtImage *albumart)
Definition: metaio.h:85
def rating(profile, smoonURL, gate)
Definition: scan.py:39
MetaIOID3(void)
Definition: metaioid3.h:36
#define META_PUBLIC
Definition: mythmetaexp.h:9
Read and write metadata in MPEG (mp3) ID3V2 tags.
Definition: metaioid3.h:33
MusicMetadata * read(const QString &filename) override=0
Reads MusicMetadata from a file.
ImageType
Definition: musicmetadata.h:26
virtual bool TagExists(const QString &filename)
Definition: metaio.h:135
const String email
Definition: metaioid3.cpp:22
Base for Taglib metadata classes.
Definition: metaiotaglib.h:20