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