bazarr
bazarr copied to clipboard
Incorrect Escape Sequence In File Paths for Radarr and Sonarr
Describe the bug
Bazarr uses /
to escape
(space) in the folder name where media is stored. This appears to be due to these replace
statements:
https://github.com/morpheus65535/bazarr/blob/d6b74c908353c5051e188565e01b686a7017c3e9/bazarr/utilities/path_mappings.py#L49
https://github.com/morpheus65535/bazarr/blob/d6b74c908353c5051e188565e01b686a7017c3e9/bazarr/utilities/path_mappings.py#L67
https://github.com/morpheus65535/bazarr/blob/d6b74c908353c5051e188565e01b686a7017c3e9/bazarr/utilities/path_mappings.py#L85
if path_mapping[1] in path:
path = path.replace(path_mapping[1], path_mapping[0])
if path.startswith('\\\\') or re.match(r'^[a-zA-Z]:\\', path):
path = path.replace('/', '\\')
elif path.startswith('/'):
path = path.replace('\\', '/')
break
We have the path mapping defined as
/library/movies/
-> /movies/
/library/tv/
-> /tv/
This causes the interpreter to enter the if block.
The path is then mutated to /movies/...
or /tv/...
and as the path mappings force tailing slashes, this ensures that the path now starts with /
, causing the interpreter to enter the elif
block.
Python's str.replace(old, new)
replaces all instances of old
with new
, so strings that were properly escaped are now "escaped" with the path delimiter /
.
Bazarr now believes movies like The Big Short
is in the folder /movies/The/ Big/ Short/
.
Example:
Path mapping in Bazarr:
Radarr: /library/movies/
Bazarr: /movies/
Sonarr:
/library/tv/
Bazarr: /tv/
(Note: when I attempt to leave the trailing slash off, it will map /library/
to /
)
Radarr has Road Trip
path: /library/movies/Road\ Trip\ (2005)/  Bazarr imported path:
/movies/Road/ Trip/ (2005)/`
Radarr has Mary Poppins
path: /library/movies/Mary\ Poppins\ (1964)/  Bazarr imported path:
/movies/Mary/ Poppins/ (1965)/`
To Reproduce Steps to reproduce the behavior:
- Deploy Radarr or Sonarr with library mounts that contain the mounts defined in Bazarrr container
- Have media separated into folders by the title of the media, some of which contain spaces
- Create appropriate path mappings in the Radarr and Sonarr settings page
- Sync the libraries into Bazarr
- Go to a movie or tv show that contains spaces and search for subtitles
- See
Error 500 File not found
error
Expected behavior Folders that are mapped between the services respect proper escape sequences for their platform
Screenshots Included above
Software (please complete the following information):
- Bazarr: v1.4.5 (image: linuxserver/bazarr:1.4.5)
- Radarr version 5.10.4.9218 (image: linuxserver/radarr:5.10.1)
- Sonarr version 4.0.9.2386 (image: linuxserver/sonarr:4.0.9)
- OS: Ubuntu 22.04
Additional context Add any other context about the problem here.