From 287677f6832a68d1201ff458d7d6bd62a0dbcfde Mon Sep 17 00:00:00 2001
From: angelblue05 <angelblue05@users.noreply.github.com>
Date: Fri, 27 Mar 2015 04:53:30 -0500
Subject: [PATCH] Create addondir directory

This allows to make the addon work right away, without a Kodi restart.
Step to eliminate the need to restart Kodi after setting the sources, etc.
---
 resources/lib/Utils.py | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py
index 56d06261..5b1a5bec 100644
--- a/resources/lib/Utils.py
+++ b/resources/lib/Utils.py
@@ -55,6 +55,28 @@ def checkKodiSources():
     tvLibrary           = os.path.join(dataPath,'tvshows')
     musicvideoLibrary = os.path.join(dataPath,'musicvideos')
     
+    # If no folder exists at the time, create it.
+    if xbmcvfs.exists(addondir) == False:
+        xbmcvfs.mkdir(addondir)
+        xbmc.log("Manually created %s" % addondir)
+    
+    if not xbmcvfs.exists(dataPath + os.sep):
+        xbmcvfs.mkdir(dataPath)
+    if not xbmcvfs.exists(movieLibrary + os.sep):
+        xbmcvfs.mkdir(movieLibrary)
+        addKodiSource("mediabrowser_movies",movieLibrary,"movies")
+    if not xbmcvfs.exists(tvLibrary + os.sep):
+        xbmcvfs.mkdir(tvLibrary)
+        addKodiSource("mediabrowser_tvshows",tvLibrary,"tvshows")
+    if not xbmcvfs.exists(musicvideoLibrary + os.sep):
+        xbmcvfs.mkdir(musicvideoLibrary)
+        addKodiSource("mediabrowser_musicvideos",musicvideoLibrary,"musicvideos")
+    
+    KodiAdvancedSettingsCheck()
+    
+    return True
+    
+    ''' To be deleted once fully tested - Angel
     rebootRequired = False
     
     if not xbmcvfs.exists(dataPath + os.sep):
@@ -81,7 +103,7 @@ def checkKodiSources():
         else:
             return False
     
-    return True
+    return True'''
 
 def KodiSQL():
     if xbmc.getInfoLabel("System.BuildVersion").startswith("13"):
@@ -279,4 +301,4 @@ def stopProfiling(pr, profileName):
 
 
    
- 
\ No newline at end of file
+