From a67f7f00604a73ad50a87a31963abf54fc2bd92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 27 Nov 2017 20:53:53 -0500 Subject: [PATCH] Path replacement bug under Linux --- get_general_settings.py | 6 ++---- list_subtitles.py | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/get_general_settings.py b/get_general_settings.py index bc8cd6e50..a517e63cb 100644 --- a/get_general_settings.py +++ b/get_general_settings.py @@ -38,10 +38,9 @@ def path_replace(path): elif path.startswith('/'): path = path.replace('\\', '/') break - return path.encode('utf8') + return path def path_replace_reverse(path): - print path for path_mapping in path_mappings: if path_mapping[1] in path: path = path.replace(path_mapping[1], path_mapping[0]) @@ -50,5 +49,4 @@ def path_replace_reverse(path): elif path.startswith('/'): path = path.replace('\\', '/') break - print path - return path.encode('utf8') + return path diff --git a/list_subtitles.py b/list_subtitles.py index 2698b6d98..88e105202 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -8,6 +8,7 @@ from subliminal import * import pycountry import sqlite3 import ast +import sys from get_general_settings import * @@ -109,7 +110,7 @@ def full_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0]).encode('string_escape')) + store_subtitles(path_replace(episode[0]).encode(sys.getfilesystemencoding())) def series_scan_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) @@ -118,7 +119,7 @@ def series_scan_subtitles(no): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0]).encode('string_escape')) + store_subtitles(path_replace(episode[0]).encode(sys.getfilesystemencoding())) list_missing_subtitles(no) @@ -129,4 +130,4 @@ def new_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0]).encode('string_escape')) + store_subtitles(path_replace(episode[0]).encode(sys.getfilesystemencoding()))