Path replacement improvement

This commit is contained in:
Louis Vézina 2017-11-24 21:45:57 -05:00
parent bbd509e98f
commit be4c76fafc
3 changed files with 21 additions and 25 deletions

View File

@ -1,7 +1,7 @@
# coding: utf-8
from __future__ import unicode_literals
bazarr_version = '0.1.3'
bazarr_version = '0.1.4'
from bottle import route, run, template, static_file, request, redirect
import bottle

View File

@ -30,27 +30,23 @@ branch = general_settings[5]
automatic = general_settings[6]
def path_replace(path):
for path_mapping in path_mappings:
path = path.replace(path_mapping[0], path_mapping[1], 1)
if '\\' in path:
path = path.replace('/', '\\')
return path
for path_mapping in path_mappings:
if path_mapping[0] in path:
path = path.replace(path_mapping[0], path_mapping[1])
if path.startswith('\\\\'):
path = path.replace('/', '\\')
elif path.startswith('/'):
path = path.replace('\\', '/')
break
return path
def path_replace_reverse(path):
for path_mapping in path_mappings:
if path.startswith('\\\\\\\\'):
if '\\\\' in path:
path = path.replace('\\\\', '\\')
elif '\\' in path:
path = path.replace('\\\\', '\\')
path = path.replace(path_mapping[1], path_mapping[0], 1)
elif path.startswith('\\\\'):
path = path.replace(path_mapping[1], path_mapping[0], 1)
if '\\' in path:
path = path.replace('\\', '/')
return path
for path_mapping in path_mappings:
if path_mapping[1] in path:
path = path.replace(path_mapping[1], path_mapping[0])
if path.startswith('\\\\'):
path = path.replace('/', '\\')
elif path.startswith('/'):
path = path.replace('\\', '/')
break
return path

View File

@ -109,7 +109,7 @@ def full_scan_subtitles():
c_db.close()
for episode in episodes:
store_subtitles(path_replace(episode[0].encode('utf-8')))
store_subtitles(path_replace(episode[0]))
def series_scan_subtitles(no):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
@ -129,4 +129,4 @@ def new_scan_subtitles():
c_db.close()
for episode in episodes:
store_subtitles(path_replace(episode[0].encode('utf-8')))
store_subtitles(path_replace(episode[0]))