MythTV  master
programdata.h
Go to the documentation of this file.
1 #ifndef _PROGRAMDATA_H_
2 #define _PROGRAMDATA_H_
3 
4 // C++ headers
5 #include <cstdint>
6 #include <vector>
7 using namespace std;
8 
9 // Qt headers
10 #include <QString>
11 #include <QDateTime>
12 #include <QList>
13 #include <QMap>
14 #include <QStringList>
15 
16 // MythTV headers
17 #include "mythtvexp.h"
18 #include "listingsources.h"
19 #include "programinfo.h"
20 #include "eithelper.h" /* for FixupValue */
21 
22 class MSqlQuery;
23 
25 {
26  public:
27  typedef enum
28  {
29  kUnknown = 0,
41  } Role;
42 
43  DBPerson(const DBPerson&);
44  DBPerson(Role _role, const QString &_name);
45  DBPerson(const QString &_role, const QString &_name);
46 
47  QString GetRole(void) const;
48 
49  uint InsertDB(MSqlQuery &query, uint chanid,
50  const QDateTime &starttime) const;
51 
52  private:
53  uint GetPersonDB(MSqlQuery &query) const;
54  uint InsertPersonDB(MSqlQuery &query) const;
55  uint InsertCreditsDB(MSqlQuery &query, uint personid, uint chanid,
56  const QDateTime &starttime) const;
57 
58  private:
60  QString name;
61 };
62 typedef vector<DBPerson> DBCredits;
63 
65 {
66  public:
67  QString system;
68  QString rating;
69 };
70 
72 {
73  public:
74  explicit DBEvent(uint _listingsource) :
75  title(),
76  subtitle(),
77  description(),
78  category(),
79  /*starttime, endtime,*/
80  airdate(0),
81  credits(nullptr),
82  partnumber(0),
83  parttotal(0),
84  syndicatedepisodenumber(),
85  subtitleType(0),
86  audioProps(0),
87  videoProps(0),
88  stars(0.0),
89  categoryType(ProgramInfo::kCategoryNone),
90  seriesId(),
91  programId(),
92  inetref(),
93  previouslyshown(false),
94  listingsource(_listingsource),
95  season(0),
96  episode(0),
97  totalepisodes(0) {}
98 
99  DBEvent(const QString &_title, const QString &_subtitle,
100  const QString &_desc,
101  const QString &_category, ProgramInfo::CategoryType _category_type,
102  const QDateTime &_start, const QDateTime &_end,
103  unsigned char _subtitleType,
104  unsigned char _audioProps,
105  unsigned char _videoProps,
106  float _stars,
107  const QString &_seriesId, const QString &_programId,
108  uint32_t _listingsource,
109  uint _season, uint _episode,
110  uint _totalepisodes ) :
111  title(_title), subtitle(_subtitle),
112  description(_desc),
113  category(_category),
114  starttime(_start), endtime(_end),
115  airdate(0),
116  credits(nullptr),
117  partnumber(0), parttotal(0),
118  syndicatedepisodenumber(),
119  subtitleType(_subtitleType),
120  audioProps(_audioProps), videoProps(_videoProps),
121  stars(_stars),
122  categoryType(_category_type),
123  seriesId(_seriesId),
124  programId(_programId),
125  inetref(),
126  previouslyshown(false),
127  listingsource(_listingsource),
128  season(_season),
129  episode(_episode),
130  totalepisodes(_totalepisodes)
131  {
132  }
133 
134  virtual ~DBEvent() { delete credits; }
135 
136  void AddPerson(DBPerson::Role, const QString &name);
137  void AddPerson(const QString &role, const QString &name);
138 
139  uint UpdateDB(MSqlQuery &query, uint chanid, int match_threshold) const;
140 
141  bool HasCredits(void) const { return credits; }
142  bool HasTimeConflict(const DBEvent &other) const;
143 
144  DBEvent &operator=(const DBEvent&);
145 
146  protected:
147  uint GetOverlappingPrograms(
148  MSqlQuery&, uint chanid, vector<DBEvent> &programs) const;
149  int GetMatch(
150  const vector<DBEvent> &programs, int &bestmatch) const;
151  uint UpdateDB(
152  MSqlQuery&, uint chanid, const vector<DBEvent> &p, int match) const;
153  uint UpdateDB(
154  MSqlQuery&, uint chanid, const DBEvent &match) const;
155  bool MoveOutOfTheWayDB(
156  MSqlQuery&, uint chanid, const DBEvent &nonmatch) const;
157  virtual uint InsertDB(MSqlQuery&, uint chanid) const;
158  virtual void Squeeze(void);
159 
160  public:
161  QString title;
162  QString subtitle;
163  QString description;
164  QString category;
165  QDateTime starttime;
166  QDateTime endtime;
173  unsigned char subtitleType;
174  unsigned char audioProps;
175  unsigned char videoProps;
176  float stars;
178  QString seriesId;
179  QString programId;
180  QString inetref;
182  uint32_t listingsource;
183  QList<EventRating> ratings;
184  QStringList genres;
188 };
189 
191 {
192  public:
193  DBEventEIT(uint _chanid,
194  const QString &_title, const QString &_subtitle,
195  const QString &_desc,
196  const QString &_category, ProgramInfo::CategoryType _category_type,
197  const QDateTime &_start, const QDateTime &_end,
198  FixupValue _fixup,
199  unsigned char _subtitleType,
200  unsigned char _audioProps,
201  unsigned char _videoProps,
202  float _stars,
203  const QString &_seriesId, const QString &_programId,
204  uint _season, uint _episode,
205  uint _totalepisodes ) :
206  DBEvent(_title, _subtitle, _desc, _category, _category_type,
207  _start, _end, _subtitleType, _audioProps, _videoProps,
208  _stars, _seriesId, _programId, kListingSourceEIT,
209  _season, _episode, _totalepisodes),
210  chanid(_chanid), fixup(_fixup)
211  {
212  }
213 
214  DBEventEIT(uint _chanid,
215  const QString &_title, const QString &_desc,
216  const QDateTime &_start, const QDateTime &_end,
217  FixupValue _fixup,
218  unsigned char _subtitleType,
219  unsigned char _audioProps,
220  unsigned char _videoProps) :
221  DBEvent(_title, QString(), _desc, QString(), ProgramInfo::kCategoryNone,
222  _start, _end, _subtitleType, _audioProps, _videoProps,
223  0.0, QString(), QString(), kListingSourceEIT, 0, 0, 0), // Season, Episode and Total Episodes are not set with this constructor!
224  chanid(_chanid), fixup(_fixup)
225  {
226  }
227 
228  uint UpdateDB(MSqlQuery &query, int match_threshold) const
229  {
230  return DBEvent::UpdateDB(query, chanid, match_threshold);
231  }
232 
233  public:
234  uint32_t chanid;
236  QMap<QString,QString> items;
237 };
238 
240 {
241  public:
244 
245  ProgInfo(const ProgInfo &other);
246 
247  uint InsertDB(MSqlQuery &query, uint chanid) const override; // DBEvent
248 
249  void Squeeze(void) override; // DBEvent
250 
251  ProgInfo &operator=(const ProgInfo&);
252 
253  public:
254  // extra XMLTV stuff
255  QString channel;
256  QString startts;
257  QString endts;
259  QString showtype;
260  QString colorcode;
261  QString clumpidx;
262  QString clumpmax;
263 };
264 
266 {
267  public:
268  static void HandlePrograms(uint sourceid,
269  QMap<QString, QList<ProgInfo> > &proglist);
270 
271  static int fix_end_times(void);
272  static bool ClearDataByChannel(
273  uint chanid,
274  const QDateTime &from,
275  const QDateTime &to,
276  bool use_channel_time_offset);
277  static bool ClearDataBySource(
278  uint sourceid,
279  const QDateTime &from,
280  const QDateTime &to,
281  bool use_channel_time_offset);
282 
283  private:
284  static void FixProgramList(QList<ProgInfo*> &fixlist);
285  static void HandlePrograms(
286  MSqlQuery &query, uint chanid,
287  const QList<ProgInfo*> &sortlist,
288  uint &unchanged, uint &updated);
289  static bool IsUnchanged(
290  MSqlQuery &query, uint chanid, const ProgInfo &pi);
291  static bool DeleteOverlaps(
292  MSqlQuery &query, uint chanid, const ProgInfo &pi);
293 };
294 
295 #endif // _PROGRAMDATA_H_
unsigned char audioProps
Definition: programdata.h:174
QString system
Definition: programdata.h:67
FixupValue fixup
Definition: programdata.h:235
DBEventEIT(uint _chanid, const QString &_title, const QString &_subtitle, const QString &_desc, const QString &_category, ProgramInfo::CategoryType _category_type, const QDateTime &_start, const QDateTime &_end, FixupValue _fixup, unsigned char _subtitleType, unsigned char _audioProps, unsigned char _videoProps, float _stars, const QString &_seriesId, const QString &_programId, uint _season, uint _episode, uint _totalepisodes)
Definition: programdata.h:193
DBEvent(const QString &_title, const QString &_subtitle, const QString &_desc, const QString &_category, ProgramInfo::CategoryType _category_type, const QDateTime &_start, const QDateTime &_end, unsigned char _subtitleType, unsigned char _audioProps, unsigned char _videoProps, float _stars, const QString &_seriesId, const QString &_programId, uint32_t _listingsource, uint _season, uint _episode, uint _totalepisodes)
Definition: programdata.h:99
uint episode
Definition: programdata.h:186
QString endts
Definition: programdata.h:257
QString title_pronounce
Definition: programdata.h:258
uint season
Definition: programdata.h:185
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
QList< EventRating > ratings
Definition: programdata.h:183
unsigned char subtitleType
Definition: programdata.h:173
uint16_t parttotal
Definition: programdata.h:171
unsigned int uint
Definition: compat.h:140
QString colorcode
Definition: programdata.h:260
uint32_t chanid
Definition: programdata.h:234
QString subtitle
Definition: programdata.h:162
DBEventEIT(uint _chanid, const QString &_title, const QString &_desc, const QDateTime &_start, const QDateTime &_end, FixupValue _fixup, unsigned char _subtitleType, unsigned char _audioProps, unsigned char _videoProps)
Definition: programdata.h:214
QString programId
Definition: programdata.h:179
bool previouslyshown
Definition: programdata.h:181
float stars
Definition: programdata.h:176
Holds information on recordings and videos.
Definition: programinfo.h:66
QString rating
Definition: programdata.h:68
DBEvent(uint _listingsource)
Definition: programdata.h:74
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
QString clumpmax
Definition: programdata.h:262
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QString startts
Definition: programdata.h:256
QMap< QString, QString > items
Definition: programdata.h:236
uint UpdateDB(MSqlQuery &query, int match_threshold) const
Definition: programdata.h:228
bool HasCredits(void) const
Definition: programdata.h:141
Role role
Definition: programdata.h:59
QString title
Definition: programdata.h:161
unsigned short uint16_t
Definition: iso6937tables.h:1
QString description
Definition: programdata.h:163
QStringList genres
Definition: programdata.h:184
QString seriesId
Definition: programdata.h:178
const char * name
Definition: ParseText.cpp:339
vector< DBPerson > DBCredits
Definition: programdata.h:62
QString syndicatedepisodenumber
Definition: programdata.h:172
QString category
Definition: programdata.h:164
virtual ~DBEvent()
Definition: programdata.h:134
uint16_t airdate
movie year / production year
Definition: programdata.h:167
uint UpdateDB(MSqlQuery &query, uint chanid, int match_threshold) const
QDateTime starttime
Definition: programdata.h:165
QString clumpidx
Definition: programdata.h:261
QString name
Definition: programdata.h:60
uint32_t listingsource
Definition: programdata.h:182
uint totalepisodes
Definition: programdata.h:187
uint64_t FixupValue
Definition: eithelper.h:78
uint16_t partnumber
Definition: programdata.h:170
Unprocessable file type.
Definition: imagetypes.h:34
QDate originalairdate
origial broadcast date
Definition: programdata.h:168
unsigned char videoProps
Definition: programdata.h:175
ProgramInfo::CategoryType categoryType
Definition: programdata.h:177
QDateTime endtime
Definition: programdata.h:166
QString showtype
Definition: programdata.h:259
DBCredits * credits
Definition: programdata.h:169
QString inetref
Definition: programdata.h:180
QString channel
Definition: programdata.h:255