From 9b4ed031880251ec6b7b637d1924c343dd6484bc Mon Sep 17 00:00:00 2001 From: Michael O'Neill Date: Sat, 21 May 2016 00:05:15 -0400 Subject: [PATCH] Add pattern to better handle a year specifier after the series name (#23) - Add a pattern which should more accurately determine whether a four digit string after the name of the series is the year the series began or the season and episode number. This also prevents the actual season and episode number from being interpreted as the title of the episode. - Add test cases to exercise the new pattern. - Resolves #22. --- nielsen.py | 2 ++ test.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/nielsen.py b/nielsen.py index 1a06e8b..ff45ed5 100755 --- a/nielsen.py +++ b/nielsen.py @@ -57,6 +57,8 @@ def get_file_info(filename): """ patterns = [ + # The.Flash.2014.217.Flash.Back.HDTV.x264-LOL[ettv].mp4 + re.compile(r"(?P.+)\.+(?P\d{4})\.(?P\d{1,2})(?P\d{2})\.*(?P.*)?\.+(?P<extension>\w+)$", re.IGNORECASE), # The.Glades.S02E01.Family.Matters.HDTV.XviD-FQM.avi re.compile(r"(?P<series>.+)\.+S?(?P<season>\d{2})\.?E?(?P<episode>\d{2})\.*(?P<title>.*)?\.+(?P<extension>\w+)$", re.IGNORECASE), # the.glades.201.family.matters.hdtv.xvid-fqm.avi diff --git a/test.py b/test.py index 8554b21..320b900 100755 --- a/test.py +++ b/test.py @@ -119,19 +119,27 @@ def test_get_file_info(self): "extension": "mp4" }, - "the.flash.(2014).217.hdtv-lol[ettv].mp4": { + "the.flash.(2014).217.flash.back.hdtv-lol[ettv].mp4": { "series": "The Flash", "season": "02", "episode": "17", - "title": "", + "title": "Flash Back", "extension": "mp4" }, - "The.Flash.2014.S02E17.HDTV.x264-LOL[ettv].mp4": { + "The.Flash.2014.S02E17.Flash.Back.HDTV.x264-LOL[ettv].mp4": { "series": "The Flash", "season": "02", "episode": "17", - "title": "", + "title": "Flash Back", + "extension": "mp4" + }, + + "The.Flash.2014.217.Flash.Back.HDTV.x264-LOL[ettv].mp4": { + "series": "The Flash", + "season": "02", + "episode": "17", + "title": "Flash Back", "extension": "mp4" },