mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 01:43:37 +00:00
Fixed invalid naming pattern error.
Fixed sports regexes. Fixed name parsing issues.
This commit is contained in:
parent
5fb3fe6797
commit
7cbeef5ed0
5 changed files with 34 additions and 38 deletions
|
@ -3,7 +3,6 @@
|
|||
#from sickbeard import common
|
||||
#from sickbeard import exceptions
|
||||
#from sickbeard import scene_exceptions
|
||||
#from sickbeard.blackandwhitelist import *
|
||||
#set global $title="Edit " + $show.name
|
||||
#set global $header=$show.name
|
||||
|
||||
|
@ -146,8 +145,10 @@ Separate words with a comma, e.g. "word1,word2,word3"
|
|||
<br /><br />
|
||||
|
||||
#if $show.is_anime
|
||||
#from sickbeard.blackandwhitelist import *
|
||||
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_blackwhitelist.tmpl")
|
||||
#end if
|
||||
|
||||
<input type="hidden" name="whitelist" id="whitelist"/>
|
||||
<input type="hidden" name="blacklist" id="blacklist"/>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class NameParser(object):
|
|||
self.naming_pattern = naming_pattern
|
||||
|
||||
self.regexModes = [self.NORMAL_REGEX, self.SPORTS_REGEX, self.ANIME_REGEX]
|
||||
if self.showObj and not (self.showObj.is_anime and self.showObj.is_sports):
|
||||
if self.showObj and not (self.showObj.is_anime or self.showObj.is_sports):
|
||||
self.regexModes = [self.NORMAL_REGEX]
|
||||
elif self.showObj and self.showObj.is_anime:
|
||||
self.regexModes = [self.ANIME_REGEX]
|
||||
|
@ -82,7 +82,6 @@ class NameParser(object):
|
|||
if regexMode == self.SPORTS_REGEX:
|
||||
logger.log(u"Using SPORTS regexs", logger.DEBUG)
|
||||
uncompiled_regex = [regexes.sports_regexs]
|
||||
|
||||
elif regexMode == self.ANIME_REGEX:
|
||||
logger.log(u"Using ANIME regexs", logger.DEBUG)
|
||||
uncompiled_regex = [regexes.anime_regexes]
|
||||
|
@ -135,14 +134,17 @@ class NameParser(object):
|
|||
if result.series_name:
|
||||
result.series_name = self.clean_series_name(result.series_name)
|
||||
|
||||
if not self.naming_pattern:
|
||||
if self.showObj and self.showObj.name.lower() == result.series_name.lower():
|
||||
result.show = self.showObj
|
||||
else:
|
||||
if self.showObj and self.showObj.name.lower() == result.series_name.lower():
|
||||
result.show = self.showObj
|
||||
else:
|
||||
if not self.naming_pattern:
|
||||
result.show = helpers.get_show_by_name(result.series_name, useIndexer=self.useIndexers)
|
||||
|
||||
if not result.show:
|
||||
if not result.show:
|
||||
if len(self.regexModes) > 1:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
||||
result.score += 1
|
||||
|
||||
|
@ -185,7 +187,7 @@ class NameParser(object):
|
|||
|
||||
if 'sports_air_date' in named_groups:
|
||||
sports_air_date = match.group('sports_air_date')
|
||||
if sports_air_date:
|
||||
if result.show and result.show.is_sports:
|
||||
try:
|
||||
result.sports_air_date = parser.parse(sports_air_date, fuzzy=True).date()
|
||||
result.score += 1
|
||||
|
@ -193,16 +195,17 @@ class NameParser(object):
|
|||
pass
|
||||
|
||||
if 'air_year' in named_groups and 'air_month' in named_groups and 'air_day' in named_groups:
|
||||
year = int(match.group('air_year'))
|
||||
month = int(match.group('air_month'))
|
||||
day = int(match.group('air_day'))
|
||||
if result.show and result.show.air_by_date:
|
||||
year = int(match.group('air_year'))
|
||||
month = int(match.group('air_month'))
|
||||
day = int(match.group('air_day'))
|
||||
|
||||
try:
|
||||
dtStr = '%s-%s-%s' % (year, month, day)
|
||||
result.air_date = datetime.datetime.strptime(dtStr, "%Y-%m-%d").date()
|
||||
result.score += 1
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
dtStr = '%s-%s-%s' % (year, month, day)
|
||||
result.air_date = datetime.datetime.strptime(dtStr, "%Y-%m-%d").date()
|
||||
result.score += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
if 'extra_info' in named_groups:
|
||||
tmp_extra_info = match.group('extra_info')
|
||||
|
|
|
@ -192,11 +192,8 @@ sports_regexs = [
|
|||
# Sports.Name.23rd.Nov.2010.Source.Quality.Etc-Group
|
||||
'''
|
||||
^(?P<series_name>(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP))[. _-]+
|
||||
((?P<sports_event_id>\d{3})[. _-]+)?
|
||||
((?P<sports_event_name>\.+)[. _-]+)?
|
||||
(?P<sports_air_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4}))
|
||||
[. _-]*((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
|
||||
-(?P<release_group>[^- ]+))?)?$
|
||||
(?P<sports_air_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4})|(\w+[. _-]+\d{1,2}\w{2}[. _-]+\d{4}))[. _-]+
|
||||
((?P<extra_info>.+?)((?<![. _-])(?<!WEB)-(?P<release_group>[^- ]+))?)?$
|
||||
'''
|
||||
),
|
||||
|
||||
|
@ -204,11 +201,9 @@ sports_regexs = [
|
|||
# Sports.Name.2010.11.23.Source.Quality.Etc-Group
|
||||
# Sports.Name.23rd.Nov.2010.Source.Quality.Etc-Group
|
||||
'''
|
||||
^(?P<series_name>.+?)[. _-]+
|
||||
((?P<sports_event_id>\d{3})[. _-]+)?
|
||||
((?P<sports_event_name>\.+)[. _-]+)?
|
||||
(?P<sports_air_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4}))
|
||||
[. _-]*((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
|
||||
^(?P<series_name>.+?)\W+
|
||||
(?P<sports_air_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4})|(\w+[. _-]+\d{1,2}\w{2}[. _-]+\d{4}))[. _-]+
|
||||
((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
|
||||
-(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$
|
||||
'''
|
||||
),
|
||||
|
|
|
@ -225,7 +225,7 @@ def generate_sample_ep(multi=None, abd=False, sports=False, anime_type=None):
|
|||
ep._release_name = 'Show.Name.2011.03.09.HDTV.XviD-RLSGROUP'
|
||||
ep.show.air_by_date = 1
|
||||
elif sports:
|
||||
ep._release_name = 'Show.Name.100.Fighter.vs.Fighter.HDTV.XviD-RLSGROUP'
|
||||
ep._release_name = 'Show.Name.100.Fighter.vs.Fighter.2011.03.09.HDTV.XviD-RLSGROUP'
|
||||
ep.show.sports = 1
|
||||
else:
|
||||
if anime_type != 3:
|
||||
|
|
|
@ -2073,12 +2073,12 @@ class TVEpisode(object):
|
|||
name = name.rpartition('.')[0]
|
||||
return name
|
||||
|
||||
def release_group(name):
|
||||
def release_group(show, name):
|
||||
if not name:
|
||||
return ''
|
||||
|
||||
try:
|
||||
np = NameParser(name, naming_pattern=True)
|
||||
np = NameParser(name, showObj=show, naming_pattern=True)
|
||||
parse_result = np.parse(name)
|
||||
except (InvalidNameException, InvalidShowException), e:
|
||||
logger.log(u"Unable to get parse release_group: " + ex(e), logger.DEBUG)
|
||||
|
@ -2116,7 +2116,7 @@ class TVEpisode(object):
|
|||
'%AB': '%(#)03d' % {'#': self.absolute_number},
|
||||
'%XAB': '%(#)03d' % {'#': self.scene_absolute_number},
|
||||
'%RN': release_name(self.release_name),
|
||||
'%RG': release_group(self.release_name),
|
||||
'%RG': release_group(self.show, self.release_name),
|
||||
'%AD': str(self.airdate).replace('-', ' '),
|
||||
'%A.D': str(self.airdate).replace('-', '.'),
|
||||
'%A_D': us(str(self.airdate)),
|
||||
|
@ -2156,10 +2156,7 @@ class TVEpisode(object):
|
|||
multi = sickbeard.NAMING_MULTI_EP
|
||||
|
||||
if anime_type == None:
|
||||
if not self.show.is_anime:
|
||||
anime_type = 3
|
||||
else:
|
||||
anime_type = sickbeard.NAMING_ANIME
|
||||
anime_type = sickbeard.NAMING_ANIME
|
||||
|
||||
replace_map = self._replace_map()
|
||||
|
||||
|
@ -2170,7 +2167,7 @@ class TVEpisode(object):
|
|||
if self.show.air_by_date or self.show.sports:
|
||||
result_name = result_name.replace('%RN', '%S.N.%A.D.%E.N-SiCKRAGE')
|
||||
result_name = result_name.replace('%rn', '%s.n.%A.D.%e.n-sickrage')
|
||||
elif self.show.anime:
|
||||
elif anime_type != 3:
|
||||
result_name = result_name.replace('%RN', '%S.N.%AB.%E.N-SiCKRAGE')
|
||||
result_name = result_name.replace('%rn', '%s.n.%ab.%e.n-sickrage')
|
||||
else:
|
||||
|
@ -2261,7 +2258,7 @@ class TVEpisode(object):
|
|||
|
||||
ep_string += other_ep._format_string(ep_format.upper(), other_ep._replace_map())
|
||||
|
||||
if self.show.anime and anime_type != 3:
|
||||
if anime_type != 3:
|
||||
if self.absolute_number == 0:
|
||||
curAbsolute_number = self.episode
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue