summaryrefslogtreecommitdiff
path: root/detailview.c
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2020-07-16 13:50:57 +0200
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2020-07-16 13:52:30 +0200
commitb55442a1efcaa717fe5e415679df253ca08047b5 (patch)
tree39a7f5e8cff5151fc11dc9a419198dd0c1e86320 /detailview.c
parentc80bd754ac12026a71793f26822c936b58cfd603 (diff)
downloadvdr-plugin-tvguideng-b55442a1efcaa717fe5e415679df253ca08047b5.tar.gz
vdr-plugin-tvguideng-b55442a1efcaa717fe5e415679df253ca08047b5.tar.bz2
Refactor reruns
Diffstat (limited to 'detailview.c')
-rw-r--r--detailview.c105
1 files changed, 51 insertions, 54 deletions
diff --git a/detailview.c b/detailview.c
index 0915c99..f537d99 100644
--- a/detailview.c
+++ b/detailview.c
@@ -311,11 +311,14 @@ void cDetailView::DrawHeader(void) {
header->AddIntToken((int)eDetailedHeaderIT::year, sStartTime->tm_year + 1900);
header->AddIntToken((int)eDetailedHeaderIT::daynumeric, sStartTime->tm_mday);
header->AddIntToken((int)eDetailedHeaderIT::month, sStartTime->tm_mon+1);
+ const cChannel* channel = NULL;
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
+ {
LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(event->ChannelID());
+ channel = Channels->GetByChannelID(event->ChannelID());
+ }
#else
- const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
+ channel = Channels.GetByChannelID(event->ChannelID());
#endif
if (channel) {
header->AddStringToken((int)eDetailedHeaderST::channelname, channel->Name());
@@ -488,7 +491,9 @@ void cDetailView::SetTabTokens(void) {
int numActors = NumActors();
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns = LoadReruns();
- int numReruns = NumReruns(reruns);
+ int numReruns = 0;
+ if (reruns && reruns->Count() > 0)
+ numReruns = reruns->Count();
vector<int> loopInfo;
loopInfo.push_back(numReruns);
@@ -496,7 +501,7 @@ void cDetailView::SetTabTokens(void) {
tabs->SetLoop(loopInfo);
if (numReruns > 0) {
- tabs->AddIntToken((int)eDetailedEpgIT::hasreruns, 1);
+ tabs->AddIntToken((int)eDetailedEpgIT::hasreruns, numReruns);
SetReruns(reruns);
}
if (scrapInfoAvailable) {
@@ -511,87 +516,77 @@ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *cDetailView::LoadReru
if (!epgSearchPlugin)
return NULL;
- if (isempty(event->Title()))
+ if (!event || isempty(event->Title()))
return NULL;
Epgsearch_searchresults_v1_0 data;
- data.query = (char*)event->Title();
+ std::string strQuery = event->Title();
+
+ if (config.useSubtitleRerun && !isempty(event->ShortText())) {
+ strQuery += "~";
+ strQuery += event->ShortText();
+ }
+
+ data.query = (char *)strQuery.c_str();
data.mode = 0;
data.channelNr = 0;
data.useTitle = true;
data.useSubTitle = true;
data.useDescription = false;
- cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *result = NULL;
- if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data))
- result = data.pResultList;
- return result;
-}
-
-int cDetailView::NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
- if (!reruns || reruns->Count() < 2)
- return 0;
-
int maxNumReruns = config.rerunAmount;
int rerunDistance = config.rerunDistance * 3600;
int rerunMaxChannel = config.rerunMaxChannel;
int i = 0;
- for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->Next(r)) {
- time_t eventStart = event->StartTime();
- time_t rerunStart = r->event->StartTime();
+
+ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns = NULL;
+ if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data)) {
+ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *result = data.pResultList;
+ if (result) {
+ for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = result->First(); r && i < maxNumReruns; r = result->Next(r)) {
+ time_t eventStart = event->StartTime();
+ time_t rerunStart = r->event->StartTime();
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(r->event->ChannelID(), true, true);
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(r->event->ChannelID(), true, true);
#else
- const cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
+ const cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
#endif
- //check for identical event
- if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
- continue;
- //check for timely distance
- if (rerunDistance > 0)
- if (rerunStart - eventStart < rerunDistance)
- continue;
- //check for maxchannel
- if (rerunMaxChannel > 0)
- if (channel && channel->Number() > rerunMaxChannel)
- continue;
- i++;
+ //check for identical event
+ if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
+ continue;
+ //check for timely distance
+ if (rerunDistance > 0)
+ if (rerunStart - eventStart < rerunDistance)
+ continue;
+ //check for maxchannel
+ if (rerunMaxChannel > 0)
+ if (channel && channel->Number() > rerunMaxChannel)
+ continue;
+ if (!reruns) reruns = new cList<Epgsearch_searchresults_v1_0::cServiceSearchResult>;
+ reruns->Add(r);
+ i++;
+ }
+ }
}
- return i;
+ return reruns;
}
void cDetailView::SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
- if (!reruns || reruns->Count() < 2)
+ if (!reruns || reruns->Count() < 1)
return;
- int rerunsIndex = tabs->GetLoopIndex("reruns");
- int maxNumReruns = config.rerunAmount;
- int rerunDistance = config.rerunDistance * 3600;
- int rerunMaxChannel = config.rerunMaxChannel;
+ int rerunsIndex = tabs->GetLoopIndex("reruns");
int i = 0;
- for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->Next(r)) {
- time_t eventStart = event->StartTime();
- time_t rerunStart = r->event->StartTime();
+ for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r; r = reruns->Next(r)) {
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(r->event->ChannelID(), true, true);
#else
const cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
#endif
- //check for identical event
- if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
- continue;
- //check for timely distance
- if (rerunDistance > 0)
- if (rerunStart - eventStart < rerunDistance)
- continue;
- //check for maxchannel
- if (rerunMaxChannel > 0)
- if (channel && channel->Number() > rerunMaxChannel)
- continue;
tabs->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::title, r->event->Title());
tabs->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::shorttext, r->event->ShortText());
tabs->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::start, *(r->event->GetTimeString()));
@@ -610,6 +605,8 @@ void cDetailView::SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchRe
tabs->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelname, "");
tabs->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelnumber, "");
}
+ if (r == reruns->Last())
+ break;
i++;
}
}