Merge pull request #574 from adam111316/feature/FixQualityTrimming

Fix removal of non-release groups such that anime qualities are not t…
This commit is contained in:
adam111316 2015-11-28 21:24:05 +08:00
commit e01303242f
5 changed files with 30 additions and 18 deletions

View file

@ -85,6 +85,7 @@
* Enable Alpha Ratio again now that the secure login page over https is fixed * Enable Alpha Ratio again now that the secure login page over https is fixed
* Add ability to parse command line output from unix unrar version 4 and below * Add ability to parse command line output from unix unrar version 4 and below
* Fix show search box on non-poster show list views * Fix show search box on non-poster show list views
* Fix removal of non-release groups such that anime qualities are not trimmed from name
### 0.10.0 (2015-08-06 11:05:00 UTC) ### 0.10.0 (2015-08-06 11:05:00 UTC)

View file

@ -94,18 +94,18 @@ def remove_extension(name):
return name return name
def remove_non_release_groups(name): def remove_non_release_groups(name, anime=False):
""" """
Remove non release groups from name Remove non release groups from name
""" """
if name: if name:
rc = [re.compile(r'(?i)' + v) for v in rc = [re.compile(r'(?i)' + v) for v in [
'([\s\.\-_\[\{\(]*(no-rar|nzbgeek|ripsalot|rp|siklopentan)[\s\.\-_\]\}\)]*)$', '([\s\.\-_\[\{\(]*(no-rar|nzbgeek|ripsalot|rp|siklopentan)[\s\.\-_\]\}\)]*)$',
'(?<=\w)([\s\.\-_]*[\[\{\(][\s\.\-_]*(www\.\w+.\w+)[\s\.\-_]*[\]\}\)][\s\.\-_]*)$', '(?<=\w)([\s\.\-_]*[\[\{\(][\s\.\-_]*(www\.\w+.\w+)[\s\.\-_]*[\]\}\)][\s\.\-_]*)$',
'(?<=\w)([\s\.\-_]*[\[\{\(]\s*(rar(bg|tv)|((e[tz]|v)tv))[\s\.\-_]*[\]\}\)][\s\.\-_]*)$', '(?<=\w)([\s\.\-_]*[\[\{\(]\s*(rar(bg|tv)|((e[tz]|v)tv))[\s\.\-_]*[\]\}\)][\s\.\-_]*)$'] +
'(?<=\w)([\s\.\-_]*[\[\{\(][\s\.\-_]*[\w\s\.\-\_]+[\s\.\-_]*[\]\}\)][\s\.\-_]*)$' (['(?<=\w)([\s\.\-_]*[\[\{\(][\s\.\-_]*[\w\s\.\-\_]+[\s\.\-_]*[\]\}\)][\s\.\-_]*)$'], [])[anime]
] ]
rename = name rename = name
while rename: while rename:
for regex in rc: for regex in rc:

View file

@ -222,8 +222,15 @@ def _downloadPropers(properList):
else: else:
# get the show object
showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
if showObj == None:
logger.log(u'Unable to find the show with indexerid ' + str(
curProper.indexerid) + ' so unable to download the proper', logger.ERROR)
continue
# make sure that none of the existing history downloads are the same proper we're trying to download # make sure that none of the existing history downloads are the same proper we're trying to download
clean_proper_name = _genericName(helpers.remove_non_release_groups(curProper.name)) clean_proper_name = _genericName(helpers.remove_non_release_groups(curProper.name, showObj.anime))
isSame = False isSame = False
for curResult in historyResults: for curResult in historyResults:
# if the result exists in history already we need to skip it # if the result exists in history already we need to skip it
@ -234,12 +241,8 @@ def _downloadPropers(properList):
logger.log(u'This proper is already in history, skipping it', logger.DEBUG) logger.log(u'This proper is already in history, skipping it', logger.DEBUG)
continue continue
# get the episode object
showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
if showObj == None:
logger.log(u'Unable to find the show with indexerid ' + str(
curProper.indexerid) + ' so unable to download the proper', logger.ERROR)
continue
epObj = showObj.getEpisode(curProper.season, curProper.episode) epObj = showObj.getEpisode(curProper.season, curProper.episode)
# make the result object # make the result object

View file

@ -2156,14 +2156,14 @@ class TVEpisode(object):
def us(name): def us(name):
return re.sub('[ -]', '_', name) return re.sub('[ -]', '_', name)
def release_name(name): def release_name(show, name):
if name: if name:
name = helpers.remove_non_release_groups(helpers.remove_extension(name)) name = helpers.remove_non_release_groups(helpers.remove_extension(name), show.anime)
return name return name
def release_group(show, name): def release_group(show, name):
if name: if name:
name = helpers.remove_non_release_groups(helpers.remove_extension(name)) name = helpers.remove_non_release_groups(helpers.remove_extension(name), show.anime)
else: else:
return "" return ""
@ -2205,7 +2205,7 @@ class TVEpisode(object):
'%0XE': '%02d' % self.scene_episode, '%0XE': '%02d' % self.scene_episode,
'%AB': '%(#)03d' % {'#': self.absolute_number}, '%AB': '%(#)03d' % {'#': self.absolute_number},
'%XAB': '%(#)03d' % {'#': self.scene_absolute_number}, '%XAB': '%(#)03d' % {'#': self.scene_absolute_number},
'%RN': release_name(self.release_name), '%RN': release_name(self.show, self.release_name),
'%RG': release_group(self.show, self.release_name), '%RG': release_group(self.show, self.release_name),
'%AD': str(self.airdate).replace('-', ' '), '%AD': str(self.airdate).replace('-', ' '),
'%A.D': str(self.airdate).replace('-', '.'), '%A.D': str(self.airdate).replace('-', '.'),

View file

@ -29,6 +29,14 @@ class HelpersTests(unittest.TestCase):
self.assertEqual(helpers.sizeof_fmt(2 ** 20), '1.0 MB') self.assertEqual(helpers.sizeof_fmt(2 ** 20), '1.0 MB')
self.assertEqual(helpers.sizeof_fmt(1234567), '1.2 MB') self.assertEqual(helpers.sizeof_fmt(1234567), '1.2 MB')
def test_remove_non_release_groups(self):
test_names = {
('[HorribleSubs] Hidan no Aria AA - 08 [1080p]', True): '[HorribleSubs] Hidan no Aria AA - 08 [1080p]',
('The.Last.Man.On.Earth.S02E08.No.Bull.1080p.WEB-DL.DD5.1.H264-BTN[rartv]', False): 'The.Last.Man.On.Earth.S02E08.No.Bull.1080p.WEB-DL.DD5.1.H264-BTN',
}
for test_name, test_result in test_names.items():
self.assertEqual(test_result, helpers.remove_non_release_groups(test_name[0], test_name[1]))
if __name__ == '__main__': if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(HelpersTests) suite = unittest.TestLoader().loadTestsFromTestCase(HelpersTests)