Skip to content

Commit

Permalink
Strip bt sites tag from group name
Browse files Browse the repository at this point in the history
Related divijbindlish#15
Signed-off-by: Roi Dayan <[email protected]>
  • Loading branch information
roidayan committed Aug 13, 2017
1 parent 6e0032e commit 7a0fae9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 11 additions & 1 deletion PTN/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

import re
from .patterns import patterns, types
from .patterns import patterns, types, bt_sites


class PTN(object):
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions PTN/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@
'unrated': 'boolean',
'3d': 'boolean'
}

bt_sites = ['eztv', 'ettv', 'rarbg', 'rartv', 'ETRG']
9 changes: 6 additions & 3 deletions tests/files/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"resolution": "720p",
"quality": "HDTV",
"codec": "x264",
"title": "The Walking Dead"
"title": "The Walking Dead",
"group": "ASAP"
},
{
"year": 2014,
Expand Down Expand Up @@ -50,7 +51,8 @@
"codec": "XViD",
"extended": true,
"excess": "",
"title": "Hercules"
"title": "Hercules",
"group": "juggs"
},
{
"year": 2014,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7a0fae9

Please sign in to comment.