Compile regex only once

This commit is contained in:
tomkat83 2016-09-25 19:21:12 +02:00
parent 219cdd9fba
commit 0b7e6ec0a3

View file

@ -57,7 +57,8 @@ import embydb_functions as embydb
log = logging.getLogger("PLEX."+__name__) log = logging.getLogger("PLEX."+__name__)
addonName = 'PlexKodiConnect' addonName = 'PlexKodiConnect'
REGEX_IMDB = re.compile(r'''/(tt\d+)''')
REGEX_TVDB = re.compile(r'''tvdb://(\d+)''')
############################################################################### ###############################################################################
@ -1450,10 +1451,10 @@ class API():
return None return None
if providername == 'imdb': if providername == 'imdb':
regex = re.compile(r'''/(tt\d+)''') regex = REGEX_IMDB
elif providername == 'tvdb': elif providername == 'tvdb':
# originally e.g. com.plexapp.agents.thetvdb://276564?lang=en # originally e.g. com.plexapp.agents.thetvdb://276564?lang=en
regex = re.compile(r'''tvdb://(\d+)''') regex = REGEX_TVDB
else: else:
return None return None