"BABS-OP-ED-support" by jotaro0010

https://forums.plex.tv/index.php/topic/31081-better-absolute-scanner-babs/?p=617540 Posted 01 April 2014 - 11:58 PM

I had several problems with the scanner. the first being the scanner counted the opening and endings for a show as an episode rather than ignore them. so a file named "Anime - OP01.mkv" would be mistaken as episode one for show anime. I modified the regex so it would not match the episode if "OP", or "ED" was directly behind the number.
 
Lines 43-50 of BABS.py
just_episode_regexs = [
    '(?P<ep>[0-9]{1,3})[\. -_]of[\. -_]+[0-9]{1,3}',       # 01 of 08
    '^(?P<ep>[0-9]{1,3})[^0-9]',                           # 01 - Foo
    '(^|[ \.\-_])e(p{0,1}|(pisode){0,1})[ \.\-_]*(?P<ep>[0-9]{2,3})([^0-9c-uw-z%]|$)', # Blah Blah ep234
    '.*?[ \.\-_](?P<ep>[0-9]{2,3})[^0-9c-uw-z%]+',         # Flah - 04 - Blah
    '.*?[ \.\-_](?P<ep>[0-9]{2,3})$',                      # Flah - 04
-    '.*?[^0-9x](?P<ep>[0-9]{2,3})$' # Flah707 
+    '.*?[^0-9x](?<!OP)(?<!ED)(?P<ep>\d{2,3})' # Flah707 as long as it isn't precede by op, ed
  ]
 
The second problem I had was for the show "3x3 Eyes" all episodes where mistaken as being part of season 3 episode 3. Below this is the part I edited to make it so it doesn't try to find the episode number in the name of the show.
Lines 281-287 of BABS.py
          print "BABS: after whackRx, file = |", file, "|"
 
+          #BABS: Before matching for episdodes replace the show name with an X to prevent the regex from matching the show name
+          #important for 3x3 Eyes since 3x3 generally means season 3 episode 3
+          file = re.sub(show, 'X', file)
          
          for rx in episode_regexps: