mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-11-10 17:13:35 +08:00
Continuing development.
This commit is contained in:
parent
6e3c340829
commit
2e99a3b0a8
1 changed files with 10 additions and 4 deletions
|
@ -18,9 +18,15 @@ from utils import get_sonarr_platform, get_radarr_platform
|
|||
def sonarr_path_mapping_regex():
|
||||
global path_mapping
|
||||
global sonarr_regex
|
||||
global sonarr_use_path_mapping
|
||||
|
||||
path_mapping = dict(ast.literal_eval(settings.general.path_mappings))
|
||||
sonarr_regex = re.compile("|".join(map(re.escape, path_mapping.keys())))
|
||||
path_mapping_temp = dict(ast.literal_eval(settings.general.path_mappings))
|
||||
path_mapping = {k: v for k, v in path_mapping_temp.items() if k != ''}
|
||||
if any(item for sublist in path_mapping for item in sublist):
|
||||
sonarr_use_path_mapping = True
|
||||
sonarr_regex = re.compile("|".join(path_mapping.keys()))
|
||||
else:
|
||||
sonarr_use_path_mapping = False
|
||||
|
||||
|
||||
def sonarr_path_mapping_reverse_regex():
|
||||
|
@ -56,8 +62,8 @@ def radarr_path_mapping_reverse_regex():
|
|||
|
||||
|
||||
def path_replace(path):
|
||||
if path is None:
|
||||
return None
|
||||
if path is None or sonarr_use_path_mapping is False:
|
||||
return path
|
||||
|
||||
reverted_path = sonarr_regex.sub(lambda match: path_mapping[match.group(0)], path, count=1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue