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