Compile regex only once

This commit is contained in:
croneter 2017-09-06 19:55:27 +02:00
parent fc03ebc8d4
commit 5fcccba105

View file

@ -15,7 +15,7 @@ from variables import PLEX_TO_KODI_TIMEFACTOR
log = getLogger("PLEX."+__name__)
CONTAINERSIZE = int(settings('limitindex'))
REGEX_PLEX_KEY = re.compile(r'''/(.+)/(\d+)$''')
###############################################################################
@ -36,9 +36,8 @@ def GetPlexKeyNumber(plexKey):
Returns ('','') if nothing is found
"""
regex = re.compile(r'''/(.+)/(\d+)$''')
try:
result = regex.findall(plexKey)[0]
result = REGEX_PLEX_KEY.findall(plexKey)[0]
except IndexError:
result = ('', '')
return result