MythTV  master
cddb.h
Go to the documentation of this file.
1 #ifndef CDDB_H_
2 #define CDDB_H_
3 
4 #include <utility>
5 
6 #include <QString>
7 #include <QStringList>
8 #include <QVector>
9 
10 /*
11  * CDDB lookup
12  */
13 struct Cddb
14 {
15  using discid_t = unsigned long;
16  struct Album;
17 
18  // A CDDB query match
19  struct Match
20  {
21  QString discGenre;
23  QString artist;
24  QString title;
25 
26  Match() = default;
27  Match(const char *g, discid_t d, const char *a, const char *t) :
28  discGenre(g), discID(d), artist(a), title(t)
29  {}
30  Match(QString g, discid_t d, QString a, QString t) :
31  discGenre(std::move(g)), discID(d), artist(std::move(a)), title(std::move(t))
32  {}
33  explicit Match(const Album& a) : discGenre(a.discGenre), discID(a.discID),
34  artist(a.artist), title(a.title)
35  {}
36  };
37 
38  // CDDB query results
39  struct Matches
40  {
41  discid_t discID { 0 }; // discID of query
42  bool isExact { false };
43  using match_t = QVector< Match >;
45 
46  Matches() = default;
47  };
48 
49  struct Msf
50  {
51  int min, sec, frame;
52  explicit Msf(int m = 0, int s = 0, int f = 0) : min(m), sec(s), frame(f) {}
53  };
54  using Toc = QVector< Msf >;
55 
56  struct Track
57  {
58  QString artist;
59  QString title;
60  };
61 
62  // CDDB detail result
63  struct Album
64  {
65  QString discGenre; // the genre used in the query to differentiate similar discID's
67  QString artist;
68  QString title;
69  QString genre; // the genre from the DGENRE= item
70  int year { 0 };
71  QString submitter;
72  int rev { 1 };
73  bool isCompilation { false };
74  using track_t = QVector< Track >;
76  QString extd;
77  using ext_t = QVector< QString >;
80 
81  explicit Album(discid_t d = 0, const char* g = nullptr) :
82  discGenre(g), discID(d) {}
83 
84  explicit Album(const QString& s) { *this = s; }
85 
86  Album& operator = (const QString& rhs);
87  operator QString () const;
88  };
89 
90  // Primary cddb access
91  static bool Query(Matches& res, const Toc& toc);
92  static bool Read(Album& album, const QString& genre, discid_t discID);
93  static bool Write(const Album& album, bool bLocalOnly = true);
94 
95  // Support
96  static discid_t Discid(unsigned& secs, const Msf v[], unsigned tracks);
97  static void Alias(const Album& album, discid_t discID);
98 };
99 
100 #endif //ndef CDDB_H_
Cddb::Album::rev
int rev
Definition: cddb.h:72
Cddb::Alias
static void Alias(const Album &album, discid_t discID)
Create a local alias for a matched discID.
Definition: cddb.cpp:283
Cddb::Track::title
QString title
Definition: cddb.h:59
Cddb::Album
Definition: cddb.h:64
Cddb::Match::Match
Match(const char *g, discid_t d, const char *a, const char *t)
Definition: cddb.h:27
Cddb::Match::artist
QString artist
Definition: cddb.h:23
Cddb::Discid
static discid_t Discid(unsigned &secs, const Msf v[], unsigned tracks)
discID calculation.
Definition: cddb.cpp:265
Cddb::Msf
Definition: cddb.h:50
Cddb::Match::Match
Match()=default
Cddb::Album::toc
Toc toc
Definition: cddb.h:79
Cddb::Album::title
QString title
Definition: cddb.h:68
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
Cddb::Track
Definition: cddb.h:57
Cddb
Definition: cddb.h:14
Cddb::Matches::isExact
bool isExact
Definition: cddb.h:42
Cddb::Album::operator=
Album & operator=(const QString &rhs)
Parse CDDB text.
Definition: cddb.cpp:291
Cddb::Album::Album
Album(const QString &s)
Definition: cddb.h:84
Cddb::Album::ext_t
QVector< QString > ext_t
Definition: cddb.h:77
Cddb::Album::track_t
QVector< Track > track_t
Definition: cddb.h:74
Cddb::Match::title
QString title
Definition: cddb.h:24
Cddb::Match::discGenre
QString discGenre
Definition: cddb.h:21
Cddb::Toc
QVector< Msf > Toc
Definition: cddb.h:54
Cddb::Album::tracks
track_t tracks
Definition: cddb.h:75
Cddb::Match::Match
Match(const Album &a)
Definition: cddb.h:33
Cddb::Match
Definition: cddb.h:20
Cddb::Matches::match_t
QVector< Match > match_t
Definition: cddb.h:43
hardwareprofile.i18n.t
t
Definition: i18n.py:36
Cddb::Album::discGenre
QString discGenre
Definition: cddb.h:65
Cddb::Matches::discID
discid_t discID
Definition: cddb.h:41
Cddb::discid_t
unsigned long discid_t
Definition: cddb.h:15
hardwareprofile.smolt.long
long
Definition: smolt.py:76
Cddb::Album::Album
Album(discid_t d=0, const char *g=nullptr)
Definition: cddb.h:81
f
QTextStream t & f
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:600
Cddb::Album::year
int year
Definition: cddb.h:70
Cddb::Msf::frame
int frame
Definition: cddb.h:51
Cddb::Album::genre
QString genre
Definition: cddb.h:69
Cddb::Msf::min
int min
Definition: cddb.h:51
Cddb::Matches
Definition: cddb.h:40
Cddb::Match::discID
discid_t discID
Definition: cddb.h:22
Cddb::Album::extd
QString extd
Definition: cddb.h:76
Cddb::Album::artist
QString artist
Definition: cddb.h:67
Cddb::Msf::sec
int sec
Definition: cddb.h:51
Cddb::Album::discID
discid_t discID
Definition: cddb.h:66
Cddb::Matches::matches
match_t matches
Definition: cddb.h:44
Cddb::Write
static bool Write(const Album &album, bool bLocalOnly=true)
CDDB write.
Definition: cddb.cpp:242
Cddb::Matches::Matches
Matches()=default
Cddb::Album::submitter
QString submitter
Definition: cddb.h:71
Cddb::Read
static bool Read(Album &album, const QString &genre, discid_t discID)
CDDB read.
Definition: cddb.cpp:196
Cddb::Match::Match
Match(QString g, discid_t d, QString a, QString t)
Definition: cddb.h:30
Cddb::Album::ext
ext_t ext
Definition: cddb.h:78
Cddb::Query
static bool Query(Matches &res, const Toc &toc)
CDDB query.
Definition: cddb.cpp:100
Cddb::Album::isCompilation
bool isCompilation
Definition: cddb.h:73
Cddb::Msf::Msf
Msf(int m=0, int s=0, int f=0)
Definition: cddb.h:52
Cddb::Track::artist
QString artist
Definition: cddb.h:58