Skip to content

Commit

Permalink
autoTimerReason
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Oct 22, 2023
1 parent cdad668 commit 30c086c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
13 changes: 10 additions & 3 deletions pages/timerconflicts.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
std::string longDescription;
std::string searchTimName;
std::string searchTimId;
std::string recID;
std::string recName;
std::string title;
#if VDRVERSNUM >= 20301
if (!timer->Event()) {
Expand All @@ -111,7 +113,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+ "<br/><br/>" + tr("Click to view details.");
AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::SearchTimerInfo(*timer, "searchtimer").c_str());
searchTimId = SortedTimers::SearchTimerInfo(*timer, "s-id");
if (searchTimName.empty() && searchTimId.empty() ) AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::TvScraperTimerInfo(*timer).c_str());
if (searchTimName.empty() && searchTimId.empty() ) AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::TvScraperTimerInfo(*timer, recID, recName).c_str() );
title = epgEvent->Title();
}
std::string timerFile;
Expand All @@ -137,10 +139,15 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");

<td class="<? bottom ? "bottomrow" ?>"><div class="withmargin">
% if ( !timer->Local() || searchTimId.empty() ) {
<$$ StringReplace(searchTimName, "~", "~<wbr>") $></div></td>
<# not created by epgsearch, check tvscraper autotimer #>
<$$ StringReplace(searchTimName, "~", "~<wbr>") $>
% if (!recID.empty() ) {
<a href="epginfo.html?epgid=<$ recID $>"> <$$ StringReplace(recName, "~", "~<wbr>") $></a>
% }
% } else {
<a href="edit_searchtimer.html?searchtimerid=<$ searchTimId $>"><$$ StringReplace(searchTimName, "~", "~<wbr>") $></a></div></td>
<a href="edit_searchtimer.html?searchtimerid=<$ searchTimId $>"><$$ StringReplace(searchTimName, "~", "~<wbr>") $></a>
% }
</div></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><a class="hidden-xs action-rightcol" href="searchresults.html?searchplain=<$ StringEscapeAndBreak(title) $>"><img src="<$ LiveSetup().GetThemedLink("img", "search.png") $>" alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>></img></a></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><a class="hidden-xs action-rightcol" href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><div class="hidden-xs action-rightcol"><& pageelems.edit_timer timerId=(timers.GetTimerId(*timer)) &></div></td>
Expand Down
19 changes: 13 additions & 6 deletions pages/timers.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ using namespace vdrlive;
std::string longDescription;
std::string searchTimName;
std::string searchTimId;
std::string recID;
std::string recName;

if (timer->Event())
{
Expand All @@ -104,7 +106,7 @@ using namespace vdrlive;
if (truncated) longDescription += "...";
AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::SearchTimerInfo(*timer, "searchtimer").c_str());
searchTimId = SortedTimers::SearchTimerInfo(*timer, "s-id");
if (searchTimName.empty() && searchTimId.empty() ) AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::TvScraperTimerInfo(*timer).c_str());
if (searchTimName.empty() && searchTimId.empty() ) AppendHtmlEscapedAndCorrectNonUTF8(searchTimName, SortedTimers::TvScraperTimerInfo(*timer, recID, recName).c_str());
}
std::string currentDay = SortedTimers::GetTimerDays(timer);
const cTimer *nextTimer = NULL;
Expand Down Expand Up @@ -189,14 +191,19 @@ using namespace vdrlive;
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><div class="xs-nomargin"><$ timer->Local()?trVDR(" "):timer->Remote() $></div></td>
<td class="<? bottom ? "bottomrow" ?>"><div class="withmargin">
% if ( !timer->Local() || searchTimId.empty() ) {
<$$ StringReplace(searchTimName, "~", "~<wbr>") $></div></td>
<# not created by epgsearch, check tvscraper autotimer #>
<$$ StringReplace(searchTimName, "~", "~<wbr>") $>
% if (!recID.empty() ) {
<a href="epginfo.html?epgid=<$ recID $>"> <$$ StringReplace(recName, "~", "~<wbr>") $></a>
% }
% } else {
<a href="edit_searchtimer.html?searchtimerid=<$ searchTimId $>"><$$ StringReplace(searchTimName, "~", "~<wbr>") $></a></div></td>
<a href="edit_searchtimer.html?searchtimerid=<$ searchTimId $>"><$$ StringReplace(searchTimName, "~", "~<wbr>") $></a>
% }
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><a class="hidden-xs action-rightcol" href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><div class="hidden-xs action-rightcol"><& pageelems.edit_timer timerId=(timers.GetTimerId(*timer)) &></div></td>
</div></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><a class="hidden-xs action-rightcol" href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a></td>
<td class="<? bottom ? "bottomrow" ?> td-hidden-xs"><div class="hidden-xs action-rightcol"><& pageelems.edit_timer timerId=(timers.GetTimerId(*timer)) &></div></td>

<td class="rightcol <? bottom ? "bottomrow" ?>">
<td class="rightcol <? bottom ? "bottomrow" ?>">
<a class="display-xs action-rightcol" href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a>
<div class="display-xs action-rightcol"><& pageelems.edit_timer timerId=(timers.GetTimerId(*timer)) &></div>
<a class="action-rightcol" href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=delete"><img src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" <& tooltip.hint text=(tr("Delete timer")) &>></img></a></td>
Expand Down
17 changes: 17 additions & 0 deletions services.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ class cEnvironment

// NEW interface, used by live =========================================================

// Data structure for service "GetAutoTimerReason"
class cGetAutoTimerReason {
public:
//in:
const cTimer *timer = nullptr;
bool requestRecording = false;
//out
bool createdByTvscraper; // if this is false, please ignore all other return values
std::string reason; // translated, e.g. "Verbessern von Action~Salt"
std::string recordingName; // with folder, e.g. Action~Salt
const cRecording *recording; // only if requestRecording == true. Can always be nullptr, e.g. if the recording was deleted after the timer was created
cPlugin *call(cPlugin *pScraper = NULL) {
if (!pScraper) return cPluginManager::CallFirstService("GetAutoTimerReason", this);
else return pScraper->Service("GetAutoTimerReason", this)?pScraper:NULL;
}
};

// Data structure for service "GetScraperImageDir"
class cGetScraperImageDir {
public:
Expand Down
29 changes: 22 additions & 7 deletions timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <vdr/plugin.h>
#include <vdr/menu.h>
#include <vdr/svdrp.h>
#include "services.h"
#include "setup.h"

namespace vdrlive {

Expand Down Expand Up @@ -129,14 +131,27 @@ namespace vdrlive {
return info.str();
}

std::string SortedTimers::TvScraperTimerInfo(cTimer const& timer) {
std::string SortedTimers::TvScraperTimerInfo(cTimer const& timer, std::string &recID, std::string &recName) {
if (!timer.Aux()) return "";
std::string tvScraperInfo = GetXMLValue(timer.Aux(), "tvscraper");
if (tvScraperInfo.empty()) return "";
std::string data = GetXMLValue(tvScraperInfo, "reason");
if (data.empty() ) return "";
data.append(": ");
data.append(GetXMLValue(tvScraperInfo, "causedBy"));
cGetAutoTimerReason getAutoTimerReason;
getAutoTimerReason.timer = &timer;
getAutoTimerReason.requestRecording = true;
if (getAutoTimerReason.call(LiveSetup().GetPluginScraper()) ) {
if (!getAutoTimerReason.createdByTvscraper) return "";
if (getAutoTimerReason.recording) {
recID = "recording_" + MD5Hash(getAutoTimerReason.recording->FileName() );
recName = getAutoTimerReason.recordingName;
return getAutoTimerReason.reason;
}
return getAutoTimerReason.reason + " " + getAutoTimerReason.recordingName;
}
// fallback information, if this tvscraper method is not available
std::string tvScraperInfo = GetXMLValue(timer.Aux(), "tvscraper");
if (tvScraperInfo.empty()) return "";
std::string data = GetXMLValue(tvScraperInfo, "reason");
if (data.empty() ) return "";
data.append(": ");
data.append(GetXMLValue(tvScraperInfo, "causedBy"));
return data;
}

Expand Down
2 changes: 1 addition & 1 deletion timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace vdrlive {
static std::string GetTimerDays(cTimer const *timer);
static std::string GetTimerInfo(cTimer const& timer);
static std::string SearchTimerInfo(cTimer const& timer, std::string const& value);
static std::string TvScraperTimerInfo(cTimer const& timer);
static std::string TvScraperTimerInfo(cTimer const& timer, std::string &recID, std::string &recName);

private:
SortedTimers();
Expand Down

0 comments on commit 30c086c

Please sign in to comment.