summaryrefslogtreecommitdiff
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
parentc80bd754ac12026a71793f26822c936b58cfd603 (diff)
downloadvdr-plugin-tvguideng-b55442a1efcaa717fe5e415679df253ca08047b5.tar.gz
vdr-plugin-tvguideng-b55442a1efcaa717fe5e415679df253ca08047b5.tar.bz2
Refactor reruns
-rw-r--r--config.c2
-rw-r--r--config.h2
-rw-r--r--detailview.c105
-rw-r--r--detailview.h1
-rw-r--r--po/de_DE.po5
-rw-r--r--setup.c2
6 files changed, 60 insertions, 57 deletions
diff --git a/config.c b/config.c
index 72cfcc9..cbf0124 100644
--- a/config.c
+++ b/config.c
@@ -19,6 +19,7 @@ cTVGuideConfig::cTVGuideConfig(void) {
blueKeyMode = eBlueKeyFavorites;
intelligentSwitch = 0;
//settings for rerun display
+ useSubtitleRerun = 0;
rerunAmount = 10;
rerunDistance = 2;
rerunMaxChannel = 0;
@@ -62,6 +63,7 @@ bool cTVGuideConfig::SetupParse(const char *Name, const char *Value) {
else if (!strcasecmp(Name, "numKeyMode")) numKeyMode = atoi(Value);
else if (!strcasecmp(Name, "blueKeyMode")) blueKeyMode = atoi(Value);
else if (!strcasecmp(Name, "intelligentSwitch")) intelligentSwitch = atoi(Value);
+ else if (!strcasecmp(Name, "UseSubtitleRerun")) useSubtitleRerun = atoi(Value);
else if (!strcasecmp(Name, "rerunAmount")) rerunAmount = atoi(Value);
else if (!strcasecmp(Name, "rerunDistance")) rerunDistance = atoi(Value);
else if (!strcasecmp(Name, "rerunMaxChannel")) rerunMaxChannel = atoi(Value);
diff --git a/config.h b/config.h
index 7df30de..c8fd70c 100644
--- a/config.h
+++ b/config.h
@@ -60,6 +60,7 @@ public:
int numKeyMode;
int blueKeyMode;
int intelligentSwitch;
+ int useSubtitleRerun;
int rerunAmount;
int rerunDistance;
int rerunMaxChannel;
@@ -83,7 +84,6 @@ public:
int favLimitChannels;
int favStartChannel;
int favStopChannel;
- int useSubtitleRerun;
int switchMinsBefore;
bool SetupParse(const char *Name, const char *Value);
};
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++;
}
}
diff --git a/detailview.h b/detailview.h
index d5174d0..84de6bc 100644
--- a/detailview.h
+++ b/detailview.h
@@ -27,7 +27,6 @@ private:
int NumActors(void);
void SetScraperTokens(void);
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *LoadReruns(void);
- int NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
void SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
void SetEpgPictures(int eventId);
public:
diff --git a/po/de_DE.po b/po/de_DE.po
index 3626b88..938b8d5 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-tvguideng 0.0.1\n"
"Report-Msgid-Bugs-To: <see README>\n"
-"POT-Creation-Date: 2020-07-15 16:59+0200\n"
+"POT-Creation-Date: 2020-07-16 13:42+0200\n"
"PO-Revision-Date: 2015-03-08 17:49+0200\n"
"Last-Translator: Louis\n"
"Language-Team: \n"
@@ -567,6 +567,9 @@ msgstr "Tasten Blau und OK"
msgid "\"Intelligent\" channel switch mode"
msgstr "\"Intelligenter\" Kanalumschalt Modus"
+msgid "Use Subtitle for reruns"
+msgstr "Untertitel für Wiederholungen vergleichen"
+
msgid "Maximum number of reruns to display"
msgstr "Maximale Anzahl dargestellter Wiederholungen"
diff --git a/setup.c b/setup.c
index c178cba..5ac61c4 100644
--- a/setup.c
+++ b/setup.c
@@ -51,6 +51,7 @@ void cTvGuideSetup::Setup(void) {
Add(new cMenuEditStraItem(tr("Functionality of numeric Keys"), &tmpConfig.numKeyMode, 2, numMode));
Add(new cMenuEditStraItem(tr("Keys Blue and OK"), &tmpConfig.blueKeyMode, 3, blueMode));
Add(new cMenuEditBoolItem(tr("\"Intelligent\" channel switch mode"), &tmpConfig.intelligentSwitch));
+ Add(new cMenuEditBoolItem(tr("Use Subtitle for reruns"), &tmpConfig.useSubtitleRerun));
Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &tmpConfig.rerunAmount, 1, 100));
Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &tmpConfig.rerunDistance, 0, 1000));
Add(new cMenuEditIntItem(tr("Limit Channel Numbers for reruns"), &tmpConfig.rerunMaxChannel, 0, 1000, tr("no limit")));
@@ -112,6 +113,7 @@ void cTvGuideSetup::Store(void) {
SetupStore("numKeyMode", config.numKeyMode);
SetupStore("blueKeyMode", config.blueKeyMode);
SetupStore("intelligentSwitch", config.intelligentSwitch);
+ SetupStore("UseSubtitleRerun", config.useSubtitleRerun);
SetupStore("rerunAmount", config.rerunAmount);
SetupStore("rerunDistance", config.rerunDistance);
SetupStore("rerunMaxChannel", config.rerunMaxChannel);