Add state for direct paths

This commit is contained in:
tomkat83 2017-05-17 15:42:12 +02:00
parent 8e70955ded
commit 8ae68a7158
6 changed files with 19 additions and 15 deletions

View file

@ -451,6 +451,7 @@ class InitialSetup():
yeslabel="Native (Direct Paths)"): yeslabel="Native (Direct Paths)"):
log.debug("User opted to use direct paths.") log.debug("User opted to use direct paths.")
settings('useDirectPaths', value="1") settings('useDirectPaths', value="1")
state.DIRECT_PATHS = True
# Are you on a system where you would like to replace paths # Are you on a system where you would like to replace paths
# \\NAS\mymovie.mkv with smb://NAS/mymovie.mkv? (e.g. Windows) # \\NAS\mymovie.mkv with smb://NAS/mymovie.mkv? (e.g. Windows)
if dialog.yesno(heading=lang(29999), line1=lang(39033)): if dialog.yesno(heading=lang(29999), line1=lang(39033)):

View file

@ -16,6 +16,7 @@ import kodidb_functions as kodidb
import PlexAPI import PlexAPI
from PlexFunctions import GetPlexMetadata from PlexFunctions import GetPlexMetadata
import variables as v import variables as v
import state
############################################################################### ###############################################################################
@ -35,8 +36,6 @@ class Items(object):
""" """
def __init__(self): def __init__(self):
self.directpath = window('useDirectPaths') == 'true'
self.artwork = artwork.Artwork() self.artwork = artwork.Artwork()
self.userid = window('currUserId') self.userid = window('currUserId')
self.server = window('pms_server') self.server = window('pms_server')
@ -268,8 +267,8 @@ class Movies(Items):
break break
# GET THE FILE AND PATH ##### # GET THE FILE AND PATH #####
doIndirect = not self.directpath doIndirect = not state.DIRECT_PATHS
if self.directpath: if state.DIRECT_PATHS:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
playurl = API.getFilePath(forceFirstMediaStream=True) playurl = API.getFilePath(forceFirstMediaStream=True)
if playurl is None: if playurl is None:
@ -569,8 +568,8 @@ class TVShows(Items):
studio = None studio = None
# GET THE FILE AND PATH ##### # GET THE FILE AND PATH #####
doIndirect = not self.directpath doIndirect = not state.DIRECT_PATHS
if self.directpath: if state.DIRECT_PATHS:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
playurl = API.getTVShowPath() playurl = API.getTVShowPath()
if playurl is None: if playurl is None:
@ -892,9 +891,9 @@ class TVShows(Items):
seasonid = self.kodi_db.addSeason(showid, season) seasonid = self.kodi_db.addSeason(showid, season)
# GET THE FILE AND PATH ##### # GET THE FILE AND PATH #####
doIndirect = not self.directpath doIndirect = not state.DIRECT_PATHS
playurl = API.getFilePath(forceFirstMediaStream=True) playurl = API.getFilePath(forceFirstMediaStream=True)
if self.directpath: if state.DIRECT_PATHS:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
if playurl is None: if playurl is None:
# Something went wrong, trying to use non-direct paths # Something went wrong, trying to use non-direct paths
@ -1116,7 +1115,7 @@ class TVShows(Items):
self.kodi_db.addStreams(fileid, streams, runtime) self.kodi_db.addStreams(fileid, streams, runtime)
# Process playstates # Process playstates
self.kodi_db.addPlaystate(fileid, resume, runtime, playcount, dateplayed) 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. # Create additional entry for widgets. This is only required for plugin/episode.
temppathid = self.kodi_db.getPath("plugin://plugin.video.plexkodiconnect/tvshows/") temppathid = self.kodi_db.getPath("plugin://plugin.video.plexkodiconnect/tvshows/")
tempfileid = self.kodi_db.addFile(filename, temppathid) tempfileid = self.kodi_db.addFile(filename, temppathid)
@ -1634,8 +1633,8 @@ class Music(Items):
mood = ' / '.join(moods) mood = ' / '.join(moods)
# GET THE FILE AND PATH ##### # GET THE FILE AND PATH #####
doIndirect = not self.directpath doIndirect = not state.DIRECT_PATHS
if self.directpath: if state.DIRECT_PATHS:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
playurl = API.getFilePath(forceFirstMediaStream=True) playurl = API.getFilePath(forceFirstMediaStream=True)
if playurl is None: if playurl is None:

View file

@ -71,7 +71,6 @@ class LibrarySync(Thread):
self.enableMusic = settings('enableMusic') == "true" self.enableMusic = settings('enableMusic') == "true"
self.enableBackgroundSync = settings( self.enableBackgroundSync = settings(
'enableBackgroundSync') == "true" 'enableBackgroundSync') == "true"
self.direct_paths = settings('useDirectPaths') == '1'
# Init for replacing paths # Init for replacing paths
window('remapSMB', value=settings('remapSMB')) window('remapSMB', value=settings('remapSMB'))
@ -473,7 +472,7 @@ class LibrarySync(Thread):
""" """
Compare the views to Plex 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: if music.set_excludefromscan_music_folders() is True:
log.info('Detected new Music library - restarting now') log.info('Detected new Music library - restarting now')
# 'New Plex music library detected. Sorry, but we need to # 'New Plex music library detected. Sorry, but we need to

View file

@ -22,6 +22,7 @@ from playlist_func import add_item_to_kodi_playlist, \
from pickler import Playback_Successful from pickler import Playback_Successful
from plexdb_functions import Get_Plex_DB from plexdb_functions import Get_Plex_DB
import variables as v import variables as v
import state
############################################################################### ###############################################################################
@ -187,7 +188,7 @@ class PlaybackUtils():
kodi_type) kodi_type)
elif contextmenu_play: elif contextmenu_play:
if window('useDirectPaths') == 'true': if state.DIRECT_PATHS:
# Cannot add via JSON with full metadata because then we # Cannot add via JSON with full metadata because then we
# Would be using the direct path # Would be using the direct path
log.debug("Adding contextmenu item for direct paths") log.debug("Adding contextmenu item for direct paths")

View file

@ -19,7 +19,9 @@ PMS_STATUS = False
SUSPEND_USER_CLIENT = False SUSPEND_USER_CLIENT = False
# Plex home user? Then "False". Along with window('plex_restricteduser') # Plex home user? Then "False". Along with window('plex_restricteduser')
RESTRICTED_USER = False RESTRICTED_USER = False
# Direct Paths (True) or Addon Paths (False)? Along with
# window('useDirectPaths')
DIRECT_PATHS = False
# Along with window('plex_authenticated') # Along with window('plex_authenticated')
AUTHENTICATED = False AUTHENTICATED = False
PLEX_TOKEN = None PLEX_TOKEN = None

View file

@ -163,6 +163,8 @@ class UserClient(threading.Thread):
window('useDirectPaths', value='true' window('useDirectPaths', value='true'
if settings('useDirectPaths') == "1" else 'false') if settings('useDirectPaths') == "1" else 'false')
state.DIRECT_PATHS = True if settings('useDirectPaths') == "1" \
else False
window('plex_force_transcode_pix', value='true' window('plex_force_transcode_pix', value='true'
if settings('force_transcode_pix') == "1" else 'false') if settings('force_transcode_pix') == "1" else 'false')