2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "XBDateTime.h"
12 #include "pvr/PVRCachedImage.h"
13 #include "threads/CriticalSection.h"
14 #include "utils/ISerializable.h"
25 class CPVREpgChannelData
;
26 class CPVREpgDatabase
;
28 class CPVREpgInfoTag final
: public ISerializable
,
29 public std::enable_shared_from_this
<CPVREpgInfoTag
>
31 friend class CPVREpgDatabase
;
34 static const std::string IMAGE_OWNER_PATTERN
;
37 * @brief Create a new EPG infotag.
38 * @param data The tag's data.
39 * @param iClientId The client id.
40 * @param channelData The channel data.
41 * @param iEpgId The id of the EPG this tag belongs to.
43 CPVREpgInfoTag(const EPG_TAG
& data
,
45 const std::shared_ptr
<CPVREpgChannelData
>& channelData
,
49 * @brief Create a new EPG infotag.
50 * @param channelData The channel data.
51 * @param iEpgId The id of the EPG this tag belongs to.
52 * @param start The start time of the event
53 * @param end The end time of the event
54 * @param bIsGapTagTrue if this is a "gap" tag, false if this is a real EPG event
56 CPVREpgInfoTag(const std::shared_ptr
<CPVREpgChannelData
>& channelData
,
58 const CDateTime
& start
,
63 * @brief Set data for the channel linked to this EPG infotag.
64 * @param data The channel data.
66 void SetChannelData(const std::shared_ptr
<CPVREpgChannelData
>& data
);
68 bool operator==(const CPVREpgInfoTag
& right
) const;
69 bool operator!=(const CPVREpgInfoTag
& right
) const;
71 // ISerializable implementation
72 void Serialize(CVariant
& value
) const override
;
75 * @brief Get the identifier of the client that serves this event.
76 * @return The identifier.
81 * @brief Check if this event is currently active.
82 * @return True if it's active, false otherwise.
84 bool IsActive() const;
87 * @brief Check if this event is in the past.
88 * @return True when this event has already passed, false otherwise.
90 bool WasActive() const;
93 * @brief Check if this event is in the future.
94 * @return True when this event is an upcoming event, false otherwise.
96 bool IsUpcoming() const;
99 * @brief Get the progress of this tag in percent.
100 * @return The current progress of this tag.
102 float ProgressPercentage() const;
105 * @brief Get the progress of this tag in seconds.
106 * @return The current progress of this tag in seconds.
108 int Progress() const;
111 * @brief Get EPG ID of this tag.
112 * @return The epg ID.
117 * @brief Sets the EPG id for this event.
118 * @param iEpgID The EPG id.
120 void SetEpgID(int iEpgID
);
123 * @brief Change the unique broadcast ID of this event.
124 * @param iUniqueBroadcastId The new unique broadcast ID.
126 void SetUniqueBroadcastID(unsigned int iUniqueBroadcastID
);
129 * @brief Get the unique broadcast ID.
130 * @return The unique broadcast ID.
132 unsigned int UniqueBroadcastID() const;
135 * @brief Get the event's database ID.
136 * @return The database ID.
138 int DatabaseID() const;
141 * @brief Get the unique ID of the channel associated with this event.
142 * @return The unique channel ID.
144 int UniqueChannelID() const;
147 * @brief Get the path for the icon of the channel associated with this event.
148 * @return The channel icon path.
150 std::string
ChannelIconPath() const;
153 * @brief Get the event's start time.
154 * @return The start time in UTC.
156 CDateTime
StartAsUTC() const;
159 * @brief Get the event's start time.
160 * @return The start time as local time.
162 CDateTime
StartAsLocalTime() const;
165 * @brief Get the event's end time.
166 * @return The end time in UTC.
168 CDateTime
EndAsUTC() const;
171 * @brief Get the event's end time.
172 * @return The end time as local time.
174 CDateTime
EndAsLocalTime() const;
177 * @brief Change the event's end time.
178 * @param end The new end time.
180 void SetEndFromUTC(const CDateTime
& end
);
183 * @brief Get the duration of this event in seconds.
184 * @return The duration.
186 int GetDuration() const;
189 * @brief Get the title of this event.
192 std::string
Title() const;
195 * @brief Get the plot outline of this event.
196 * @return The plot outline.
198 std::string
PlotOutline() const;
201 * @brief Get the plot of this event.
204 std::string
Plot() const;
207 * @brief Get the original title of this event.
208 * @return The original title.
210 std::string
OriginalTitle() const;
213 * @brief Get the cast of this event.
216 const std::vector
<std::string
> Cast() const;
219 * @brief Get the director(s) of this event.
220 * @return The director(s).
222 const std::vector
<std::string
> Directors() const;
225 * @brief Get the writer(s) of this event.
226 * @return The writer(s).
228 const std::vector
<std::string
> Writers() const;
231 * @brief Get the cast of this event as formatted string.
232 * @return The cast label.
234 const std::string
GetCastLabel() const;
237 * @brief Get the director(s) of this event as formatted string.
238 * @return The directors label.
240 const std::string
GetDirectorsLabel() const;
243 * @brief Get the writer(s) of this event as formatted string.
244 * @return The writers label.
246 const std::string
GetWritersLabel() const;
249 * @brief Get the genre(s) of this event as formatted string.
250 * @return The genres label.
252 const std::string
GetGenresLabel() const;
255 * @brief Get the year of this event.
261 * @brief Get the imdbnumber of this event.
262 * @return The imdbnumber.
264 std::string
IMDBNumber() const;
267 * @brief Get the genre type ID of this event.
268 * @return The genre type ID.
270 int GenreType() const;
273 * @brief Get the genre subtype ID of this event.
274 * @return The genre subtype ID.
276 int GenreSubType() const;
279 * @brief Get the genre description of this event.
282 std::string
GenreDescription() const;
285 * @brief Get the genre as human readable string.
288 const std::vector
<std::string
> Genre() const;
291 * @brief Get the first air date of this event.
292 * @return The first air date.
294 CDateTime
FirstAired() const;
297 * @brief Get the parental rating of this event.
298 * @return The parental rating.
300 int ParentalRating() const;
303 * @brief Get the parental rating code of this event.
304 * @return The parental rating code.
306 std::string
ParentalRatingCode() const;
309 * @brief Get the star rating of this event.
310 * @return The star rating.
312 int StarRating() const;
315 * @brief The series number of this event.
316 * @return The series number.
318 int SeriesNumber() const;
321 * @brief The series link for this event.
322 * @return The series link or empty string, if not available.
324 std::string
SeriesLink() const;
327 * @brief The episode number of this event.
328 * @return The episode number.
330 int EpisodeNumber() const;
333 * @brief The episode part number of this event.
334 * @return The episode part number.
336 int EpisodePart() const;
339 * @brief The episode name of this event.
340 * @return The episode name.
342 std::string
EpisodeName() const;
345 * @brief Get the path to the icon for this event used by Kodi.
346 * @return The path to the icon
348 std::string
IconPath() const;
351 * @brief Get the path to the icon for this event as given by the client.
352 * @return The path to the icon
354 std::string
ClientIconPath() const;
357 * @brief The path to this event.
360 std::string
Path() const;
363 * @brief Check if this event can be recorded.
364 * @return True if it can be recorded, false otherwise.
366 bool IsRecordable() const;
369 * @brief Check if this event can be played.
370 * @return True if it can be played, false otherwise.
372 bool IsPlayable() const;
375 * @brief Write query to persist this tag in the query queue of the given database.
376 * @param database The database.
377 * @return True on success, false otherwise.
379 bool QueuePersistQuery(const std::shared_ptr
<CPVREpgDatabase
>& database
);
382 * @brief Update the information in this tag with the info in the given tag.
383 * @param tag The new info.
384 * @param bUpdateBroadcastId If set to false, the tag BroadcastId (locally unique) will not be
386 * @return True if something changed, false otherwise.
388 bool Update(const CPVREpgInfoTag
& tag
, bool bUpdateBroadcastId
= true);
391 * @brief Retrieve the edit decision list (EDL) of an EPG tag.
392 * @return The edit decision list (empty on error)
394 std::vector
<PVR_EDL_ENTRY
> GetEdl() const;
397 * @brief Check whether this tag has any series attributes.
398 * @return True if this tag has any series attributes, false otherwise
400 bool IsSeries() const;
403 * @brief Check whether this tag is associated with a radion or TV channel.
404 * @return True if this tag is associated with a radio channel, false otherwise.
406 bool IsRadio() const;
409 * @brief Check whether this event is parental locked.
410 * @return True if whether this event is parental locked, false otherwise.
412 bool IsParentalLocked() const;
415 * @brief Check whether this event is a real event or a gap in the EPG timeline.
416 * @return True if this event is a gap, false otherwise.
418 bool IsGapTag() const;
421 * @brief Check whether this tag will be flagged as new.
422 * @return True if this tag will be flagged as new, false otherwise
427 * @brief Check whether this tag will be flagged as a premiere.
428 * @return True if this tag will be flagged as a premiere, false otherwise
430 bool IsPremiere() const;
433 * @brief Check whether this tag will be flagged as a finale.
434 * @return True if this tag will be flagged as a finale, false otherwise
436 bool IsFinale() const;
439 * @brief Check whether this tag will be flagged as live.
440 * @return True if this tag will be flagged as live, false otherwise
445 * @brief Return the flags (EPG_TAG_FLAG_*) of this event as a bitfield.
448 unsigned int Flags() const { return m_iFlags
; }
451 * @brief Split the given string into tokens. Interprets occurrences of EPG_STRING_TOKEN_SEPARATOR
452 * in the string as separator.
453 * @param str The string to tokenize.
454 * @return the tokens.
456 static const std::vector
<std::string
> Tokenize(const std::string
& str
);
459 * @brief Combine the given strings to a single string. Inserts EPG_STRING_TOKEN_SEPARATOR as
461 * @param tokens The tokens.
462 * @return the combined string.
464 static const std::string
DeTokenize(const std::vector
<std::string
>& tokens
);
467 CPVREpgInfoTag(int iEpgID
, const std::string
& iconPath
);
469 CPVREpgInfoTag() = delete;
470 CPVREpgInfoTag(const CPVREpgInfoTag
& tag
) = delete;
471 CPVREpgInfoTag
& operator=(const CPVREpgInfoTag
& other
) = delete;
474 * @brief Get current time, taking timeshifting into account.
475 * @return The playing time.
477 CDateTime
GetCurrentPlayingTime() const;
479 int m_iDatabaseID
= -1; /*!< database ID */
480 int m_iGenreType
= 0; /*!< genre type */
481 int m_iGenreSubType
= 0; /*!< genre subtype */
482 std::string m_strGenreDescription
; /*!< genre description */
483 int m_iParentalRating
= 0; /*!< parental rating */
484 std::string m_strParentalRatingCode
; /*!< parental rating code */
485 int m_iStarRating
= 0; /*!< star rating */
486 int m_iSeriesNumber
= -1; /*!< series number */
487 int m_iEpisodeNumber
= -1; /*!< episode number */
488 int m_iEpisodePart
= -1; /*!< episode part number */
489 unsigned int m_iUniqueBroadcastID
= 0; /*!< unique broadcast ID */
490 std::string m_strTitle
; /*!< title */
491 std::string m_strPlotOutline
; /*!< plot outline */
492 std::string m_strPlot
; /*!< plot */
493 std::string m_strOriginalTitle
; /*!< original title */
494 std::vector
<std::string
> m_cast
; /*!< cast */
495 std::vector
<std::string
> m_directors
; /*!< director(s) */
496 std::vector
<std::string
> m_writers
; /*!< writer(s) */
497 int m_iYear
= 0; /*!< year */
498 std::string m_strIMDBNumber
; /*!< imdb number */
499 mutable std::vector
<std::string
> m_genre
; /*!< genre */
500 std::string m_strEpisodeName
; /*!< episode name */
501 CPVRCachedImage m_iconPath
; /*!< the path to the icon */
502 CDateTime m_startTime
; /*!< event start time */
503 CDateTime m_endTime
; /*!< event end time */
504 CDateTime m_firstAired
; /*!< first airdate */
505 unsigned int m_iFlags
= 0; /*!< the flags applicable to this EPG entry */
506 std::string m_strSeriesLink
; /*!< series link */
507 bool m_bIsGapTag
= false;
509 mutable CCriticalSection m_critSection
;
510 std::shared_ptr
<CPVREpgChannelData
> m_channelData
;