MythTV  master
recordingextender.h
Go to the documentation of this file.
1 /*
2  * Class RecordingExtender
3  *
4  * Copyright (c) David Hampton 2021
5  *
6  * Based on the ideas in the standalone Myth Recording PHP code from
7  * Derek Battams <derek@battams.ca>.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef RECORDING_EXTENDER_H_
25 #define RECORDING_EXTENDER_H_
26 
27 #include <memory>
28 
29 #include <QMutex>
30 #include <QJsonDocument>
31 
32 #include "libmythbase/mthread.h"
34 
35 class Scheduler;
36 
37 //
38 // Database info
39 //
40 struct SportInfo
41 {
42  QString showTitle; // Title in listings (RE match)
44  QString sport;
45  QString league;
46 };
47 using SportInfoList = QList<SportInfo>;
48 
50 {
51  public:
52  ActiveGame(int recordedid, QString title) :
53  m_recordedid(recordedid), m_title(std::move(title)) {}
54  ActiveGame(int recordedid, QString title, SportInfo info) :
55  m_recordedid(recordedid), m_title(std::move(title)),
56  m_info(std::move(info)) {}
57  int getRecordedId() const { return m_recordedid; }
58  QString getTitle() const { return m_title; }
59  SportInfo getInfo() const { return m_info; }
60  QString getTeam1() const { return m_team1; }
61  QString getTeam2() const { return m_team2; }
62  QString getTeam1Norm() const { return m_team1Normalized; }
63  QString getTeam2Norm() const { return m_team2Normalized; }
64  QString getAbbrev1() const { return m_abbrev1; }
65  QString getAbbrev2() const { return m_abbrev2; }
66  QUrl getInfoUrl() const { return m_infoUrl; }
67  QUrl getGameUrl() const { return m_gameUrl; }
68  QDateTime getStartTime() const { return m_startTime; }
69  QString getStartTimeAsString() const
70  { return m_startTime.toString(Qt::ISODate); }
71 
72  void setInfo(const SportInfo& info) { m_info = info; }
73  void setTeams(QString team1, QString team2)
74  { m_team1 = std::move(team1); m_team2 = std::move(team2); }
75  void setTeamsNorm(QString team1, QString team2)
76  { m_team1Normalized = std::move(team1); m_team2Normalized = std::move(team2); }
77  void setAbbrev1(const QString& abbrev) { m_abbrev1 = abbrev; }
78  void setAbbrev2(const QString& abbrev) { m_abbrev2 = abbrev; }
79  void setAbbrevs(QStringList abbrevs)
80  { m_abbrev1 = abbrevs[0]; m_abbrev2 = abbrevs[1]; }
81  void setInfoUrl(QUrl url);
82  void setGameUrl(QUrl url);
83  void setStartTime(const QDateTime& time) { m_startTime = time; }
84 
85  bool isValid() const
86  {
87  return !m_team1.isEmpty() && !m_team2.isEmpty() &&
88  m_startTime.isValid() && m_infoUrl.isValid();
89  }
90 
91  bool teamsMatch(const QStringList& names, const QStringList& abbrevs) const;
92 
93  private:
94  int m_recordedid {0};
95  QString m_title;
97 
98  QString m_team1;
99  QString m_team2;
102  QString m_abbrev1;
103  QString m_abbrev2;
104  QUrl m_infoUrl;
105  QUrl m_gameUrl;
106  QDateTime m_startTime;
107 };
108 
109 //
110 // The status of a single game.
111 //
113 {
114  public:
115  GameState() = default;
116  GameState(const QString& n1, const QString& n2,
117  const QString& a1, const QString& a2,
118  int p, bool finished) :
119  m_team1(n1.simplified()), m_team2(n2.simplified()),
120  m_abbrev1(a1.simplified()), m_abbrev2(a2.simplified()),
121  m_period(p), m_finished(finished) {};
122  GameState(const ActiveGame& game, int p, bool finished) :
123  m_team1(game.getTeam1()), m_team2(game.getTeam2()),
124  m_abbrev1(game.getAbbrev1()), m_abbrev2(game.getAbbrev2()),
125  m_period(p), m_finished(finished) {};
126  bool isValid() {return !m_team1.isEmpty() && !m_team2.isEmpty();};
127  QString getTeam1() { return m_team1; }
128  QString getTeam2() { return m_team2; }
129  QString getAbbrev1() { return m_abbrev1; }
130  QString getAbbrev2() { return m_abbrev2; }
131  QString getTextState() { return m_textState; }
132  void setTextState(QString text) { m_textState = std::move(text); }
133  int getPeriod() const { return m_period; }
134  bool isFinished() const { return m_finished; }
135  bool matchName(const QString& a, const QString& b)
136  { return (((a == m_team1) && (b == m_team2)) ||
137  ((a == m_team2) && (b == m_team1))); }
138  bool matchAbbrev(const QString& a, const QString& b)
139  { return (((a == m_abbrev1) && (b == m_abbrev2)) ||
140  ((a == m_abbrev2) && (b == m_abbrev1))); }
141  bool match(const QString& team1, const QString& team2)
142  {
143  if (matchName(team1, team2))
144  return true;
145  return matchAbbrev(team1, team2);
146  }
147  private:
148  QString m_team1;
149  QString m_team2;
150  QString m_abbrev1;
151  QString m_abbrev2;
152  QString m_textState;
153  int m_period {0};
154  bool m_finished {false};
155 };
156 //using GameStateList = QList<GameState>;
157 
158 class RecExtDataSource;
159 class RecordingExtender;
160 
161 class RecExtDataPage : public QObject
162 {
163  Q_OBJECT;
164  public:
166  {return qobject_cast<RecExtDataSource*>(parent()); }
168  virtual QDateTime getNow() {return MythDate::current(); }
169  virtual bool timeIsClose(const QDateTime& eventStart);
170  virtual bool findGameInfo(ActiveGame& game) = 0;
171  virtual GameState findGameScore(ActiveGame& game) = 0;
172  static QJsonObject walkJsonPath(QJsonObject& object, const QStringList& path);
175  QJsonDocument getDoc() { return m_doc; }
176  static bool getJsonInt (const QJsonObject& object, QStringList& path, int& value);
177  static bool getJsonInt (const QJsonObject& object, const QString& key, int& value);
178  static bool getJsonString(const QJsonObject& object, QStringList& path, QString& value);
179  static bool getJsonString(const QJsonObject& object, const QString& key, QString& value);
180  static bool getJsonObject(const QJsonObject& object, QStringList& path, QJsonObject& value);
181  static bool getJsonObject(const QJsonObject& object, const QString& key, QJsonObject& value);
182  static bool getJsonArray (const QJsonObject& object, const QString& key, QJsonArray& value);
183 
186  RecExtDataPage(QObject* parent, QJsonDocument doc) :
187  QObject(parent), m_doc(std::move(doc)) {};
188  protected:
189  QJsonDocument m_doc;
190 };
191 
193 {
194  // Games status codes.
195  enum GameStatus : std::uint8_t {
196  TBD = 0,
199  FINAL = 3,
200  FORFEIT = 4,
203  DELAYED = 7,
210  HALFTIME = 23,
211  OVERTIME = 24,
214  ABANDONED = 27,
215  FULL_TIME = 28,
225  RETIRED = 38,
226  BYE = 39,
227  WALKOVER = 40,
228  ESPNVOID = 41, // VOID makes win32 die horribly
231  SHOOTOUT = 44,
239  };
240  static const QList<GameStatus> kFinalStatuses;
241 
242  public:
243  RecExtEspnDataPage(QObject* parent, QJsonDocument doc) :
244  RecExtDataPage(parent, std::move(doc)) {};
245  bool findGameInfo(ActiveGame& game) override;
246  GameState findGameScore(ActiveGame& game) override;
247 };
248 
250 {
251  public:
252  RecExtMlbDataPage(QObject* parent, QJsonDocument doc) :
253  RecExtDataPage(parent, std::move(doc)) {};
254  bool findGameInfo(ActiveGame& game) override;
255  GameState findGameScore(ActiveGame& game) override;
256  bool parseGameObject(const QJsonObject& gameObject, ActiveGame& game);
257 };
258 
259 class RecExtDataSource : public QObject
260 {
261  Q_OBJECT;
262 
263  public:
265  { return qobject_cast<RecordingExtender*>(parent()); }
266  virtual RecExtDataPage* newPage(const QJsonDocument& doc) = 0;
267  static void clearCache();
268  virtual QUrl makeInfoUrl(const SportInfo& info, const QDateTime& dt) = 0;
269  virtual QUrl makeGameUrl(const ActiveGame& game, const QString& str) = 0;
270  virtual QUrl findInfoUrl(ActiveGame& game, SportInfo& info) = 0;
271  virtual RecExtDataPage* loadPage(const ActiveGame& game, const QUrl& _url) = 0;
272 
273  protected:
274  explicit RecExtDataSource(QObject *parent) : QObject(parent) {};
275 
276  QUrl m_url;
277  static QHash<QString,QJsonDocument> s_downloadedJson;
278 };
279 
281 {
282  public:
283  explicit RecExtEspnDataSource(QObject *parent) : RecExtDataSource(parent) {};
284  RecExtDataPage* newPage(const QJsonDocument& doc) override
285  { return new RecExtEspnDataPage(this, doc); }
286  QUrl makeInfoUrl(const SportInfo& info, const QDateTime& dt) override;
287  QUrl makeGameUrl(const ActiveGame& game, const QString& str) override;
288  QUrl findInfoUrl(ActiveGame& game, SportInfo& info) override;
289  RecExtDataPage* loadPage(const ActiveGame& game, const QUrl& _url) override;
290 };
291 
293 {
294  public:
295  explicit RecExtMlbDataSource(QObject *parent) : RecExtDataSource(parent) {}
296  RecExtDataPage* newPage(const QJsonDocument& doc) override
297  { return new RecExtMlbDataPage(this, doc); }
298  QUrl makeInfoUrl(const SportInfo& info, const QDateTime& dt) override;
299  QUrl makeGameUrl(const ActiveGame& game, const QString& str) override;
300  QUrl findInfoUrl(ActiveGame& game, SportInfo& info) override;
301  RecExtDataPage* loadPage(const ActiveGame& game, const QUrl& _url) override;
302 };
303 
304 //
305 //
306 //
307 class RecordingExtender : public QObject, public MThread
308 {
309  Q_OBJECT;
310  friend class TestRecordingExtender;
311 
312  public:
313  static void create(Scheduler *scheduler, RecordingInfo& ri);
314  void run(void) override; // MThread
315  ~RecordingExtender() override;
316  static void nameCleanup(const SportInfo& info, QString& name1, QString& name2);
317 
318  private:
319  RecordingExtender () : MThread("RecordingExtender") {}
320 
321  void addNewRecording(int recordedID);
322 
323  // Get provider information from database.
324  bool findKnownSport(const QString& _title,
326  SportInfoList& info) const;
327  static void clearDownloadedInfo();
328 
329  // Process recordings
331  static bool parseProgramInfo(const QString& subtitle, const QString& description,
332  QString& team1, QString& team2);
333  static QString ruleIdAsString(const RecordingRule *rr);
334  static void finishRecording(const RecordingInfo* ri, RecordingRule *rr, const ActiveGame& game);
335  void extendRecording(const RecordingInfo* ri, RecordingRule *rr, const ActiveGame& game);
336  static void unchangedRecording(const RecordingInfo* ri, RecordingRule *rr, const ActiveGame& game);
337  void processNewRecordings();
339  void checkDone();
340 
341  // Cleanup
342  static void nameCleanup(const SportInfo& info, QString& name);
343  void expireOverrides();
344 
349  static QMutex s_createLock;
351  bool m_running {true};
354  Scheduler *m_scheduler {nullptr};
359  QList<int> m_newRecordings;
361  QList<ActiveGame> m_activeGames;
363  QList<int> m_overrideRules;
364 
367 };
368 
369 #endif // RECORDING_EXTENDER_H_
Scheduler
Definition: scheduler.h:45
RecordingExtender::clearDownloadedInfo
static void clearDownloadedInfo()
Clear all downloaded info.
Definition: recordingextender.cpp:1211
ActiveGame::m_team1Normalized
QString m_team1Normalized
Definition: recordingextender.h:100
ActiveGame::setTeamsNorm
void setTeamsNorm(QString team1, QString team2)
Definition: recordingextender.h:75
ActiveGame::m_recordedid
int m_recordedid
Definition: recordingextender.h:94
RecExtMlbDataPage::findGameInfo
bool findGameInfo(ActiveGame &game) override
Parse a previously downloaded data page for a given sport.
Definition: recordingextender.cpp:806
ActiveGame::setAbbrevs
void setAbbrevs(QStringList abbrevs)
Definition: recordingextender.h:79
RecExtEspnDataPage::UNOFFICIAL
@ UNOFFICIAL
Definition: recordingextender.h:219
RecExtDataSource::clearCache
static void clearCache()
Clear the downloaded document cache.
Definition: recordingextender.cpp:338
ActiveGame::m_abbrev2
QString m_abbrev2
Definition: recordingextender.h:103
RecExtEspnDataPage::FULL_TIME
@ FULL_TIME
Definition: recordingextender.h:215
RecExtMlbDataPage::parseGameObject
bool parseGameObject(const QJsonObject &gameObject, ActiveGame &game)
MLB ///.
Definition: recordingextender.cpp:762
RecExtDataSource::getExtender
RecordingExtender * getExtender()
Definition: recordingextender.h:264
RecordingExtender::addNewRecording
void addNewRecording(int recordedID)
Add an item to the list of new recordings.
Definition: recordingextender.cpp:1109
RecExtMlbDataSource::newPage
RecExtDataPage * newPage(const QJsonDocument &doc) override
Definition: recordingextender.h:296
RecExtEspnDataPage::END_EXTRA_TIME
@ END_EXTRA_TIME
Definition: recordingextender.h:235
ActiveGame::getInfoUrl
QUrl getInfoUrl() const
Definition: recordingextender.h:66
ActiveGame::setTeams
void setTeams(QString team1, QString team2)
Definition: recordingextender.h:73
ActiveGame::getGameUrl
QUrl getGameUrl() const
Definition: recordingextender.h:67
RecExtEspnDataPage::CORRECTED_RESULT
@ CORRECTED_RESULT
Definition: recordingextender.h:224
RecExtMlbDataSource::makeGameUrl
QUrl makeGameUrl(const ActiveGame &game, const QString &str) override
Create a URL for one specific game in the MLB API that is built from the various known bits of data a...
Definition: recordingextender.cpp:1017
RecExtEspnDataPage::BYE
@ BYE
Definition: recordingextender.h:226
GameState::match
bool match(const QString &team1, const QString &team2)
Definition: recordingextender.h:141
GameState::getAbbrev2
QString getAbbrev2()
Definition: recordingextender.h:130
ActiveGame::getInfo
SportInfo getInfo() const
Definition: recordingextender.h:59
SportInfo::showTitle
QString showTitle
Definition: recordingextender.h:42
ActiveGame::teamsMatch
bool teamsMatch(const QStringList &names, const QStringList &abbrevs) const
Do the supplied team names/abbrevs match this game.
Definition: recordingextender.cpp:101
RecordingExtender::RecordingExtender
RecordingExtender()
Definition: recordingextender.h:319
GameState::getTextState
QString getTextState()
Definition: recordingextender.h:131
GameState::m_abbrev2
QString m_abbrev2
Definition: recordingextender.h:151
GameState::m_finished
bool m_finished
Definition: recordingextender.h:154
GameState::getTeam2
QString getTeam2()
Definition: recordingextender.h:128
RecordingInfo
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:35
RecordingExtender::s_createLock
static QMutex s_createLock
Interlock the scheduler thread crating this process, and this process determining whether it should c...
Definition: recordingextender.h:349
RecordingExtender::m_forcedYearforTesting
uint m_forcedYearforTesting
Testing data.
Definition: recordingextender.h:366
RecExtEspnDataPage::GameStatus
GameStatus
Definition: recordingextender.h:195
ActiveGame::getTitle
QString getTitle() const
Definition: recordingextender.h:58
RecExtEspnDataPage::findGameInfo
bool findGameInfo(ActiveGame &game) override
Parse a previously downloaded data page for a given sport.
Definition: recordingextender.cpp:420
RecExtEspnDataPage::FORFEIT_AWAY_TEAM
@ FORFEIT_AWAY_TEAM
Definition: recordingextender.h:206
RecExtDataSource::RecExtDataSource
RecExtDataSource(QObject *parent)
Definition: recordingextender.h:274
RecExtEspnDataPage::DELAYED
@ DELAYED
Definition: recordingextender.h:203
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
GameState::setTextState
void setTextState(QString text)
Definition: recordingextender.h:132
RecordingExtender::processActiveRecordings
void processActiveRecordings()
Process the currently active sports recordings.
Definition: recordingextender.cpp:1573
ActiveGame::setGameUrl
void setGameUrl(QUrl url)
Set the game status information URL.
Definition: recordingextender.cpp:85
ActiveGame::setStartTime
void setStartTime(const QDateTime &time)
Definition: recordingextender.h:83
RecExtDataPage::walkJsonPath
static QJsonObject walkJsonPath(QJsonObject &object, const QStringList &path)
Iterate through a json object and return the specified object.
Definition: recordingextender.cpp:159
RecExtEspnDataPage::FINAL_SCORE_AFTER_PENALTIES
@ FINAL_SCORE_AFTER_PENALTIES
Definition: recordingextender.h:234
RecordingExtender::processNewRecordings
void processNewRecordings()
Process the list of newly started sports recordings.
Definition: recordingextender.cpp:1472
ActiveGame::getTeam1
QString getTeam1() const
Definition: recordingextender.h:60
ActiveGame::m_team1
QString m_team1
Definition: recordingextender.h:98
RecExtEspnDataPage::GOLDEN_TIME
@ GOLDEN_TIME
Definition: recordingextender.h:230
ActiveGame::isValid
bool isValid() const
Definition: recordingextender.h:85
RecExtEspnDataPage::SECOND_HALF
@ SECOND_HALF
Definition: recordingextender.h:213
ActiveGame::getAbbrev2
QString getAbbrev2() const
Definition: recordingextender.h:65
RecExtMlbDataPage::RecExtMlbDataPage
RecExtMlbDataPage(QObject *parent, QJsonDocument doc)
Definition: recordingextender.h:252
RecExtEspnDataPage::FINAL_SCORE_ABANDONED
@ FINAL_SCORE_ABANDONED
Definition: recordingextender.h:238
AutoExtendType
AutoExtendType
Definition: recordingtypes.h:93
ActiveGame::setInfoUrl
void setInfoUrl(QUrl url)
Set the game scheduling information URL.
Definition: recordingextender.cpp:73
RecExtEspnDataPage::SCHEDULED
@ SCHEDULED
Definition: recordingextender.h:197
RecExtEspnDataPage::EXTRA_TIME_HALF_TIME
@ EXTRA_TIME_HALF_TIME
Definition: recordingextender.h:236
RecordingExtender
Definition: recordingextender.h:307
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
ActiveGame::ActiveGame
ActiveGame(int recordedid, QString title)
Definition: recordingextender.h:52
RecExtMlbDataSource::RecExtMlbDataSource
RecExtMlbDataSource(QObject *parent)
Definition: recordingextender.h:295
RecordingExtender::m_activeGames
QList< ActiveGame > m_activeGames
Currently ongoing games to track.
Definition: recordingextender.h:361
AutoExtendType::None
@ None
RecExtDataSource::findInfoUrl
virtual QUrl findInfoUrl(ActiveGame &game, SportInfo &info)=0
ActiveGame::m_infoUrl
QUrl m_infoUrl
Definition: recordingextender.h:104
RecExtDataSource::makeGameUrl
virtual QUrl makeGameUrl(const ActiveGame &game, const QString &str)=0
RecordingExtender::findKnownSport
bool findKnownSport(const QString &_title, AutoExtendType type, SportInfoList &info) const
Retrieve the db record for a sporting event on a specific provider.
Definition: recordingextender.cpp:1155
RecExtEspnDataPage::ABANDONED
@ ABANDONED
Definition: recordingextender.h:214
RecordingExtender::run
void run(void) override
The main execution loop for the Recording Extender.
Definition: recordingextender.cpp:1681
RecExtEspnDataPage::INPROGRESS
@ INPROGRESS
Definition: recordingextender.h:198
RecExtEspnDataPage::POSTPONED
@ POSTPONED
Definition: recordingextender.h:202
GameState::isValid
bool isValid()
Definition: recordingextender.h:126
RecExtMlbDataSource::findInfoUrl
QUrl findInfoUrl(ActiveGame &game, SportInfo &info) override
Find the right URL for a specific recording.
Definition: recordingextender.cpp:1037
RecExtMlbDataPage
Definition: recordingextender.h:249
ActiveGame::setInfo
void setInfo(const SportInfo &info)
Definition: recordingextender.h:72
GameState::getAbbrev1
QString getAbbrev1()
Definition: recordingextender.h:129
RecExtEspnDataPage::FORFEIT
@ FORFEIT
Definition: recordingextender.h:200
RecExtEspnDataPage::RecExtEspnDataPage
RecExtEspnDataPage(QObject *parent, QJsonDocument doc)
Definition: recordingextender.h:243
GameState::matchName
bool matchName(const QString &a, const QString &b)
Definition: recordingextender.h:135
RecExtDataPage::getJsonString
static bool getJsonString(const QJsonObject &object, QStringList &path, QString &value)
Retrieve the specified string from a json object.
Definition: recordingextender.cpp:248
SportInfoList
QList< SportInfo > SportInfoList
Definition: recordingextender.h:47
RecordingExtender::m_running
bool m_running
Whether the RecordingExtender process is running.
Definition: recordingextender.h:351
ActiveGame::getStartTimeAsString
QString getStartTimeAsString() const
Definition: recordingextender.h:69
RecordingExtender::ruleIdAsString
static QString ruleIdAsString(const RecordingRule *rr)
Quick helper function for printing recording rule numbers.
Definition: recordingextender.cpp:1268
RecExtDataPage::getJsonInt
static bool getJsonInt(const QJsonObject &object, QStringList &path, int &value)
Retrieve the specified integer from a json object.
Definition: recordingextender.cpp:210
RecExtEspnDataSource::findInfoUrl
QUrl findInfoUrl(ActiveGame &game, SportInfo &info) override
Find the right URL for a specific recording.
Definition: recordingextender.cpp:670
GameState::m_textState
QString m_textState
Definition: recordingextender.h:152
SportInfo::dataProvider
AutoExtendType dataProvider
Definition: recordingextender.h:43
RecExtEspnDataPage::GROUPINGS_OFFICIAL
@ GROUPINGS_OFFICIAL
Definition: recordingextender.h:221
hardwareprofile.config.p
p
Definition: config.py:33
GameState::getPeriod
int getPeriod() const
Definition: recordingextender.h:133
RecordingExtender::createDataSource
virtual RecExtDataSource * createDataSource(AutoExtendType type)
Create a RecExtDataSource object for the specified service.
Definition: recordingextender.cpp:1123
RecExtDataPage::findGameInfo
virtual bool findGameInfo(ActiveGame &game)=0
RecordingExtender::m_newRecordings
QList< int > m_newRecordings
Newly started recordings to process.
Definition: recordingextender.h:359
RecExtDataPage::findGameScore
virtual GameState findGameScore(ActiveGame &game)=0
RecExtEspnDataPage::FIRST_HALF
@ FIRST_HALF
Definition: recordingextender.h:212
RecExtEspnDataPage::OFFICIAL_EVENT_SHORTENED
@ OFFICIAL_EVENT_SHORTENED
Definition: recordingextender.h:223
RecExtEspnDataPage::FINAL
@ FINAL
Definition: recordingextender.h:199
GameState::GameState
GameState()=default
RecExtDataPage::getJsonArray
static bool getJsonArray(const QJsonObject &object, const QString &key, QJsonArray &value)
Retrieve the specified array from a json object.
Definition: recordingextender.cpp:324
ActiveGame::m_team2Normalized
QString m_team2Normalized
Definition: recordingextender.h:101
RecordingExtender::parseProgramInfo
static bool parseProgramInfo(const QString &subtitle, const QString &description, QString &team1, QString &team2)
Parse a RecordingInfo to find the team names.
Definition: recordingextender.cpp:1250
RecExtDataSource::newPage
virtual RecExtDataPage * newPage(const QJsonDocument &doc)=0
RecExtEspnDataPage::INTERMEDIATE
@ INTERMEDIATE
Definition: recordingextender.h:218
RecExtEspnDataPage::WALKOVER
@ WALKOVER
Definition: recordingextender.h:227
RecExtEspnDataSource::newPage
RecExtDataPage * newPage(const QJsonDocument &doc) override
Definition: recordingextender.h:284
ActiveGame::setAbbrev1
void setAbbrev1(const QString &abbrev)
Definition: recordingextender.h:77
RecordingExtender::m_newRecordingsLock
QMutex m_newRecordingsLock
New recordings are added by the scheduler process and removed by this process.
Definition: recordingextender.h:357
RecExtDataPage::getSource
RecExtDataSource * getSource()
Definition: recordingextender.h:165
RecordingExtender::checkDone
void checkDone()
Is there any remaining work? Check for both newly created recording and for active recordings.
Definition: recordingextender.cpp:1660
RecExtEspnDataPage::BEGINNING_OF_PERIOD
@ BEGINNING_OF_PERIOD
Definition: recordingextender.h:208
RecExtEspnDataPage::END_OF_PERIOD
@ END_OF_PERIOD
Definition: recordingextender.h:209
ActiveGame::ActiveGame
ActiveGame(int recordedid, QString title, SportInfo info)
Definition: recordingextender.h:54
SportInfo
Definition: recordingextender.h:40
ActiveGame
Definition: recordingextender.h:49
RecExtEspnDataPage::kFinalStatuses
static const QList< GameStatus > kFinalStatuses
A list of the ESPN status that mean the game is over.
Definition: recordingextender.h:240
uint
unsigned int uint
Definition: compat.h:81
ActiveGame::m_gameUrl
QUrl m_gameUrl
Definition: recordingextender.h:105
RecExtDataPage
Definition: recordingextender.h:161
RecExtEspnDataPage::RESCHEDULED
@ RESCHEDULED
Definition: recordingextender.h:216
ActiveGame::m_info
SportInfo m_info
Definition: recordingextender.h:96
RecExtEspnDataSource::loadPage
RecExtDataPage * loadPage(const ActiveGame &game, const QUrl &_url) override
Download the data page for a game, and do some minimal validation.
Definition: recordingextender.cpp:565
RecExtDataSource::s_downloadedJson
static QHash< QString, QJsonDocument > s_downloadedJson
A cache of downloaded documents.
Definition: recordingextender.h:277
RecExtEspnDataPage::PRELIMINARY
@ PRELIMINARY
Definition: recordingextender.h:229
RecExtEspnDataPage::RETIRED
@ RETIRED
Definition: recordingextender.h:225
RecExtDataPage::RecExtDataPage
RecExtDataPage(QObject *parent, QJsonDocument doc)
Create a new RecExtDataPage object.
Definition: recordingextender.h:186
GameState
Definition: recordingextender.h:112
RecExtEspnDataPage
Definition: recordingextender.h:192
RecExtEspnDataPage::FINAL_SCORE_AFTER_GOLDEN_GOAL
@ FINAL_SCORE_AFTER_GOLDEN_GOAL
Definition: recordingextender.h:233
RecExtEspnDataSource::makeGameUrl
QUrl makeGameUrl(const ActiveGame &game, const QString &str) override
Create a URL for one specific game in the ESPN API that is built from the various known bits of data ...
Definition: recordingextender.cpp:649
ActiveGame::m_abbrev1
QString m_abbrev1
Definition: recordingextender.h:102
GameState::GameState
GameState(const QString &n1, const QString &n2, const QString &a1, const QString &a2, int p, bool finished)
Definition: recordingextender.h:116
GameState::m_period
int m_period
Definition: recordingextender.h:153
RecordingExtender::m_scheduler
Scheduler * m_scheduler
Pointer to the scheduler.
Definition: recordingextender.h:354
RecExtDataSource::makeInfoUrl
virtual QUrl makeInfoUrl(const SportInfo &info, const QDateTime &dt)=0
RecordingExtender::create
static void create(Scheduler *scheduler, RecordingInfo &ri)
Create an instance of the RecordingExtender if necessary, and add this recording to the list of new r...
Definition: recordingextender.cpp:1080
RecExtEspnDataSource::RecExtEspnDataSource
RecExtEspnDataSource(QObject *parent)
Definition: recordingextender.h:283
RecExtEspnDataPage::SHOOTOUT
@ SHOOTOUT
Definition: recordingextender.h:231
ActiveGame::getStartTime
QDateTime getStartTime() const
Definition: recordingextender.h:68
RecExtEspnDataSource
Definition: recordingextender.h:280
ActiveGame::m_team2
QString m_team2
Definition: recordingextender.h:99
RecExtEspnDataPage::FORFEIT_HOME_TEAM
@ FORFEIT_HOME_TEAM
Definition: recordingextender.h:205
ActiveGame::m_title
QString m_title
Definition: recordingextender.h:95
RecExtEspnDataPage::HALFTIME
@ HALFTIME
Definition: recordingextender.h:210
SportInfo::sport
QString sport
Definition: recordingextender.h:44
RecExtEspnDataPage::TBD
@ TBD
Definition: recordingextender.h:196
MythDate::ISODate
@ ISODate
Default UTC.
Definition: mythdate.h:17
ActiveGame::getTeam2Norm
QString getTeam2Norm() const
Definition: recordingextender.h:63
GameState::getTeam1
QString getTeam1()
Definition: recordingextender.h:127
ActiveGame::getTeam2
QString getTeam2() const
Definition: recordingextender.h:61
ActiveGame::getAbbrev1
QString getAbbrev1() const
Definition: recordingextender.h:64
RecordingExtender::nameCleanup
static void nameCleanup(const SportInfo &info, QString &name1, QString &name2)
Clean up two team names for comparison against the ESPN API.
Definition: recordingextender.cpp:1352
RecExtMlbDataSource
Definition: recordingextender.h:292
RecExtDataPage::m_doc
QJsonDocument m_doc
Definition: recordingextender.h:187
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
GameState::GameState
GameState(const ActiveGame &game, int p, bool finished)
Definition: recordingextender.h:122
RecExtEspnDataPage::FIXTURE_NO_LIVE_COVERAGE
@ FIXTURE_NO_LIVE_COVERAGE
Definition: recordingextender.h:237
RecordingExtender::TestRecordingExtender
friend class TestRecordingExtender
Definition: recordingextender.h:309
RecExtEspnDataPage::FINAL_SCORE_AFTER_EXTRA_TIME
@ FINAL_SCORE_AFTER_EXTRA_TIME
Definition: recordingextender.h:232
ActiveGame::m_startTime
QDateTime m_startTime
Definition: recordingextender.h:106
ActiveGame::getTeam1Norm
QString getTeam1Norm() const
Definition: recordingextender.h:62
RecExtDataSource::loadPage
virtual RecExtDataPage * loadPage(const ActiveGame &game, const QUrl &_url)=0
RecExtDataPage::timeIsClose
virtual bool timeIsClose(const QDateTime &eventStart)
Base Classes ///.
Definition: recordingextender.cpp:137
GameState::m_abbrev1
QString m_abbrev1
Definition: recordingextender.h:150
ActiveGame::getRecordedId
int getRecordedId() const
Definition: recordingextender.h:57
RecExtMlbDataPage::findGameScore
GameState findGameScore(ActiveGame &game) override
Parse the previously downloaded data page for a given game.
Definition: recordingextender.cpp:875
RecExtEspnDataPage::MEDAL_OFFICIAL
@ MEDAL_OFFICIAL
Definition: recordingextender.h:220
RecExtDataSource::m_url
QUrl m_url
Definition: recordingextender.h:274
RecExtEspnDataPage::PLAY_COMPLETE
@ PLAY_COMPLETE
Definition: recordingextender.h:222
RecExtDataPage::getJsonObject
static bool getJsonObject(const QJsonObject &object, QStringList &path, QJsonObject &value)
Retrieve a specific object from another json object.
Definition: recordingextender.cpp:286
azlyrics.info
dictionary info
Definition: azlyrics.py:7
RecExtDataPage::getNow
virtual QDateTime getNow()
Get the current time. Overridden by the testing code.
Definition: recordingextender.h:168
RecordingExtender::s_singleton
static RecordingExtender * s_singleton
The single instance of a RecordingExtender.
Definition: recordingextender.h:346
GameState::m_team2
QString m_team2
Definition: recordingextender.h:149
GameState::isFinished
bool isFinished() const
Definition: recordingextender.h:134
RecordingExtender::finishRecording
static void finishRecording(const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game)
Stop the current recording early.
Definition: recordingextender.cpp:1369
RecExtMlbDataSource::makeInfoUrl
QUrl makeInfoUrl(const SportInfo &info, const QDateTime &dt) override
Create a URL for the MLB API that is built from the various known bits of data accumulated so far.
Definition: recordingextender.cpp:993
recordingrule.h
GameState::m_team1
QString m_team1
Definition: recordingextender.h:148
RecExtEspnDataPage::OVERTIME
@ OVERTIME
Definition: recordingextender.h:211
RecordingExtender::expireOverrides
void expireOverrides()
Delete the list of the override rules that have been created by this instance of RecordingExtender.
Definition: recordingextender.cpp:1464
RecordingExtender::m_overrideRules
QList< int > m_overrideRules
Recordings that have had an override rule creates.
Definition: recordingextender.h:363
RecExtEspnDataSource::makeInfoUrl
QUrl makeInfoUrl(const SportInfo &info, const QDateTime &dt) override
Create a URL for the ESPN API that is built from the various known bits of data accumulated so far.
Definition: recordingextender.cpp:629
RecordingExtender::extendRecording
void extendRecording(const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game)
Extend the current recording by XX minutes.
Definition: recordingextender.cpp:1391
RecExtEspnDataPage::CANCELLED
@ CANCELLED
Definition: recordingextender.h:201
RecExtEspnDataPage::findGameScore
GameState findGameScore(ActiveGame &game) override
Parse the previously downloaded data page for a given game.
Definition: recordingextender.cpp:516
RecExtEspnDataPage::SUSPENDED
@ SUSPENDED
Definition: recordingextender.h:204
SportInfo::league
QString league
Definition: recordingextender.h:45
RecordingExtender::~RecordingExtender
~RecordingExtender() override
Definition: recordingextender.cpp:1065
GameState::matchAbbrev
bool matchAbbrev(const QString &a, const QString &b)
Definition: recordingextender.h:138
RecExtEspnDataPage::START_LIST
@ START_LIST
Definition: recordingextender.h:217
RecExtMlbDataSource::loadPage
RecExtDataPage * loadPage(const ActiveGame &game, const QUrl &_url) override
Download the data page for a game, and do some minimal validation.
Definition: recordingextender.cpp:939
RecExtEspnDataPage::RAIN_DELAY
@ RAIN_DELAY
Definition: recordingextender.h:207
ActiveGame::setAbbrev2
void setAbbrev2(const QString &abbrev)
Definition: recordingextender.h:78
RecExtDataSource
Definition: recordingextender.h:259
RecExtDataPage::getDoc
QJsonDocument getDoc()
Get the JSON document associated with this object.
Definition: recordingextender.h:175
RecordingExtender::unchangedRecording
static void unchangedRecording(const RecordingInfo *ri, RecordingRule *rr, const ActiveGame &game)
Log that this recording hasn't changed.
Definition: recordingextender.cpp:1451
RecExtEspnDataPage::ESPNVOID
@ ESPNVOID
Definition: recordingextender.h:228