]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
opentv: hack to include episode/series number processing from description.
authorDave Chapman <dave@dchapman.com>
Fri, 8 Mar 2013 21:42:30 +0000 (21:42 +0000)
committerDave Chapman <dave@dchapman.com>
Fri, 8 Mar 2013 22:29:52 +0000 (22:29 +0000)
src/epggrab/module/opentv.c

index e1fd6ee3f5d930774e53cc3663140d64736b525b..0d245d3ad2197bd13cf70213a72df8b87de4b155 100644 (file)
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <assert.h>
 #include <unistd.h>
+#include <regex.h>
 #include <linux/dvb/dmx.h>
 #include "tvheadend.h"
 #include "dvb/dvb.h"
@@ -397,6 +398,25 @@ static int _opentv_parse_event_section
         save |= epg_episode_set_genre(ee, egl, src);
         epg_genre_list_destroy(egl);
       }
+      if (ev.summary) {
+        regex_t preg;
+        regmatch_t match[3];
+
+        /* Parse Series/Episode
+         * TODO: HACK: this needs doing properly */
+        regcomp(&preg, " *\\(S ?([0-9]+),? Ep? ?([0-9]+)\\)$",
+                REG_ICASE | REG_EXTENDED);
+        if (!regexec(&preg, ev.summary, 3, match, 0)) {
+          epg_episode_num_t en;
+          memset(&en, 0, sizeof(en));
+          if (match[1].rm_so != -1)
+            en.s_num = atoi(ev.summary + match[1].rm_so);
+          if (match[2].rm_so != -1)
+            en.e_num = atoi(ev.summary + match[2].rm_so);
+          save |= epg_episode_set_epnum(ee, &en, src);
+        }
+        regfree(&preg);
+      }
     }
 
     /* Cleanup */