mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-31 11:22:38 +00:00
Path replacement improvement
This commit is contained in:
parent
bbd509e98f
commit
be4c76fafc
3 changed files with 21 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
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
|
from bottle import route, run, template, static_file, request, redirect
|
||||||
import bottle
|
import bottle
|
||||||
|
|
|
@ -30,27 +30,23 @@ branch = general_settings[5]
|
||||||
automatic = general_settings[6]
|
automatic = general_settings[6]
|
||||||
|
|
||||||
def path_replace(path):
|
def path_replace(path):
|
||||||
for path_mapping in path_mappings:
|
for path_mapping in path_mappings:
|
||||||
path = path.replace(path_mapping[0], path_mapping[1], 1)
|
if path_mapping[0] in path:
|
||||||
|
path = path.replace(path_mapping[0], path_mapping[1])
|
||||||
if '\\' in path:
|
if path.startswith('\\\\'):
|
||||||
path = path.replace('/', '\\')
|
path = path.replace('/', '\\')
|
||||||
|
elif path.startswith('/'):
|
||||||
return path
|
path = path.replace('\\', '/')
|
||||||
|
break
|
||||||
|
return path
|
||||||
|
|
||||||
def path_replace_reverse(path):
|
def path_replace_reverse(path):
|
||||||
for path_mapping in path_mappings:
|
for path_mapping in path_mappings:
|
||||||
if path.startswith('\\\\\\\\'):
|
if path_mapping[1] in path:
|
||||||
if '\\\\' in path:
|
path = path.replace(path_mapping[1], path_mapping[0])
|
||||||
path = path.replace('\\\\', '\\')
|
if path.startswith('\\\\'):
|
||||||
elif '\\' in path:
|
path = path.replace('/', '\\')
|
||||||
path = path.replace('\\\\', '\\')
|
elif path.startswith('/'):
|
||||||
|
path = path.replace('\\', '/')
|
||||||
path = path.replace(path_mapping[1], path_mapping[0], 1)
|
break
|
||||||
elif path.startswith('\\\\'):
|
return path
|
||||||
path = path.replace(path_mapping[1], path_mapping[0], 1)
|
|
||||||
|
|
||||||
if '\\' in path:
|
|
||||||
path = path.replace('\\', '/')
|
|
||||||
|
|
||||||
return path
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ def full_scan_subtitles():
|
||||||
c_db.close()
|
c_db.close()
|
||||||
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
store_subtitles(path_replace(episode[0].encode('utf-8')))
|
store_subtitles(path_replace(episode[0]))
|
||||||
|
|
||||||
def series_scan_subtitles(no):
|
def series_scan_subtitles(no):
|
||||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
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()
|
c_db.close()
|
||||||
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
store_subtitles(path_replace(episode[0].encode('utf-8')))
|
store_subtitles(path_replace(episode[0]))
|
||||||
|
|
Loading…
Reference in a new issue