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