File: EpgInfoTag.cpp

package info (click to toggle)
kodi 2%3A21.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 143,076 kB
  • sloc: cpp: 694,471; xml: 52,618; ansic: 38,300; python: 7,161; sh: 4,289; javascript: 2,325; makefile: 1,791; perl: 969; java: 513; cs: 390; objc: 340
file content (677 lines) | stat: -rw-r--r-- 19,251 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
/*
 *  Copyright (C) 2012-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "EpgInfoTag.h"

#include "ServiceBroker.h"
#include "pvr/PVRManager.h"
#include "pvr/PVRPlaybackState.h"
#include "pvr/addons/PVRClient.h"
#include "pvr/epg/Epg.h"
#include "pvr/epg/EpgChannelData.h"
#include "pvr/epg/EpgDatabase.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
#include "utils/Variant.h"
#include "utils/log.h"

#include <memory>
#include <mutex>
#include <string>
#include <vector>

using namespace PVR;

const std::string CPVREpgInfoTag::IMAGE_OWNER_PATTERN = "epgtag_{}";

CPVREpgInfoTag::CPVREpgInfoTag(int iEpgID, const std::string& iconPath)
  : m_iUniqueBroadcastID(EPG_TAG_INVALID_UID),
    m_iconPath(iconPath, StringUtils::Format(IMAGE_OWNER_PATTERN, iEpgID)),
    m_iFlags(EPG_TAG_FLAG_UNDEFINED),
    m_channelData(new CPVREpgChannelData),
    m_iEpgID(iEpgID)
{
}

CPVREpgInfoTag::CPVREpgInfoTag(const std::shared_ptr<CPVREpgChannelData>& channelData,
                               int iEpgID,
                               const CDateTime& start,
                               const CDateTime& end,
                               bool bIsGapTag)
  : m_iUniqueBroadcastID(EPG_TAG_INVALID_UID),
    m_iconPath(StringUtils::Format(IMAGE_OWNER_PATTERN, iEpgID)),
    m_iFlags(EPG_TAG_FLAG_UNDEFINED),
    m_bIsGapTag(bIsGapTag),
    m_iEpgID(iEpgID)
{
  if (channelData)
    m_channelData = channelData;
  else
    m_channelData = std::make_shared<CPVREpgChannelData>();

  const CDateTimeSpan correction(
      0, 0, 0, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection);
  m_startTime = start + correction;
  m_endTime = end + correction;
}

CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG& data,
                               int iClientId,
                               const std::shared_ptr<CPVREpgChannelData>& channelData,
                               int iEpgID)
  : m_iGenreType(data.iGenreType),
    m_iGenreSubType(data.iGenreSubType),
    m_iParentalRating(data.iParentalRating),
    m_iStarRating(data.iStarRating),
    m_iSeriesNumber(data.iSeriesNumber),
    m_iEpisodeNumber(data.iEpisodeNumber),
    m_iEpisodePart(data.iEpisodePartNumber),
    m_iUniqueBroadcastID(data.iUniqueBroadcastId),
    m_iYear(data.iYear),
    m_iconPath(data.strIconPath ? data.strIconPath : "",
               StringUtils::Format(IMAGE_OWNER_PATTERN, iEpgID)),
    m_startTime(
        data.startTime +
        CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection),
    m_endTime(data.endTime +
              CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection),
    m_iFlags(data.iFlags),
    m_iEpgID(iEpgID)
{
  // strFirstAired is optional, so check if supported before assigning it
  if (data.strFirstAired && strlen(data.strFirstAired) > 0)
    m_firstAired.SetFromW3CDate(data.strFirstAired);

  if (channelData)
  {
    m_channelData = channelData;

    if (m_channelData->ClientId() != iClientId)
      CLog::LogF(LOGERROR, "Client id mismatch (channel: {}, epg: {})!", m_channelData->ClientId(),
                 iClientId);
    if (m_channelData->UniqueClientChannelId() != static_cast<int>(data.iUniqueChannelId))
      CLog::LogF(LOGERROR, "Channel uid mismatch (channel: {}, epg: {})!",
                 m_channelData->UniqueClientChannelId(), data.iUniqueChannelId);
  }
  else
  {
    // provide minimalistic channel data until we get fully initialized later
    m_channelData = std::make_shared<CPVREpgChannelData>(iClientId, data.iUniqueChannelId);
  }

  // explicit NULL check, because there is no implicit NULL constructor for std::string
  if (data.strTitle)
    m_strTitle = data.strTitle;
  if (data.strGenreDescription)
    m_strGenreDescription = data.strGenreDescription;
  if (data.strPlotOutline)
    m_strPlotOutline = data.strPlotOutline;
  if (data.strPlot)
    m_strPlot = data.strPlot;
  if (data.strOriginalTitle)
    m_strOriginalTitle = data.strOriginalTitle;
  if (data.strCast)
    m_cast = Tokenize(data.strCast);
  if (data.strDirector)
    m_directors = Tokenize(data.strDirector);
  if (data.strWriter)
    m_writers = Tokenize(data.strWriter);
  if (data.strIMDBNumber)
    m_strIMDBNumber = data.strIMDBNumber;
  if (data.strEpisodeName)
    m_strEpisodeName = data.strEpisodeName;
  if (data.strSeriesLink)
    m_strSeriesLink = data.strSeriesLink;
  if (data.strParentalRatingCode)
    m_strParentalRatingCode = data.strParentalRatingCode;
}

void CPVREpgInfoTag::SetChannelData(const std::shared_ptr<CPVREpgChannelData>& data)
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  if (data)
    m_channelData = data;
  else
    m_channelData = std::make_shared<CPVREpgChannelData>();
}

bool CPVREpgInfoTag::operator==(const CPVREpgInfoTag& right) const
{
  if (this == &right)
    return true;

  std::unique_lock<CCriticalSection> lock(m_critSection);
  return (m_iUniqueBroadcastID == right.m_iUniqueBroadcastID && m_channelData &&
          right.m_channelData &&
          m_channelData->UniqueClientChannelId() == right.m_channelData->UniqueClientChannelId() &&
          m_channelData->ClientId() == right.m_channelData->ClientId());
}

bool CPVREpgInfoTag::operator!=(const CPVREpgInfoTag& right) const
{
  if (this == &right)
    return false;

  return !(*this == right);
}

void CPVREpgInfoTag::Serialize(CVariant& value) const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  value["broadcastid"] = m_iDatabaseID; // Use DB id here as it is unique across PVR clients
  value["channeluid"] = m_channelData->UniqueClientChannelId();
  value["parentalrating"] = m_iParentalRating;
  value["parentalratingcode"] = m_strParentalRatingCode;
  value["rating"] = m_iStarRating;
  value["title"] = m_strTitle;
  value["plotoutline"] = m_strPlotOutline;
  value["plot"] = m_strPlot;
  value["originaltitle"] = m_strOriginalTitle;
  value["thumbnail"] = ClientIconPath();
  value["cast"] = DeTokenize(m_cast);
  value["director"] = DeTokenize(m_directors);
  value["writer"] = DeTokenize(m_writers);
  value["year"] = m_iYear;
  value["imdbnumber"] = m_strIMDBNumber;
  value["genre"] = Genre();
  value["filenameandpath"] = Path();
  value["starttime"] = m_startTime.IsValid() ? m_startTime.GetAsDBDateTime() : StringUtils::Empty;
  value["endtime"] = m_endTime.IsValid() ? m_endTime.GetAsDBDateTime() : StringUtils::Empty;
  value["runtime"] = GetDuration() / 60;
  value["firstaired"] = m_firstAired.IsValid() ? m_firstAired.GetAsDBDate() : StringUtils::Empty;
  value["progress"] = Progress();
  value["progresspercentage"] = ProgressPercentage();
  value["episodename"] = m_strEpisodeName;
  value["episodenum"] = m_iEpisodeNumber;
  value["episodepart"] = m_iEpisodePart;
  value["seasonnum"] = m_iSeriesNumber;
  value["isactive"] = IsActive();
  value["wasactive"] = WasActive();
  value["isseries"] = IsSeries();
  value["serieslink"] = m_strSeriesLink;
  value["clientid"] = m_channelData->ClientId();
}

int CPVREpgInfoTag::ClientID() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_channelData->ClientId();
}

CDateTime CPVREpgInfoTag::GetCurrentPlayingTime() const
{
  return CServiceBroker::GetPVRManager().PlaybackState()->GetChannelPlaybackTime(ClientID(),
                                                                                 UniqueChannelID());
}

bool CPVREpgInfoTag::IsActive() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime <= now && m_endTime > now);
}

bool CPVREpgInfoTag::WasActive() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_endTime < now);
}

bool CPVREpgInfoTag::IsUpcoming() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime > now);
}

float CPVREpgInfoTag::ProgressPercentage() const
{
  float fReturn = 0.0f;

  time_t currentTime, startTime, endTime;
  CDateTime::GetUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);
  m_endTime.GetAsTime(endTime);
  int iDuration = endTime - startTime > 0 ? endTime - startTime : 3600;

  if (currentTime >= startTime && currentTime <= endTime)
    fReturn = static_cast<float>(currentTime - startTime) * 100.0f / iDuration;
  else if (currentTime > endTime)
    fReturn = 100.0f;

  return fReturn;
}

int CPVREpgInfoTag::Progress() const
{
  time_t currentTime, startTime;
  CDateTime::GetUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);
  int iDuration = currentTime - startTime;

  if (iDuration <= 0)
    return 0;

  return iDuration;
}

void CPVREpgInfoTag::SetUniqueBroadcastID(unsigned int iUniqueBroadcastID)
{
  m_iUniqueBroadcastID = iUniqueBroadcastID;
}

unsigned int CPVREpgInfoTag::UniqueBroadcastID() const
{
  return m_iUniqueBroadcastID;
}

int CPVREpgInfoTag::DatabaseID() const
{
  return m_iDatabaseID;
}

int CPVREpgInfoTag::UniqueChannelID() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_channelData->UniqueClientChannelId();
}

std::string CPVREpgInfoTag::ChannelIconPath() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_channelData->ChannelIconPath();
}

CDateTime CPVREpgInfoTag::StartAsUTC() const
{
  return m_startTime;
}

CDateTime CPVREpgInfoTag::StartAsLocalTime() const
{
  return m_startTime.GetAsLocalDateTime();
}

CDateTime CPVREpgInfoTag::EndAsUTC() const
{
  return m_endTime;
}

CDateTime CPVREpgInfoTag::EndAsLocalTime() const
{
  return m_endTime.GetAsLocalDateTime();
}

void CPVREpgInfoTag::SetEndFromUTC(const CDateTime& end)
{
  m_endTime = end;
}

int CPVREpgInfoTag::GetDuration() const
{
  time_t start, end;
  m_startTime.GetAsTime(start);
  m_endTime.GetAsTime(end);
  return end - start > 0 ? end - start : 3600;
}

std::string CPVREpgInfoTag::Title() const
{
  return m_strTitle;
}

std::string CPVREpgInfoTag::PlotOutline() const
{
  return m_strPlotOutline;
}

std::string CPVREpgInfoTag::Plot() const
{
  return m_strPlot;
}

std::string CPVREpgInfoTag::OriginalTitle() const
{
  return m_strOriginalTitle;
}

const std::vector<std::string> CPVREpgInfoTag::Cast() const
{
  return m_cast;
}

const std::vector<std::string> CPVREpgInfoTag::Directors() const
{
  return m_directors;
}

const std::vector<std::string> CPVREpgInfoTag::Writers() const
{
  return m_writers;
}

const std::string CPVREpgInfoTag::GetCastLabel() const
{
  // Note: see CVideoInfoTag::GetCast for reference implementation.
  std::string strLabel;
  for (const auto& castEntry : m_cast)
    strLabel += StringUtils::Format("{}\n", castEntry);

  return StringUtils::TrimRight(strLabel, "\n");
}

const std::string CPVREpgInfoTag::GetDirectorsLabel() const
{
  return StringUtils::Join(
      m_directors,
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoItemSeparator);
}

const std::string CPVREpgInfoTag::GetWritersLabel() const
{
  return StringUtils::Join(
      m_writers,
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoItemSeparator);
}

const std::string CPVREpgInfoTag::GetGenresLabel() const
{
  return StringUtils::Join(
      Genre(), CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoItemSeparator);
}

int CPVREpgInfoTag::Year() const
{
  return m_iYear;
}

std::string CPVREpgInfoTag::IMDBNumber() const
{
  return m_strIMDBNumber;
}

int CPVREpgInfoTag::GenreType() const
{
  return m_iGenreType;
}

int CPVREpgInfoTag::GenreSubType() const
{
  return m_iGenreSubType;
}

std::string CPVREpgInfoTag::GenreDescription() const
{
  return m_strGenreDescription;
}

const std::vector<std::string> CPVREpgInfoTag::Genre() const
{
  if (m_genre.empty())
  {
    if ((m_iGenreType == EPG_GENRE_USE_STRING || m_iGenreSubType == EPG_GENRE_USE_STRING) &&
        !m_strGenreDescription.empty())
    {
      // Type and sub type are both not given. No EPG color coding possible unless sub type is
      // used to specify EPG_GENRE_USE_STRING leaving type available for genre category, use the
      // provided genre description for the text.
      m_genre = Tokenize(m_strGenreDescription);
    }

    if (m_genre.empty())
    {
      // Determine the genre from the type and subtype IDs.
      m_genre = Tokenize(CPVREpg::ConvertGenreIdToString(m_iGenreType, m_iGenreSubType));
    }
  }
  return m_genre;
}

CDateTime CPVREpgInfoTag::FirstAired() const
{
  return m_firstAired;
}

int CPVREpgInfoTag::ParentalRating() const
{
  return m_iParentalRating;
}

std::string CPVREpgInfoTag::ParentalRatingCode() const
{
  return m_strParentalRatingCode;
}

int CPVREpgInfoTag::StarRating() const
{
  return m_iStarRating;
}

int CPVREpgInfoTag::SeriesNumber() const
{
  return m_iSeriesNumber;
}

std::string CPVREpgInfoTag::SeriesLink() const
{
  return m_strSeriesLink;
}

int CPVREpgInfoTag::EpisodeNumber() const
{
  return m_iEpisodeNumber;
}

int CPVREpgInfoTag::EpisodePart() const
{
  return m_iEpisodePart;
}

std::string CPVREpgInfoTag::EpisodeName() const
{
  return m_strEpisodeName;
}

std::string CPVREpgInfoTag::IconPath() const
{
  return m_iconPath.GetLocalImage();
}

std::string CPVREpgInfoTag::ClientIconPath() const
{
  return m_iconPath.GetClientImage();
}

std::string CPVREpgInfoTag::Path() const
{
  return StringUtils::Format("pvr://guide/{:04}/{}.epg", EpgID(), m_startTime.GetAsDBDateTime());
}

bool CPVREpgInfoTag::Update(const CPVREpgInfoTag& tag, bool bUpdateBroadcastId /* = true */)
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  bool bChanged =
      (m_strTitle != tag.m_strTitle || m_strPlotOutline != tag.m_strPlotOutline ||
       m_strPlot != tag.m_strPlot || m_strOriginalTitle != tag.m_strOriginalTitle ||
       m_cast != tag.m_cast || m_directors != tag.m_directors || m_writers != tag.m_writers ||
       m_iYear != tag.m_iYear || m_strIMDBNumber != tag.m_strIMDBNumber ||
       m_startTime != tag.m_startTime || m_endTime != tag.m_endTime ||
       m_iGenreType != tag.m_iGenreType || m_iGenreSubType != tag.m_iGenreSubType ||
       m_strGenreDescription != tag.m_strGenreDescription || m_firstAired != tag.m_firstAired ||
       m_iParentalRating != tag.m_iParentalRating ||
       m_strParentalRatingCode != tag.m_strParentalRatingCode ||
       m_iStarRating != tag.m_iStarRating || m_iEpisodeNumber != tag.m_iEpisodeNumber ||
       m_iEpisodePart != tag.m_iEpisodePart || m_iSeriesNumber != tag.m_iSeriesNumber ||
       m_strEpisodeName != tag.m_strEpisodeName ||
       m_iUniqueBroadcastID != tag.m_iUniqueBroadcastID || m_iEpgID != tag.m_iEpgID ||
       m_genre != tag.m_genre || m_iconPath != tag.m_iconPath || m_iFlags != tag.m_iFlags ||
       m_strSeriesLink != tag.m_strSeriesLink || m_channelData != tag.m_channelData);

  if (bUpdateBroadcastId)
    bChanged |= (m_iDatabaseID != tag.m_iDatabaseID);

  if (bChanged)
  {
    if (bUpdateBroadcastId)
      m_iDatabaseID = tag.m_iDatabaseID;

    m_strTitle = tag.m_strTitle;
    m_strPlotOutline = tag.m_strPlotOutline;
    m_strPlot = tag.m_strPlot;
    m_strOriginalTitle = tag.m_strOriginalTitle;
    m_cast = tag.m_cast;
    m_directors = tag.m_directors;
    m_writers = tag.m_writers;
    m_iYear = tag.m_iYear;
    m_strIMDBNumber = tag.m_strIMDBNumber;
    m_startTime = tag.m_startTime;
    m_endTime = tag.m_endTime;
    m_iGenreType = tag.m_iGenreType;
    m_iGenreSubType = tag.m_iGenreSubType;
    m_strGenreDescription = tag.m_strGenreDescription;
    m_genre = tag.m_genre;
    m_iEpgID = tag.m_iEpgID;
    m_iFlags = tag.m_iFlags;
    m_strSeriesLink = tag.m_strSeriesLink;
    m_firstAired = tag.m_firstAired;
    m_iParentalRating = tag.m_iParentalRating;
    m_strParentalRatingCode = tag.m_strParentalRatingCode;
    m_iStarRating = tag.m_iStarRating;
    m_iEpisodeNumber = tag.m_iEpisodeNumber;
    m_iEpisodePart = tag.m_iEpisodePart;
    m_iSeriesNumber = tag.m_iSeriesNumber;
    m_strEpisodeName = tag.m_strEpisodeName;
    m_iUniqueBroadcastID = tag.m_iUniqueBroadcastID;
    m_iconPath = tag.m_iconPath;
    m_channelData = tag.m_channelData;
  }

  return bChanged;
}

bool CPVREpgInfoTag::QueuePersistQuery(const std::shared_ptr<CPVREpgDatabase>& database)
{
  if (!database)
  {
    CLog::LogF(LOGERROR, "Could not open the EPG database");
    return false;
  }

  return database->QueuePersistQuery(*this);
}

std::vector<PVR_EDL_ENTRY> CPVREpgInfoTag::GetEdl() const
{
  std::vector<PVR_EDL_ENTRY> edls;

  std::unique_lock<CCriticalSection> lock(m_critSection);
  const std::shared_ptr<const CPVRClient> client =
      CServiceBroker::GetPVRManager().GetClient(m_channelData->ClientId());

  if (client && client->GetClientCapabilities().SupportsEpgTagEdl())
    client->GetEpgTagEdl(shared_from_this(), edls);

  return edls;
}

int CPVREpgInfoTag::EpgID() const
{
  return m_iEpgID;
}

void CPVREpgInfoTag::SetEpgID(int iEpgID)
{
  m_iEpgID = iEpgID;
  m_iconPath.SetOwner(StringUtils::Format(IMAGE_OWNER_PATTERN, m_iEpgID));
}

bool CPVREpgInfoTag::IsRecordable() const
{
  bool bIsRecordable = false;

  std::unique_lock<CCriticalSection> lock(m_critSection);
  const std::shared_ptr<const CPVRClient> client =
      CServiceBroker::GetPVRManager().GetClient(m_channelData->ClientId());
  if (!client || (client->IsRecordable(shared_from_this(), bIsRecordable) != PVR_ERROR_NO_ERROR))
  {
    // event end time based fallback
    bIsRecordable = EndAsLocalTime() > CDateTime::GetCurrentDateTime();
  }
  return bIsRecordable;
}

bool CPVREpgInfoTag::IsPlayable() const
{
  bool bIsPlayable = false;

  std::unique_lock<CCriticalSection> lock(m_critSection);
  const std::shared_ptr<const CPVRClient> client =
      CServiceBroker::GetPVRManager().GetClient(m_channelData->ClientId());
  if (!client || (client->IsPlayable(shared_from_this(), bIsPlayable) != PVR_ERROR_NO_ERROR))
  {
    // fallback
    bIsPlayable = false;
  }
  return bIsPlayable;
}

bool CPVREpgInfoTag::IsSeries() const
{
  if ((m_iFlags & EPG_TAG_FLAG_IS_SERIES) > 0 || SeriesNumber() >= 0 || EpisodeNumber() >= 0 ||
      EpisodePart() >= 0)
    return true;
  else
    return false;
}

bool CPVREpgInfoTag::IsRadio() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_channelData->IsRadio();
}

bool CPVREpgInfoTag::IsParentalLocked() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_channelData->IsLocked();
}

bool CPVREpgInfoTag::IsGapTag() const
{
  std::unique_lock<CCriticalSection> lock(m_critSection);
  return m_bIsGapTag;
}

bool CPVREpgInfoTag::IsNew() const
{
  return (m_iFlags & EPG_TAG_FLAG_IS_NEW) > 0;
}

bool CPVREpgInfoTag::IsPremiere() const
{
  return (m_iFlags & EPG_TAG_FLAG_IS_PREMIERE) > 0;
}

bool CPVREpgInfoTag::IsFinale() const
{
  return (m_iFlags & EPG_TAG_FLAG_IS_FINALE) > 0;
}

bool CPVREpgInfoTag::IsLive() const
{
  return (m_iFlags & EPG_TAG_FLAG_IS_LIVE) > 0;
}

const std::vector<std::string> CPVREpgInfoTag::Tokenize(const std::string& str)
{
  return StringUtils::Split(str, EPG_STRING_TOKEN_SEPARATOR);
}

const std::string CPVREpgInfoTag::DeTokenize(const std::vector<std::string>& tokens)
{
  return StringUtils::Join(tokens, EPG_STRING_TOKEN_SEPARATOR);
}