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)"):
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)):

View File

@ -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:

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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')