Make filepath more resiliant

to user mistakes when setting up a network share with extra trailing
slashes
This commit is contained in:
angelblue05 2018-03-31 01:50:58 -05:00
parent 97bd3e653d
commit f0f36b3b19
2 changed files with 8 additions and 3 deletions

View file

@ -385,9 +385,10 @@ class API(object):
filepath = "" filepath = ""
else: else:
if "\\\\" in filepath: if filepath.startswith('\\\\'):
# append smb protocol # append smb protocol
filepath = filepath.replace("\\\\", "smb://") filepath = filepath.replace("\\\\", "smb://", 1)
filepath = filepath.replace("\\\\", "\\")
filepath = filepath.replace("\\", "/") filepath = filepath.replace("\\", "/")
if 'VideoType' in self.item: if 'VideoType' in self.item:
@ -396,6 +397,9 @@ class API(object):
elif self.item['VideoType'] == "BluRay": elif self.item['VideoType'] == "BluRay":
filepath = "%s/BDMV/index.bdmv" % filepath filepath = "%s/BDMV/index.bdmv" % filepath
# In case user made a mistake with the network share
filepath = filepath.replace("\\\\", "\\")
if "\\" in filepath: if "\\" in filepath:
# Local path scenario, with special videotype # Local path scenario, with special videotype
filepath = filepath.replace("/", "\\") filepath = filepath.replace("/", "\\")

View file

@ -224,7 +224,8 @@ class PlayUtils():
# Assign network protocol # Assign network protocol
if path.startswith('\\\\'): if path.startswith('\\\\'):
path = path.replace('\\\\', "smb://") path = path.replace('\\\\', "smb://", 1)
path = path.replace('\\\\', "\\")
path = path.replace('\\', "/") path = path.replace('\\', "/")
if "://" in path: if "://" in path: