From 7a0fae910fa1f47040e7fad12ed3ec4116c28fbf Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Fri, 11 Aug 2017 19:07:05 +0300 Subject: [PATCH] Strip bt sites tag from group name Related #15 Signed-off-by: Roi Dayan --- PTN/parse.py | 12 +++++++++++- PTN/patterns.py | 2 ++ tests/files/output.json | 9 ++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/PTN/parse.py b/PTN/parse.py index 40d6b0b..2ef67cd 100644 --- a/PTN/parse.py +++ b/PTN/parse.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import re -from .patterns import patterns, types +from .patterns import patterns, types, bt_sites class PTN(object): @@ -151,6 +151,16 @@ def parse(self, name): group = group[:-(len(container)+1)] self.parts['group'] = group + # clean group name from having bt site name + if 'group' in self.parts: + + group = self.parts['group'] + sites = '|'.join(bt_sites) + pat = '\[(' + sites + ')\]$' + group = re.sub(pat, '', group, flags=re.I) + if group: + self.parts['group'] = group + if len(clean) != 0: if len(clean) == 1: clean = clean[0] diff --git a/PTN/patterns.py b/PTN/patterns.py index 0f35801..5d5ae22 100644 --- a/PTN/patterns.py +++ b/PTN/patterns.py @@ -44,3 +44,5 @@ 'unrated': 'boolean', '3d': 'boolean' } + +bt_sites = ['eztv', 'ettv', 'rarbg', 'rartv', 'ETRG'] diff --git a/tests/files/output.json b/tests/files/output.json index 96ab497..f8af3ab 100644 --- a/tests/files/output.json +++ b/tests/files/output.json @@ -5,7 +5,8 @@ "resolution": "720p", "quality": "HDTV", "codec": "x264", - "title": "The Walking Dead" + "title": "The Walking Dead", + "group": "ASAP" }, { "year": 2014, @@ -50,7 +51,8 @@ "codec": "XViD", "extended": true, "excess": "", - "title": "Hercules" + "title": "Hercules", + "group": "juggs" }, { "year": 2014, @@ -119,7 +121,8 @@ "quality": "WEB-DL", "codec": "H.264", "audio": "DD5.1", - "title": "The Walking Dead" + "title": "The Walking Dead", + "group": "Cyphanix" }, { "year": 2012,