From d40e7223a52c4180733f400d5e92350f679b8199 Mon Sep 17 00:00:00 2001 From: emveepee Date: Sun, 27 Nov 2022 14:18:40 -0500 Subject: [PATCH] Advanced recording title search (#221) Backport of PR 220 Co-authored-by: emveepee --- pvr.nextpvr/addon.xml.in | 2 +- pvr.nextpvr/changelog.txt | 3 +++ src/Timers.cpp | 48 ++++++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/pvr.nextpvr/addon.xml.in b/pvr.nextpvr/addon.xml.in index 1933028d..b588ed46 100644 --- a/pvr.nextpvr/addon.xml.in +++ b/pvr.nextpvr/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.nextpvr/changelog.txt b/pvr.nextpvr/changelog.txt index 1f4eb380..bc659a26 100644 --- a/pvr.nextpvr/changelog.txt +++ b/pvr.nextpvr/changelog.txt @@ -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 diff --git a/src/Timers.cpp b/src/Timers.cpp index 462e4304..33dc3be0 100644 --- a/src/Timers.cpp +++ b/src/Timers.cpp @@ -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(), @@ -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"); @@ -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(), @@ -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", @@ -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(), @@ -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(), @@ -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(), @@ -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(timer.GetStartTime()), - static_cast(timer.GetEndTime()), timer.GetMaxRecordings(), marginStart, marginEnd, directory.c_str(), - encodedKeyword.c_str(), + searchText.c_str(), preventDuplicates, enabled.c_str() - ); + ); break; }