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 <utility>
7 #include <vector>
8 using namespace std;
9 
10 // Qt headers
11 #include <QString>
12 #include <QDateTime>
13 #include <QList>
14 #include <QMap>
15 #include <QStringList>
16 
17 // MythTV headers
18 #include "mythtvexp.h"
19 #include "listingsources.h"
20 #include "programinfo.h"
21 #include "eithelper.h" /* for FixupValue */
22 
23 class MSqlQuery;
24 
26 {
27  public:
28  enum Role
29  {
30  kUnknown = 0,
42  };
43 
44  DBPerson(const DBPerson &other);
45  DBPerson(Role _role, QString _name);
46  DBPerson(const QString &_role, QString _name);
47 
48  QString GetRole(void) const;
49 
50  uint InsertDB(MSqlQuery &query, uint chanid,
51  const QDateTime &starttime) const;
52 
53  private:
54  uint GetPersonDB(MSqlQuery &query) const;
55  uint InsertPersonDB(MSqlQuery &query) const;
56  uint InsertCreditsDB(MSqlQuery &query, uint personid, uint chanid,
57  const QDateTime &starttime) const;
58 
59  private:
61  QString m_name;
62 };
63 using DBCredits = vector<DBPerson>;
64 
66 {
67  public:
68  QString m_system;
69  QString m_rating;
70 };
71 
73 {
74  public:
75  explicit DBEvent(uint listingsource) :
76  m_listingsource(listingsource) {}
77 
78  DBEvent(QString _title, QString _subtitle,
79  QString _desc,
80  QString _category, ProgramInfo::CategoryType _category_type,
81  QDateTime _start, QDateTime _end,
82  unsigned char _subtitleType,
83  unsigned char _audioProps,
84  unsigned char _videoProps,
85  float _stars,
86  QString _seriesId, QString _programId,
87  uint32_t _listingsource,
88  uint _season, uint _episode,
89  uint _totalepisodes ) :
90  m_title(std::move(_title)), m_subtitle(std::move(_subtitle)),
91  m_description(std::move(_desc)),
92  m_category(std::move(_category)),
93  m_starttime(std::move(_start)), m_endtime(std::move(_end)),
94  m_subtitleType(_subtitleType),
95  m_audioProps(_audioProps), m_videoProps(_videoProps),
96  m_stars(_stars),
97  m_categoryType(_category_type),
98  m_seriesId(std::move(_seriesId)),
99  m_programId(std::move(_programId)),
100  m_listingsource(_listingsource),
101  m_season(_season),
102  m_episode(_episode),
103  m_totalepisodes(_totalepisodes)
104  {
105  }
106 
107  virtual ~DBEvent() { delete m_credits; }
108 
109  void AddPerson(DBPerson::Role role, const QString &name);
110  void AddPerson(const QString &role, const QString &name);
111 
112  uint UpdateDB(MSqlQuery &query, uint chanid, int match_threshold) const;
113 
114  bool HasCredits(void) const { return m_credits; }
115  bool HasTimeConflict(const DBEvent &other) const;
116 
117  DBEvent &operator=(const DBEvent &other);
118 
119  protected:
120  uint GetOverlappingPrograms(
121  MSqlQuery &query, uint chanid, vector<DBEvent> &programs) const;
122  int GetMatch(
123  const vector<DBEvent> &programs, int &bestmatch) const;
124  uint UpdateDB(
125  MSqlQuery &q, uint chanid, const vector<DBEvent> &p, int match) const;
126  uint UpdateDB(
127  MSqlQuery &query, uint chanid, const DBEvent &match) const;
128  bool MoveOutOfTheWayDB(
129  MSqlQuery &query, uint chanid, const DBEvent &prog) const;
130  virtual uint InsertDB(MSqlQuery &query, uint chanid) const;
131  virtual void Squeeze(void);
132 
133  public:
134  QString m_title;
135  QString m_subtitle;
136  QString m_description;
137  QString m_category;
138  QDateTime m_starttime;
139  QDateTime m_endtime;
140  uint16_t m_airdate {0};
142  DBCredits *m_credits {nullptr};
143  uint16_t m_partnumber {0};
144  uint16_t m_parttotal {0};
146  unsigned char m_subtitleType {0};
147  unsigned char m_audioProps {0};
148  unsigned char m_videoProps {0};
149  float m_stars {0.0};
151  QString m_seriesId;
152  QString m_programId;
153  QString m_inetref;
154  bool m_previouslyshown {false};
155  uint32_t m_listingsource;
156  QList<EventRating> m_ratings;
157  QStringList m_genres;
158  uint m_season {0};
159  uint m_episode {0};
160  uint m_totalepisodes {0};
161 };
162 
164 {
165  public:
166  DBEventEIT(uint _chanid,
167  const QString &_title, const QString &_subtitle,
168  const QString &_desc,
169  const QString &_category, ProgramInfo::CategoryType _category_type,
170  const QDateTime &_start, const QDateTime &_end,
171  FixupValue _fixup,
172  unsigned char _subtitleType,
173  unsigned char _audioProps,
174  unsigned char _videoProps,
175  float _stars,
176  const QString &_seriesId, const QString &_programId,
177  uint _season, uint _episode,
178  uint _totalepisodes ) :
179  DBEvent(_title, _subtitle, _desc, _category, _category_type,
180  _start, _end, _subtitleType, _audioProps, _videoProps,
181  _stars, _seriesId, _programId, kListingSourceEIT,
182  _season, _episode, _totalepisodes),
183  m_chanid(_chanid), m_fixup(_fixup)
184  {
185  }
186 
187  DBEventEIT(uint _chanid,
188  const QString &_title, const QString &_desc,
189  const QDateTime &_start, const QDateTime &_end,
190  FixupValue _fixup,
191  unsigned char _subtitleType,
192  unsigned char _audioProps,
193  unsigned char _videoProps) :
194  DBEvent(_title, QString(), _desc, QString(), ProgramInfo::kCategoryNone,
195  _start, _end, _subtitleType, _audioProps, _videoProps,
196  0.0, QString(), QString(), kListingSourceEIT, 0, 0, 0), // Season, Episode and Total Episodes are not set with this constructor!
197  m_chanid(_chanid), m_fixup(_fixup)
198  {
199  }
200 
201  uint UpdateDB(MSqlQuery &query, int match_threshold) const
202  {
203  return DBEvent::UpdateDB(query, m_chanid, match_threshold);
204  }
205 
206  public:
207  uint32_t m_chanid;
209  QMap<QString,QString> m_items;
210 };
211 
213 {
214  public:
217 
218  ProgInfo(const ProgInfo &other);
219 
220  uint InsertDB(MSqlQuery &query, uint chanid) const override; // DBEvent
221 
222  void Squeeze(void) override; // DBEvent
223 
224  ProgInfo &operator=(const ProgInfo &other);
225 
226  public:
227  // extra XMLTV stuff
228  QString m_channel;
229  QString m_startts;
230  QString m_endts;
232  QString m_showtype;
233  QString m_colorcode;
234  QString m_clumpidx;
235  QString m_clumpmax;
236 };
237 
239 {
240  public:
241  static void HandlePrograms(uint sourceid,
242  QMap<QString, QList<ProgInfo> > &proglist);
243 
244  static int fix_end_times(void);
245  static bool ClearDataByChannel(
246  uint chanid,
247  const QDateTime &from,
248  const QDateTime &to,
249  bool use_channel_time_offset);
250  static bool ClearDataBySource(
251  uint sourceid,
252  const QDateTime &from,
253  const QDateTime &to,
254  bool use_channel_time_offset);
255 
256  private:
257  static void FixProgramList(QList<ProgInfo*> &fixlist);
258  static void HandlePrograms(
259  MSqlQuery &query, uint chanid,
260  const QList<ProgInfo*> &sortlist,
261  uint &unchanged, uint &updated);
262  static bool IsUnchanged(
263  MSqlQuery &query, uint chanid, const ProgInfo &pi);
264  static bool DeleteOverlaps(
265  MSqlQuery &query, uint chanid, const ProgInfo &pi);
266 };
267 
268 #endif // _PROGRAMDATA_H_
DBEvent(uint listingsource)
Definition: programdata.h:75
QDateTime m_endtime
Definition: programdata.h:139
QString m_description
Definition: programdata.h:136
QString m_clumpidx
Definition: programdata.h:234
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:166
QString m_category
Definition: programdata.h:137
QString m_title_pronounce
Definition: programdata.h:231
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
QString m_title
Definition: programdata.h:134
QString m_system
Definition: programdata.h:68
uint32_t m_listingsource
Definition: programdata.h:155
QString m_syndicatedepisodenumber
Definition: programdata.h:145
QString m_channel
Definition: programdata.h:228
QString m_name
Definition: programdata.h:61
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:187
QString m_subtitle
Definition: programdata.h:135
QDate m_originalairdate
origial broadcast date
Definition: programdata.h:141
QStringList m_genres
Definition: programdata.h:157
Holds information on recordings and videos.
Definition: programinfo.h:67
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QString m_inetref
Definition: programdata.h:153
QString m_colorcode
Definition: programdata.h:233
uint64_t FixupValue
Definition: eithelper.h:80
uint UpdateDB(MSqlQuery &query, int match_threshold) const
Definition: programdata.h:201
QDateTime m_starttime
Definition: programdata.h:138
bool HasCredits(void) const
Definition: programdata.h:114
QList< EventRating > m_ratings
Definition: programdata.h:156
unsigned int uint
Definition: compat.h:140
DBEvent(QString _title, QString _subtitle, QString _desc, QString _category, ProgramInfo::CategoryType _category_type, QDateTime _start, QDateTime _end, unsigned char _subtitleType, unsigned char _audioProps, unsigned char _videoProps, float _stars, QString _seriesId, QString _programId, uint32_t _listingsource, uint _season, uint _episode, uint _totalepisodes)
Definition: programdata.h:78
QString m_seriesId
Definition: programdata.h:151
QString m_startts
Definition: programdata.h:229
virtual ~DBEvent()
Definition: programdata.h:107
unsigned short uint16_t
Definition: iso6937tables.h:1
uint UpdateDB(MSqlQuery &query, uint chanid, int match_threshold) const
QString m_clumpmax
Definition: programdata.h:235
QString m_showtype
Definition: programdata.h:232
FixupValue m_fixup
Definition: programdata.h:208
uint32_t m_chanid
Definition: programdata.h:207
QString m_endts
Definition: programdata.h:230
Unprocessable file type.
Definition: imagetypes.h:34
vector< DBPerson > DBCredits
Definition: programdata.h:63
Role m_role
Definition: programdata.h:60
QString m_rating
Definition: programdata.h:69
QString m_programId
Definition: programdata.h:152
QMap< QString, QString > m_items
Definition: programdata.h:209