diff options
Diffstat (limited to 'p2pvr/lib')
| -rw-r--r-- | p2pvr/lib/dvbsiHelpers/event.cpp | 2 | ||||
| -rw-r--r-- | p2pvr/lib/siParsers/event.cpp | 25 |
2 files changed, 19 insertions, 8 deletions
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) { |
