From 2cfeac1ce467a73e18378f2009a39ee4c6461ae7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 1 Nov 2015 22:43:42 +0000 Subject: Strip 'New:' from event titles --- p2pvr/daemon/unittests/testMaint.cpp | 14 ++++++++++++-- p2pvr/dvb/siParsers/event.cpp | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index 9926c2b..a794e5e 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -1,6 +1,7 @@ #define BOOST_TEST_MODULE Maintenance #include #include +#include #include #include #include @@ -133,7 +134,7 @@ BOOST_AUTO_TEST_CASE( GetNetworks ) BOOST_AUTO_TEST_CASE( GetDeliveryForService ) { - auto del = s->GetDeliveryForService(serviceId); + auto del = s->GetDeliveryForService(serviceId); BOOST_REQUIRE(del); BOOST_REQUIRE_EQUAL(del->ice_id(), "::DVBSI::TerrestrialDelivery"); BOOST_REQUIRE_EQUAL(del->Frequency, 682000000); @@ -141,7 +142,7 @@ BOOST_AUTO_TEST_CASE( GetDeliveryForService ) BOOST_AUTO_TEST_CASE( GetDeliveryForTransport ) { - auto del = s->GetDeliveryForTransport(transportId); + auto del = s->GetDeliveryForTransport(transportId); BOOST_REQUIRE(del); BOOST_REQUIRE_EQUAL(del->ice_id(), "::DVBSI::TerrestrialDelivery"); BOOST_REQUIRE_EQUAL(del->Frequency, 722000000); @@ -254,5 +255,14 @@ BOOST_AUTO_TEST_CASE( update_events ) BOOST_REQUIRE_EQUAL(keyEvents[1]->Title, keyEventsOnDayTwo[1]->Title); } +BOOST_AUTO_TEST_CASE( test_titleFiltering ) +{ + auto thingsWithNew = s->EventSearch("new", IceUtil::Optional(), + IceUtil::Optional(), IceUtil::Optional()); + BOOST_REQUIRE_EQUAL(0, std::count_if(thingsWithNew.begin(), thingsWithNew.end(), [](auto e) { + return boost::algorithm::starts_with(e->Title, "New:"); + })); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/p2pvr/dvb/siParsers/event.cpp b/p2pvr/dvb/siParsers/event.cpp index 4c3a572..11c15e2 100644 --- a/p2pvr/dvb/siParsers/event.cpp +++ b/p2pvr/dvb/siParsers/event.cpp @@ -91,6 +91,12 @@ SiEpgParser::parseDescriptor_ShortEvent(DVBSI::EventPtr current, const u_char * subtitle = convert((const char *)evtdesc->data + evtlen + 1, dsclen); } + if (title) { + if (boost::algorithm::starts_with(*title, "New:")) { + *title = boost::algorithm::trim_left_copy_if(title->substr(4), isspace); + } + } + if (subtitle) { Glib::MatchInfo matches; if (yearRegex->match(*subtitle, matches)) { -- cgit v1.2.3