From 3de5edfd3774d202dc00cccbc8b9c34a428479d0 Mon Sep 17 00:00:00 2001 From: Dave Chevell Date: Sun, 17 May 2020 11:16:51 +1000 Subject: [PATCH] Support titles with year in name --- PTN/parse.py | 3 +++ tests/files/input.json | 4 +++- tests/files/output.json | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/PTN/parse.py b/PTN/parse.py index 884ff87..2aed07e 100644 --- a/PTN/parse.py +++ b/PTN/parse.py @@ -58,6 +58,9 @@ def parse(self, name): if key not in ('season', 'episode', 'website', 'year'): pattern = r'\b%s\b' % pattern + if key == 'year': + pattern = r'.%s' % pattern + clean_name = re.sub('_', ' ', self.torrent['name']) match = re.findall(pattern, clean_name, re.I) if len(match) == 0: diff --git a/tests/files/input.json b/tests/files/input.json index fb9b30f..83c90d5 100644 --- a/tests/files/input.json +++ b/tests/files/input.json @@ -76,5 +76,7 @@ "Ben Hur 2016 TELESYNC x264 AC3 MAXPRO", "The.Secret.Life.of.Pets.2016.HDRiP.AAC-LC.x264-LEGi0N", "Onward (2020) [1080p] [WEBRip] [5.1] [YTS.MX]", - "2001: A Space Odyssey (1968) [BluRay] [1080p] [YTS.AM]" + "2001: A Space Odyssey (1968) [BluRay] [1080p] [YTS.AM]", + "2012.2009.BluRay.1080p.x264.YIFY.mp4", + "Death Race 2000 (1975) [1080p] [BluRay] [YTS.MX]" ] diff --git a/tests/files/output.json b/tests/files/output.json index 1b6b841..59f9bfc 100644 --- a/tests/files/output.json +++ b/tests/files/output.json @@ -519,5 +519,13 @@ { "year": 1968, "title": "2001: A Space Odyssey" + }, + { + "year": 2009, + "title": "2012" + }, + { + "year": 1975, + "title": "Death Race 2000" } ]