summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/datasources/schema.sql32
-rw-r--r--p2pvr/ice/p2pvr.ice1
-rw-r--r--p2pvr/lib/dvbsiHelpers/event.cpp2
-rw-r--r--p2pvr/lib/siParsers/event.cpp25
4 files changed, 51 insertions, 9 deletions
diff --git a/p2pvr/datasources/schema.sql b/p2pvr/datasources/schema.sql
index c51eb06..acd78ae 100644
--- a/p2pvr/datasources/schema.sql
+++ b/p2pvr/datasources/schema.sql
@@ -128,13 +128,29 @@ CREATE TABLE events (
episode smallint,
episodes smallint,
year smallint,
- flags text
+ flags text,
+ season integer
);
ALTER TABLE public.events OWNER TO gentoo;
--
+-- Name: event_tsvector(events); Type: FUNCTION; Schema: public; Owner: gentoo
+--
+
+CREATE FUNCTION event_tsvector(e events) RETURNS tsvector
+ LANGUAGE sql STABLE LEAKPROOF
+ AS $$
+select (setweight(to_tsvector('english', e.title), 'A') ||
+ setweight(to_tsvector('english', e.subtitle), 'B') ||
+ setweight(to_tsvector('english', e.description), 'C'));
+$$;
+
+
+ALTER FUNCTION public.event_tsvector(e events) OWNER TO gentoo;
+
+--
-- Name: networks; Type: TABLE; Schema: public; Owner: gentoo; Tablespace:
--
@@ -317,6 +333,20 @@ ALTER TABLE ONLY transportstreams
--
+-- Name: idx_event_search; Type: INDEX; Schema: public; Owner: gentoo; Tablespace:
+--
+
+CREATE INDEX idx_event_search ON events USING gin ((((setweight(to_tsvector('english'::regconfig, title), 'A'::"char") || setweight(to_tsvector('english'::regconfig, subtitle), 'B'::"char")) || setweight(to_tsvector('english'::regconfig, description), 'C'::"char"))));
+
+
+--
+-- Name: idx_event_title; Type: INDEX; Schema: public; Owner: gentoo; Tablespace:
+--
+
+CREATE INDEX idx_event_title ON events USING btree (lower(title));
+
+
+--
-- Name: fk_delivery_dvbc_transportstream; Type: FK CONSTRAINT; Schema: public; Owner: gentoo
--
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice
index 1db9cf3..0b0b596 100644
--- a/p2pvr/ice/p2pvr.ice
+++ b/p2pvr/ice/p2pvr.ice
@@ -155,6 +155,7 @@ module DVBSI {
optional(15) short Category;
optional(16) short SubCategory;
optional(17) short UserCategory;
+ optional(18) short Season;
};
};
module P2PVR {
diff --git a/p2pvr/lib/dvbsiHelpers/event.cpp b/p2pvr/lib/dvbsiHelpers/event.cpp
index d5ea1d4..800a511 100644
--- a/p2pvr/lib/dvbsiHelpers/event.cpp
+++ b/p2pvr/lib/dvbsiHelpers/event.cpp
@@ -28,6 +28,7 @@ CreateColumns<DVBSI::EventPtr>(const ColumnCreator & cc)
cc("episodes", false);
cc("year", false);
cc("flags", false);
+ cc("season", false);
}
template<>
@@ -57,5 +58,6 @@ BindColumns(RowState & rs, const DVBSI::EventPtr & e)
rs.fields[20] << e->Episodes;
rs.fields[21] << e->Year;
rs.fields[22] << e->Flags;
+ rs.fields[23] << e->Season;
}
diff --git a/p2pvr/lib/siParsers/event.cpp b/p2pvr/lib/siParsers/event.cpp
index dbb9f90..ada36ce 100644
--- a/p2pvr/lib/siParsers/event.cpp
+++ b/p2pvr/lib/siParsers/event.cpp
@@ -68,8 +68,9 @@ struct EventDescriptor {
u_char data[];
} __attribute__((packed));
-static Glib::RefPtr<Glib::Regex> episodeRegex = Glib::Regex::create("(?:[ (]+|^)(?:\\w+ )?([0-9]+)(?: of |/)([0-9]+)[.)]+");
-static Glib::RefPtr<Glib::Regex> yearRegex = Glib::Regex::create("\\(([0-9]{4})[ )]+");
+static Glib::RefPtr<Glib::Regex> episodeRegex = Glib::Regex::create("(?:[ (]+|^)(?:\\w+ )?([0-9]+)(?: of |/)([0-9]+)(?:[.)]+|$)");
+static Glib::RefPtr<Glib::Regex> seasonEpisodeRegex = Glib::Regex::create("[ ([]*[Ss]\\s*([0-9]+)[ ,]*[Ee][Pp]?\\s*([0-9]+)[).\\]]*");
+static Glib::RefPtr<Glib::Regex> yearRegex = Glib::Regex::create("[[(]([0-9]{4})[ ).\\]]+");
static Glib::RefPtr<Glib::Regex> flagsRegex = Glib::Regex::create("[ []+([A-Z,]+)\\]");
void
@@ -92,18 +93,26 @@ SiEpgParser::parseDescriptor_ShortEvent(DVBSI::EventPtr current, const u_char *
if (subtitle) {
Glib::MatchInfo matches;
- if (episodeRegex->match(*subtitle, matches)) {
- current->Episode = boost::lexical_cast<int>(matches.fetch(1));
- current->Episodes = boost::lexical_cast<int>(matches.fetch(2));
- *subtitle = episodeRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
- }
if (yearRegex->match(*subtitle, matches)) {
current->Year = boost::lexical_cast<int>(matches.fetch(1));
*subtitle = yearRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
}
if (flagsRegex->match(*subtitle, matches)) {
current->Flags = matches.fetch(1);
- *subtitle = yearRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
+ *subtitle = flagsRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
+ }
+ if (episodeRegex->match(*subtitle, matches)) {
+ current->Episode = boost::lexical_cast<int>(matches.fetch(1));
+ current->Episodes = boost::lexical_cast<int>(matches.fetch(2));
+ if (*current->Episode <= *current->Episodes) { // fudge to catch "24/7"
+ Logger()->message(LOG_DEBUG, (*subtitle).c_str());
+ *subtitle = episodeRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
+ }
+ }
+ if (seasonEpisodeRegex->match(*subtitle, matches)) {
+ current->Season = boost::lexical_cast<int>(matches.fetch(1));
+ current->Episode = boost::lexical_cast<int>(matches.fetch(2));
+ *subtitle = seasonEpisodeRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
}
}
if (title && subtitle) {