From e17d9bf1dd84ba8e7f7e6d8cabfc33f20a8a3a9c Mon Sep 17 00:00:00 2001 From: croneter Date: Thu, 14 Nov 2019 15:44:29 +0100 Subject: [PATCH] Fix a couple of issues with music when using direct paths: escape the path for Kodi regex matching --- resources/lib/music.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/lib/music.py b/resources/lib/music.py index cf24f7f0..af638674 100644 --- a/resources/lib/music.py +++ b/resources/lib/music.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_literals from logging import getLogger +import re from .plex_api.media import Media from . import utils @@ -85,7 +86,7 @@ def _turn_to_regex(path): else: if not path.endswith('\\'): path = '%s\\' % path - # Need to escape backslashes - path = path.replace('\\', '\\\\') + # Escape all characters that could cause problems + path = re.escape(path) # Beginning of path only needs to be similar return '^%s' % path