From f0f36b3b19c717e4319ef05f88fd02d8b5eebd89 Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Sat, 31 Mar 2018 01:50:58 -0500
Subject: [PATCH] Make filepath more resiliant

to user mistakes when setting up a network share with extra trailing
slashes
---
 resources/lib/api.py       | 8 ++++++--
 resources/lib/playutils.py | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/resources/lib/api.py b/resources/lib/api.py
index ddaa0975..8b544e2f 100644
--- a/resources/lib/api.py
+++ b/resources/lib/api.py
@@ -385,9 +385,10 @@ class API(object):
             filepath = ""
 
         else:
-            if "\\\\" in filepath:
+            if filepath.startswith('\\\\'):
                 # append smb protocol
-                filepath = filepath.replace("\\\\", "smb://")
+                filepath = filepath.replace("\\\\", "smb://", 1)
+                filepath = filepath.replace("\\\\", "\\")
                 filepath = filepath.replace("\\", "/")
 
             if 'VideoType' in self.item:
@@ -396,6 +397,9 @@ class API(object):
                 elif self.item['VideoType'] == "BluRay":
                     filepath = "%s/BDMV/index.bdmv" % filepath
 
+            # In case user made a mistake with the network share
+            filepath = filepath.replace("\\\\", "\\")
+
             if "\\" in filepath:
                 # Local path scenario, with special videotype
                 filepath = filepath.replace("/", "\\")
diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index e9dd2463..6ed1302f 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -224,7 +224,8 @@ class PlayUtils():
 
         # Assign network protocol
         if path.startswith('\\\\'):
-            path = path.replace('\\\\', "smb://")
+            path = path.replace('\\\\', "smb://", 1)
+            path = path.replace('\\\\', "\\")
             path = path.replace('\\', "/")
 
         if "://" in path: