Skip to content

Commit

Permalink
Advanced recording title search (#221)
Browse files Browse the repository at this point in the history
Backport of PR 220

Co-authored-by: emveepee <nospam>
  • Loading branch information
emveepee authored Nov 27, 2022
1 parent 6043f9c commit d40e722
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pvr.nextpvr/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.nextpvr"
version="19.0.4"
version="19.0.5"
name="NextPVR PVR Client"
provider-name="Graeme Blackley">
<requires>@ADDON_DEPENDS@
Expand Down
3 changes: 3 additions & 0 deletions pvr.nextpvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v19.0.5
- Backport advanced recording title search from PR 220

v19.0.4
- Backport start fast poll change from PR 214
v19.0.3
Expand Down
48 changes: 27 additions & 21 deletions src/Timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
switch (timer.GetTimerType())
{
case TIMER_ONCE_MANUAL:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_MANUAL");
// build one-off recording request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_MANUAL");
request = kodi::tools::StringUtils::Format("recording.save&name=%s&recording_id=%d&channel=%d&time_t=%d&duration=%d&pre_padding=%d&post_padding=%d&directory_id=%s",
encodedName.c_str(),
timer.GetClientIndex(),
Expand All @@ -688,22 +688,23 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
marginStart,
marginEnd,
directory.c_str()
);
);
break;
case TIMER_ONCE_EPG:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_EPG");
// build one-off recording request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_EPG");
request = kodi::tools::StringUtils::Format("recording.save&recording_id=%d&event_id=%d&pre_padding=%d&post_padding=%d&directory_id=%s",
timer.GetClientIndex(),
epgOid,
marginStart,
marginEnd,
directory.c_str());
directory.c_str()
);
break;

case TIMER_ONCE_EPG_CHILD:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_EPG_CHILD");
// build one-off recording request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_ONCE_EPG_CHILD");
if (m_settings.m_backendVersion < 50102)
{
kodi::Log(ADDON_LOG_ERROR, "Feature added in NextPVR 5.1.2");
Expand All @@ -715,15 +716,16 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
epgOid,
marginStart,
marginEnd,
directory.c_str());
directory.c_str()
);
break;

case TIMER_REPEATING_EPG:
if (timer.GetClientChannelUid() == PVR_TIMER_ANY_CHANNEL)
// Fake a manual recording not a specific type in NextPVR
{
if (timer.GetEPGSearchString() == TYPE_7_TITLE)
{
// build recurring recording title keyword request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_EPG ANY CHANNEL - TYPE 7");
request = kodi::tools::StringUtils::Format("recording.recurring.save&type=7&recurring_id=%d&start_time=%d&end_time=%d&keep=%d&pre_padding=%d&post_padding=%d&day_mask=%s&directory_id=%s%s",
timer.GetClientIndex(),
Expand All @@ -735,10 +737,11 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
days.c_str(),
directory.c_str(),
enabled.c_str()
);
);
}
else
{
// build a manual keyword request not a specific type in NextPVR
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_EPG ANY CHANNEL");
std::string title = encodedName + "%";
request = kodi::tools::StringUtils::Format("recording.recurring.save&name=%s&channel_id=%d&start_time=%d&end_time=%d&keep=%d&pre_padding=%d&post_padding=%d&day_mask=%s&directory_id=%s&keyword=%s%s",
Expand All @@ -753,13 +756,13 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
directory.c_str(),
title.c_str(),
enabled.c_str()
);
);
}
}
else
{
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_EPG");
// build recurring recording request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_EPG");
request = kodi::tools::StringUtils::Format("recording.recurring.save&recurring_id=%d&channel_id=%d&event_id=%d&keep=%d&pre_padding=%d&post_padding=%d&day_mask=%s&directory_id=%s&only_new=%s%s",
timer.GetClientIndex(),
timer.GetClientChannelUid(),
Expand All @@ -771,13 +774,13 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
directory.c_str(),
preventDuplicates,
enabled.c_str()
);
);
}
break;

case TIMER_REPEATING_MANUAL:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_MANUAL");
// build manual recurring request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_MANUAL");
request = kodi::tools::StringUtils::Format("recording.recurring.save&recurring_id=%d&name=%s&channel_id=%d&start_time=%d&end_time=%d&keep=%d&pre_padding=%d&post_padding=%d&day_mask=%s&directory_id=%s%s",
timer.GetClientIndex(),
encodedName.c_str(),
Expand All @@ -790,12 +793,12 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
days.c_str(),
directory.c_str(),
enabled.c_str()
);
);
break;

case TIMER_REPEATING_KEYWORD:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_KEYWORD");
// build manual recurring request
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_KEYWORD");
request = kodi::tools::StringUtils::Format("recording.recurring.save&recurring_id=%d&name=%s&channel_id=%d&start_time=%d&end_time=%d&keep=%d&pre_padding=%d&post_padding=%d&directory_id=%s&keyword=%s&only_new=%s%s",
timer.GetClientIndex(),
encodedName.c_str(),
Expand All @@ -809,26 +812,29 @@ PVR_ERROR Timers::AddTimer(const kodi::addon::PVRTimer& timer)
encodedKeyword.c_str(),
preventDuplicates,
enabled.c_str()
);
);
break;

case TIMER_REPEATING_ADVANCED:
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_ADVANCED");
// build manual advanced recurring request
request = kodi::tools::StringUtils::Format("recording.recurring.save&recurring_type=advanced&recurring_id=%d&name=%s&channel_id=%d&start_time=%d&end_time=%d&keep=%d&pre_padding=%d&post_padding=%d&directory_id=%s&advanced=%s&only_new=%s%s",
kodi::Log(ADDON_LOG_DEBUG, "TIMER_REPEATING_ADVANCED");
std::string searchText;
if (timer.GetFullTextEpgSearch())
searchText = encodedKeyword;
else
searchText = UriEncode(kodi::tools::StringUtils::Format("title like \"%s\"", timer.GetEPGSearchString().c_str()));
request = kodi::tools::StringUtils::Format("recording.recurring.save&recurring_type=advanced&recurring_id=%d&name=%s&channel_id=%d&keep=%d&pre_padding=%d&post_padding=%d&directory_id=%s&advanced=%s&only_new=%s%s",
timer.GetClientIndex(),
encodedName.c_str(),
timer.GetClientChannelUid(),
static_cast<int>(timer.GetStartTime()),
static_cast<int>(timer.GetEndTime()),
timer.GetMaxRecordings(),
marginStart,
marginEnd,
directory.c_str(),
encodedKeyword.c_str(),
searchText.c_str(),
preventDuplicates,
enabled.c_str()
);
);
break;
}

Expand Down

0 comments on commit d40e722

Please sign in to comment.