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