diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index ea374718..1f441db1 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -451,6 +451,7 @@ class InitialSetup(): yeslabel="Native (Direct Paths)"): log.debug("User opted to use direct paths.") settings('useDirectPaths', value="1") + state.DIRECT_PATHS = True # Are you on a system where you would like to replace paths # \\NAS\mymovie.mkv with smb://NAS/mymovie.mkv? (e.g. Windows) if dialog.yesno(heading=lang(29999), line1=lang(39033)): diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index f0bac9a3..f997c883 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -16,6 +16,7 @@ import kodidb_functions as kodidb import PlexAPI from PlexFunctions import GetPlexMetadata import variables as v +import state ############################################################################### @@ -35,8 +36,6 @@ class Items(object): """ def __init__(self): - self.directpath = window('useDirectPaths') == 'true' - self.artwork = artwork.Artwork() self.userid = window('currUserId') self.server = window('pms_server') @@ -268,8 +267,8 @@ class Movies(Items): break # GET THE FILE AND PATH ##### - doIndirect = not self.directpath - if self.directpath: + doIndirect = not state.DIRECT_PATHS + if state.DIRECT_PATHS: # Direct paths is set the Kodi way playurl = API.getFilePath(forceFirstMediaStream=True) if playurl is None: @@ -569,8 +568,8 @@ class TVShows(Items): studio = None # GET THE FILE AND PATH ##### - doIndirect = not self.directpath - if self.directpath: + doIndirect = not state.DIRECT_PATHS + if state.DIRECT_PATHS: # Direct paths is set the Kodi way playurl = API.getTVShowPath() if playurl is None: @@ -892,9 +891,9 @@ class TVShows(Items): seasonid = self.kodi_db.addSeason(showid, season) # GET THE FILE AND PATH ##### - doIndirect = not self.directpath + doIndirect = not state.DIRECT_PATHS playurl = API.getFilePath(forceFirstMediaStream=True) - if self.directpath: + if state.DIRECT_PATHS: # Direct paths is set the Kodi way if playurl is None: # Something went wrong, trying to use non-direct paths @@ -1116,7 +1115,7 @@ class TVShows(Items): self.kodi_db.addStreams(fileid, streams, runtime) # Process playstates self.kodi_db.addPlaystate(fileid, resume, runtime, playcount, dateplayed) - if not self.directpath and resume: + if not state.DIRECT_PATHS and resume: # Create additional entry for widgets. This is only required for plugin/episode. temppathid = self.kodi_db.getPath("plugin://plugin.video.plexkodiconnect/tvshows/") tempfileid = self.kodi_db.addFile(filename, temppathid) @@ -1634,8 +1633,8 @@ class Music(Items): mood = ' / '.join(moods) # GET THE FILE AND PATH ##### - doIndirect = not self.directpath - if self.directpath: + doIndirect = not state.DIRECT_PATHS + if state.DIRECT_PATHS: # Direct paths is set the Kodi way playurl = API.getFilePath(forceFirstMediaStream=True) if playurl is None: diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index e4151d43..25e1df1c 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -71,7 +71,6 @@ class LibrarySync(Thread): self.enableMusic = settings('enableMusic') == "true" self.enableBackgroundSync = settings( 'enableBackgroundSync') == "true" - self.direct_paths = settings('useDirectPaths') == '1' # Init for replacing paths window('remapSMB', value=settings('remapSMB')) @@ -473,7 +472,7 @@ class LibrarySync(Thread): """ Compare the views to Plex """ - if self.direct_paths is True and self.enableMusic is True: + if state.DIRECT_PATHS is True and self.enableMusic is True: if music.set_excludefromscan_music_folders() is True: log.info('Detected new Music library - restarting now') # 'New Plex music library detected. Sorry, but we need to diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index 00fb5551..1ca853d4 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -22,6 +22,7 @@ from playlist_func import add_item_to_kodi_playlist, \ from pickler import Playback_Successful from plexdb_functions import Get_Plex_DB import variables as v +import state ############################################################################### @@ -187,7 +188,7 @@ class PlaybackUtils(): kodi_type) elif contextmenu_play: - if window('useDirectPaths') == 'true': + if state.DIRECT_PATHS: # Cannot add via JSON with full metadata because then we # Would be using the direct path log.debug("Adding contextmenu item for direct paths") diff --git a/resources/lib/state.py b/resources/lib/state.py index 46bf020a..6bbec4e3 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -19,7 +19,9 @@ PMS_STATUS = False SUSPEND_USER_CLIENT = False # Plex home user? Then "False". Along with window('plex_restricteduser') RESTRICTED_USER = False - +# Direct Paths (True) or Addon Paths (False)? Along with +# window('useDirectPaths') +DIRECT_PATHS = False # Along with window('plex_authenticated') AUTHENTICATED = False PLEX_TOKEN = None diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index e5ed9ccd..c890da01 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -163,6 +163,8 @@ class UserClient(threading.Thread): window('useDirectPaths', value='true' if settings('useDirectPaths') == "1" else 'false') + state.DIRECT_PATHS = True if settings('useDirectPaths') == "1" \ + else False window('plex_force_transcode_pix', value='true' if settings('force_transcode_pix') == "1" else 'false')