Plex Companion: Compile regex only once

This commit is contained in:
tomkat83 2016-07-19 18:23:52 +02:00
parent dec4b077d5
commit 1f9ac4f133

View file

@ -17,6 +17,7 @@ class MyHandler(BaseHTTPRequestHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
BaseHTTPRequestHandler.__init__(self, *args, **kwargs) BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
self.serverlist = [] self.serverlist = []
self.regex = re.compile(r'''/playQueues/(\d+)$''')
def getServerByHost(self, host): def getServerByHost(self, host):
if len(self.serverlist) == 1: if len(self.serverlist) == 1:
@ -147,9 +148,8 @@ class MyHandler(BaseHTTPRequestHandler):
containerKey = urlparse(params.get('containerKey')).path containerKey = urlparse(params.get('containerKey')).path
except: except:
containerKey = '' containerKey = ''
regex = re.compile(r'''/playQueues/(\d+)$''')
try: try:
playQueueID = regex.findall(containerKey)[0] playQueueID = self.regex.findall(containerKey)[0]
except IndexError: except IndexError:
playQueueID = '' playQueueID = ''