Skip to content

Commit

Permalink
Add pattern to better handle a year specifier after the series name (#23
Browse files Browse the repository at this point in the history
)

- 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.
  • Loading branch information
IrishPrime committed May 21, 2016
1 parent 4fb3617 commit 9b4ed03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions nielsen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<series>.+)\.+(?P<year>\d{4})\.(?P<season>\d{1,2})(?P<episode>\d{2})\.*(?P<title>.*)?\.+(?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
Expand Down
16 changes: 12 additions & 4 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},

Expand Down

0 comments on commit 9b4ed03

Please sign in to comment.