Merge pull request #1059 from croneter/fix-regex

Fix a couple of issues with music when using direct paths: correctly escape music paths for Kodi regex matching
This commit is contained in:
croneter 2019-11-14 17:21:13 +01:00 committed by GitHub
commit aff0fd7a5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
from logging import getLogger from logging import getLogger
import re
from .plex_api.media import Media from .plex_api.media import Media
from . import utils from . import utils
@ -85,7 +86,7 @@ def _turn_to_regex(path):
else: else:
if not path.endswith('\\'): if not path.endswith('\\'):
path = '%s\\' % path path = '%s\\' % path
# Need to escape backslashes # Escape all characters that could cause problems
path = path.replace('\\', '\\\\') path = re.escape(path)
# Beginning of path only needs to be similar # Beginning of path only needs to be similar
return '^%s' % path return '^%s' % path