mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-11 22:08:02 -05:00
Improved XEM scene numbering converting.
Fixed release naming and parsing. Improved overall application performance and foorprint.
This commit is contained in:
parent
ce0f452183
commit
43b6b4b594
@ -211,16 +211,11 @@ class NameParser(object):
|
||||
|
||||
return result
|
||||
|
||||
def parse(self, name, fix_scene_numbering=False):
|
||||
def parse(self, name):
|
||||
name = self._unicodify(name)
|
||||
|
||||
cached = name_parser_cache.get(name)
|
||||
|
||||
if cached:
|
||||
if fix_scene_numbering:
|
||||
cached_fixed = copy.copy(cached)
|
||||
cached_fixed.fix_scene_numbering()
|
||||
return cached_fixed
|
||||
return cached
|
||||
|
||||
# break it into parts if there are any (dirname, file name, extension)
|
||||
@ -272,29 +267,8 @@ class NameParser(object):
|
||||
raise InvalidNameException("Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
|
||||
|
||||
name_parser_cache.add(name, final_result)
|
||||
|
||||
if fix_scene_numbering:
|
||||
result_fixed = copy.copy(final_result)
|
||||
result_fixed.fix_scene_numbering()
|
||||
return result_fixed
|
||||
|
||||
return final_result
|
||||
|
||||
@classmethod
|
||||
def series_name_to_indexer_id(cls, series_name):
|
||||
# do a scene reverse-lookup to get a list of all possible names
|
||||
name_list = sickbeard.show_name_helpers.sceneToNormalShowNames(series_name)
|
||||
|
||||
# for each possible interpretation of that scene name
|
||||
for cur_name in name_list:
|
||||
logger.log(u"Checking scene exceptions and database for a match on " + cur_name, logger.DEBUG)
|
||||
scene_id = sickbeard.scene_exceptions.get_scene_exception_by_name(cur_name)
|
||||
db_result = sickbeard.helpers.searchDBForShow(cur_name)
|
||||
if scene_id:
|
||||
return scene_id
|
||||
elif db_result:
|
||||
return db_result[1]
|
||||
|
||||
class ParseResult(object):
|
||||
def __init__(self,
|
||||
original_name,
|
||||
@ -384,45 +358,6 @@ class ParseResult(object):
|
||||
return False
|
||||
sports = property(_is_sports)
|
||||
|
||||
def fix_scene_numbering(self):
|
||||
"""
|
||||
The changes the parsed result (which is assumed to be scene numbering) to
|
||||
tvdb numbering, if necessary.
|
||||
"""
|
||||
if self.air_by_date or self.sports: return self # scene numbering does not apply to air-by-date
|
||||
if self.season_number == None: return self # can't work without a season
|
||||
if len(self.episode_numbers) == 0: return self # need at least one episode
|
||||
|
||||
indexer_id = NameParser.series_name_to_indexer_id(self.series_name)
|
||||
|
||||
new_episode_numbers = []
|
||||
new_season_numbers = []
|
||||
for epNo in self.episode_numbers:
|
||||
(s, e) = scene_numbering.get_indexer_numbering(indexer_id, self.season_number, epNo)
|
||||
new_episode_numbers.append(e)
|
||||
new_season_numbers.append(s)
|
||||
|
||||
# need to do a quick sanity check here. It's possible that we now have episodes
|
||||
# from more than one season (by tvdb numbering), and this is just too much
|
||||
# for sickbeard, so we'd need to flag it.
|
||||
new_season_numbers = list(set(new_season_numbers)) # remove duplicates
|
||||
if len(new_season_numbers) > 1:
|
||||
raise InvalidNameException("Scene numbering results episodes from "
|
||||
"seasons %s, (i.e. more than one) and "
|
||||
"sickbeard does not support this. "
|
||||
"Sorry." % (str(new_season_numbers)))
|
||||
|
||||
# I guess it's possible that we'd have duplicate episodes too, so lets
|
||||
# eliminate them
|
||||
new_episode_numbers = list(set(new_episode_numbers))
|
||||
new_episode_numbers.sort()
|
||||
|
||||
self.episode_numbers = new_episode_numbers
|
||||
self.season_number = new_season_numbers[0]
|
||||
|
||||
return self
|
||||
|
||||
|
||||
class NameParserCache(object):
|
||||
#TODO: check if the fifo list can beskiped and only use one dict
|
||||
_previous_parsed_list = [] # keep a fifo list of the cached items
|
||||
|
@ -114,7 +114,7 @@ def splitResult(result):
|
||||
# parse the season ep name
|
||||
try:
|
||||
np = NameParser(False)
|
||||
parse_result = np.parse(result.name, True)
|
||||
parse_result = np.parse(result.name)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + result.name + " into a valid episode", logger.WARNING)
|
||||
return False
|
||||
@ -133,7 +133,7 @@ def splitResult(result):
|
||||
# parse the name
|
||||
try:
|
||||
np = NameParser(False)
|
||||
parse_result = np.parse(newNZB, True)
|
||||
parse_result = np.parse(newNZB)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + newNZB + " into a valid episode", logger.WARNING)
|
||||
return False
|
||||
|
@ -256,9 +256,9 @@ class GenericProvider:
|
||||
|
||||
self._checkAuth()
|
||||
|
||||
regexMethod = 0
|
||||
regexMode = 0
|
||||
if show.sports:
|
||||
regexMethod = 1
|
||||
regexMode = 1
|
||||
|
||||
# update cache
|
||||
self.cache.updateCache()
|
||||
@ -299,7 +299,7 @@ class GenericProvider:
|
||||
|
||||
# parse the file name
|
||||
try:
|
||||
myParser = NameParser(False, regexMethod)
|
||||
myParser = NameParser(False, regexMode=regexMode, show=show)
|
||||
parse_result = myParser.parse(title)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
||||
|
@ -47,25 +47,11 @@ def filterBadReleases(name):
|
||||
|
||||
try:
|
||||
fp = NameParser()
|
||||
parse_result = fp.parse(name)
|
||||
fp.parse(name)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.WARNING)
|
||||
return False
|
||||
|
||||
## use the extra info and the scene group to filter against
|
||||
#check_string = ''
|
||||
#if parse_result.extra_info:
|
||||
# check_string = parse_result.extra_info
|
||||
#if parse_result.release_group:
|
||||
# if check_string:
|
||||
# check_string = check_string + '-' + parse_result.release_group
|
||||
# else:
|
||||
# check_string = parse_result.release_group
|
||||
#
|
||||
## if there's no info after the season info then assume it's fine
|
||||
#if not check_string:
|
||||
# return True
|
||||
|
||||
# if any of the bad strings are in the name then say no
|
||||
if sickbeard.IGNORE_WORDS:
|
||||
resultFilters.extend(sickbeard.IGNORE_WORDS.split(','))
|
||||
|
@ -908,6 +908,9 @@ class TVShow(object):
|
||||
logger.log(str(self.indexerid) + u": Obtained info from IMDb ->" + str(self.imdb_info), logger.DEBUG)
|
||||
|
||||
def nextEpisode(self):
|
||||
if 'ended' in str(self.status).lower():
|
||||
logger.log(str(self.indexerid) + u": Show Status: " + str(self.status) + ", skipping ...", logger.DEBUG)
|
||||
return []
|
||||
|
||||
logger.log(str(self.indexerid) + ": Finding the episode which airs next", logger.DEBUG)
|
||||
|
||||
|
@ -57,10 +57,10 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
||||
|
||||
# parse the file name
|
||||
pattern = u'%SN - %A-D - %EN'
|
||||
title = 'Show.Name.9th.Mar.2010.HDTV.XviD-RLSGROUP'
|
||||
title = 'Pawn.Stars.S08E56.HDTV.XviD-RLSGROUP'
|
||||
try:
|
||||
myParser = NameParser(False, 1)
|
||||
parse_result = myParser.parse(title, True)
|
||||
myParser = NameParser(False, -1)
|
||||
parse_result = myParser.parse(title)
|
||||
except InvalidNameException:
|
||||
print(u"Unable to parse the filename " + ep.name + " into a valid episode")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user