kodi
EpgInfoTag.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "XBDateTime.h"
12 #include "pvr/PVRCachedImage.h"
13 #include "threads/CriticalSection.h"
14 #include "utils/ISerializable.h"
15 
16 #include <memory>
17 #include <string>
18 #include <vector>
19 
20 struct EPG_TAG;
21 struct PVR_EDL_ENTRY;
22 
23 namespace PVR
24 {
25 class CPVREpgChannelData;
26 class CPVREpgDatabase;
27 
28 class CPVREpgInfoTag final : public ISerializable,
29  public std::enable_shared_from_this<CPVREpgInfoTag>
30 {
31  friend class CPVREpgDatabase;
32 
33 public:
34  static const std::string IMAGE_OWNER_PATTERN;
35 
43  CPVREpgInfoTag(const EPG_TAG& data,
44  int iClientId,
45  const std::shared_ptr<CPVREpgChannelData>& channelData,
46  int iEpgID);
47 
56  CPVREpgInfoTag(const std::shared_ptr<CPVREpgChannelData>& channelData,
57  int iEpgID,
58  const CDateTime& start,
59  const CDateTime& end,
60  bool bIsGapTag);
61 
66  void SetChannelData(const std::shared_ptr<CPVREpgChannelData>& data);
67 
68  bool operator==(const CPVREpgInfoTag& right) const;
69  bool operator!=(const CPVREpgInfoTag& right) const;
70 
71  // ISerializable implementation
72  void Serialize(CVariant& value) const override;
73 
78  int ClientID() const;
79 
84  bool IsActive() const;
85 
90  bool WasActive() const;
91 
96  bool IsUpcoming() const;
97 
102  float ProgressPercentage() const;
103 
108  int Progress() const;
109 
114  int EpgID() const;
115 
120  void SetEpgID(int iEpgID);
121 
126  void SetUniqueBroadcastID(unsigned int iUniqueBroadcastID);
127 
132  unsigned int UniqueBroadcastID() const;
133 
138  int DatabaseID() const;
139 
144  int UniqueChannelID() const;
145 
150  std::string ChannelIconPath() const;
151 
156  CDateTime StartAsUTC() const;
157 
162  CDateTime StartAsLocalTime() const;
163 
168  CDateTime EndAsUTC() const;
169 
174  CDateTime EndAsLocalTime() const;
175 
180  void SetEndFromUTC(const CDateTime& end);
181 
186  int GetDuration() const;
187 
192  std::string Title() const;
193 
198  std::string PlotOutline() const;
199 
204  std::string Plot() const;
205 
210  std::string OriginalTitle() const;
211 
216  const std::vector<std::string> Cast() const;
217 
222  const std::vector<std::string> Directors() const;
223 
228  const std::vector<std::string> Writers() const;
229 
234  const std::string GetCastLabel() const;
235 
240  const std::string GetDirectorsLabel() const;
241 
246  const std::string GetWritersLabel() const;
247 
252  const std::string GetGenresLabel() const;
253 
258  int Year() const;
259 
264  std::string IMDBNumber() const;
265 
270  int GenreType() const;
271 
276  int GenreSubType() const;
277 
282  std::string GenreDescription() const;
283 
288  const std::vector<std::string> Genre() const;
289 
294  CDateTime FirstAired() const;
295 
300  int ParentalRating() const;
301 
306  std::string ParentalRatingCode() const;
307 
312  int StarRating() const;
313 
318  int SeriesNumber() const;
319 
324  std::string SeriesLink() const;
325 
330  int EpisodeNumber() const;
331 
336  int EpisodePart() const;
337 
342  std::string EpisodeName() const;
343 
348  std::string IconPath() const;
349 
354  std::string ClientIconPath() const;
355 
360  std::string Path() const;
361 
366  bool IsRecordable() const;
367 
372  bool IsPlayable() const;
373 
379  bool QueuePersistQuery(const std::shared_ptr<CPVREpgDatabase>& database);
380 
388  bool Update(const CPVREpgInfoTag& tag, bool bUpdateBroadcastId = true);
389 
394  std::vector<PVR_EDL_ENTRY> GetEdl() const;
395 
400  bool IsSeries() const;
401 
406  bool IsRadio() const;
407 
412  bool IsParentalLocked() const;
413 
418  bool IsGapTag() const;
419 
424  bool IsNew() const;
425 
430  bool IsPremiere() const;
431 
436  bool IsFinale() const;
437 
442  bool IsLive() const;
443 
448  unsigned int Flags() const { return m_iFlags; }
449 
456  static const std::vector<std::string> Tokenize(const std::string& str);
457 
464  static const std::string DeTokenize(const std::vector<std::string>& tokens);
465 
466 private:
467  CPVREpgInfoTag(int iEpgID, const std::string& iconPath);
468 
469  CPVREpgInfoTag() = delete;
470  CPVREpgInfoTag(const CPVREpgInfoTag& tag) = delete;
471  CPVREpgInfoTag& operator=(const CPVREpgInfoTag& other) = delete;
472 
477  CDateTime GetCurrentPlayingTime() const;
478 
479  int m_iDatabaseID = -1;
480  int m_iGenreType = 0;
481  int m_iGenreSubType = 0;
482  std::string m_strGenreDescription;
483  int m_iParentalRating = 0;
484  std::string m_strParentalRatingCode;
485  int m_iStarRating = 0;
486  int m_iSeriesNumber = -1;
487  int m_iEpisodeNumber = -1;
488  int m_iEpisodePart = -1;
489  unsigned int m_iUniqueBroadcastID = 0;
490  std::string m_strTitle;
491  std::string m_strPlotOutline;
492  std::string m_strPlot;
493  std::string m_strOriginalTitle;
494  std::vector<std::string> m_cast;
495  std::vector<std::string> m_directors;
496  std::vector<std::string> m_writers;
497  int m_iYear = 0;
498  std::string m_strIMDBNumber;
499  mutable std::vector<std::string> m_genre;
500  std::string m_strEpisodeName;
501  CPVRCachedImage m_iconPath;
502  CDateTime m_startTime;
503  CDateTime m_endTime;
504  CDateTime m_firstAired;
505  unsigned int m_iFlags = 0;
506  std::string m_strSeriesLink;
507  bool m_bIsGapTag = false;
508 
509  mutable CCriticalSection m_critSection;
510  std::shared_ptr<CPVREpgChannelData> m_channelData;
511  int m_iEpgID = -1;
512 };
513 } // namespace PVR
int SeriesNumber() const
The series number of this event.
Definition: EpgInfoTag.cpp:458
int GenreType() const
Get the genre type ID of this event.
Definition: EpgInfoTag.cpp:401
bool IsLive() const
Check whether this tag will be flagged as live.
Definition: EpgInfoTag.cpp:668
bool QueuePersistQuery(const std::shared_ptr< CPVREpgDatabase > &database)
Write query to persist this tag in the query queue of the given database.
Definition: EpgInfoTag.cpp:560
bool IsFinale() const
Check whether this tag will be flagged as a finale.
Definition: EpgInfoTag.cpp:663
std::string EpisodeName() const
The episode name of this event.
Definition: EpgInfoTag.cpp:478
std::vector< PVR_EDL_ENTRY > GetEdl() const
Retrieve the edit decision list (EDL) of an EPG tag.
Definition: EpgInfoTag.cpp:571
"C" Edit definition list entry.
Definition: pvr_edl.h:54
Definition: PVRCachedImage.h:16
bool IsPremiere() const
Check whether this tag will be flagged as a premiere.
Definition: EpgInfoTag.cpp:658
Definition: EpgDatabase.h:31
float ProgressPercentage() const
Get the progress of this tag in percent.
Definition: EpgInfoTag.cpp:231
int StarRating() const
Get the star rating of this event.
Definition: EpgInfoTag.cpp:453
int EpisodeNumber() const
The episode number of this event.
Definition: EpgInfoTag.cpp:468
Definition: ContextMenuManager.h:24
int EpgID() const
Get EPG ID of this tag.
Definition: EpgInfoTag.cpp:585
const std::string GetGenresLabel() const
Get the genre(s) of this event as formatted string.
Definition: EpgInfoTag.cpp:385
int EpisodePart() const
The episode part number of this event.
Definition: EpgInfoTag.cpp:473
"C" PVR add-on channel group member.
Definition: pvr_epg.h:622
bool IsUpcoming() const
Check if this event is in the future.
Definition: EpgInfoTag.cpp:225
int DatabaseID() const
Get the event&#39;s database ID.
Definition: EpgInfoTag.cpp:272
std::string IMDBNumber() const
Get the imdbnumber of this event.
Definition: EpgInfoTag.cpp:396
int ParentalRating() const
Get the parental rating of this event.
Definition: EpgInfoTag.cpp:443
CDateTime EndAsLocalTime() const
Get the event&#39;s end time.
Definition: EpgInfoTag.cpp:306
CDateTime StartAsLocalTime() const
Get the event&#39;s start time.
Definition: EpgInfoTag.cpp:294
int UniqueChannelID() const
Get the unique ID of the channel associated with this event.
Definition: EpgInfoTag.cpp:277
CDateTime FirstAired() const
Get the first air date of this event.
Definition: EpgInfoTag.cpp:438
void SetEpgID(int iEpgID)
Sets the EPG id for this event.
Definition: EpgInfoTag.cpp:590
const std::vector< std::string > Directors() const
Get the director(s) of this event.
Definition: EpgInfoTag.cpp:351
Definition: Variant.h:31
void SetChannelData(const std::shared_ptr< CPVREpgChannelData > &data)
Set data for the channel linked to this EPG infotag.
Definition: EpgInfoTag.cpp:135
std::string IconPath() const
Get the path to the icon for this event used by Kodi.
Definition: EpgInfoTag.cpp:483
bool IsRecordable() const
Check if this event can be recorded.
Definition: EpgInfoTag.cpp:596
std::string Plot() const
Get the plot of this event.
Definition: EpgInfoTag.cpp:336
Definition: EpgInfoTag.h:28
bool Update(const CPVREpgInfoTag &tag, bool bUpdateBroadcastId=true)
Update the information in this tag with the info in the given tag.
Definition: EpgInfoTag.cpp:498
const std::vector< std::string > Cast() const
Get the cast of this event.
Definition: EpgInfoTag.cpp:346
bool IsPlayable() const
Check if this event can be played.
Definition: EpgInfoTag.cpp:611
std::string Title() const
Get the title of this event.
Definition: EpgInfoTag.cpp:326
const std::string GetDirectorsLabel() const
Get the director(s) of this event as formatted string.
Definition: EpgInfoTag.cpp:371
std::string Path() const
The path to this event.
Definition: EpgInfoTag.cpp:493
std::string ChannelIconPath() const
Get the path for the icon of the channel associated with this event.
Definition: EpgInfoTag.cpp:283
int GetDuration() const
Get the duration of this event in seconds.
Definition: EpgInfoTag.cpp:318
bool IsParentalLocked() const
Check whether this event is parental locked.
Definition: EpgInfoTag.cpp:641
int GenreSubType() const
Get the genre subtype ID of this event.
Definition: EpgInfoTag.cpp:406
std::string GenreDescription() const
Get the genre description of this event.
Definition: EpgInfoTag.cpp:411
Definition: ISerializable.h:13
std::string OriginalTitle() const
Get the original title of this event.
Definition: EpgInfoTag.cpp:341
void SetUniqueBroadcastID(unsigned int iUniqueBroadcastID)
Change the unique broadcast ID of this event.
Definition: EpgInfoTag.cpp:262
const std::vector< std::string > Genre() const
Get the genre as human readable string.
Definition: EpgInfoTag.cpp:416
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63
int Progress() const
Get the progress of this tag in seconds.
Definition: EpgInfoTag.cpp:249
bool IsActive() const
Check if this event is currently active.
Definition: EpgInfoTag.cpp:213
void SetEndFromUTC(const CDateTime &end)
Change the event&#39;s end time.
Definition: EpgInfoTag.cpp:313
unsigned int Flags() const
Return the flags (EPG_TAG_FLAG_*) of this event as a bitfield.
Definition: EpgInfoTag.h:448
int ClientID() const
Get the identifier of the client that serves this event.
Definition: EpgInfoTag.cpp:201
std::string ClientIconPath() const
Get the path to the icon for this event as given by the client.
Definition: EpgInfoTag.cpp:488
const std::string GetCastLabel() const
Get the cast of this event as formatted string.
Definition: EpgInfoTag.cpp:361
std::string PlotOutline() const
Get the plot outline of this event.
Definition: EpgInfoTag.cpp:331
static const std::string DeTokenize(const std::vector< std::string > &tokens)
Combine the given strings to a single string. Inserts EPG_STRING_TOKEN_SEPARATOR as separator...
Definition: EpgInfoTag.cpp:678
CDateTime StartAsUTC() const
Get the event&#39;s start time.
Definition: EpgInfoTag.cpp:289
bool IsRadio() const
Check whether this tag is associated with a radion or TV channel.
Definition: EpgInfoTag.cpp:635
unsigned int UniqueBroadcastID() const
Get the unique broadcast ID.
Definition: EpgInfoTag.cpp:267
const std::string GetWritersLabel() const
Get the writer(s) of this event as formatted string.
Definition: EpgInfoTag.cpp:378
bool WasActive() const
Check if this event is in the past.
Definition: EpgInfoTag.cpp:219
static const std::vector< std::string > Tokenize(const std::string &str)
Split the given string into tokens. Interprets occurrences of EPG_STRING_TOKEN_SEPARATOR in the strin...
Definition: EpgInfoTag.cpp:673
std::string SeriesLink() const
The series link for this event.
Definition: EpgInfoTag.cpp:463
bool IsNew() const
Check whether this tag will be flagged as new.
Definition: EpgInfoTag.cpp:653
bool IsSeries() const
Check whether this tag has any series attributes.
Definition: EpgInfoTag.cpp:626
std::string ParentalRatingCode() const
Get the parental rating code of this event.
Definition: EpgInfoTag.cpp:448
CDateTime EndAsUTC() const
Get the event&#39;s end time.
Definition: EpgInfoTag.cpp:301
int Year() const
Get the year of this event.
Definition: EpgInfoTag.cpp:391
bool IsGapTag() const
Check whether this event is a real event or a gap in the EPG timeline.
Definition: EpgInfoTag.cpp:647
const std::vector< std::string > Writers() const
Get the writer(s) of this event.
Definition: EpgInfoTag.cpp:356