Speed up replacing Plex paths
This commit is contained in:
parent
4073679d3f
commit
d1da07a8bf
5 changed files with 42 additions and 25 deletions
|
@ -49,7 +49,8 @@ import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
||||||
DateToKodi, KODILANGUAGE
|
DateToKodi, KODILANGUAGE
|
||||||
from PlexFunctions import PLEX_TO_KODI_TIMEFACTOR, PMSHttpsEnabled
|
from PlexFunctions import PLEX_TO_KODI_TIMEFACTOR, PMSHttpsEnabled, \
|
||||||
|
REMAP_TYPE_FROM_PLEXTYPE
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -2515,29 +2516,17 @@ class API():
|
||||||
"""
|
"""
|
||||||
if path is None:
|
if path is None:
|
||||||
return None
|
return None
|
||||||
types = {
|
typus = REMAP_TYPE_FROM_PLEXTYPE[typus]
|
||||||
'movie': 'movie',
|
if window('remapSMB') == 'true':
|
||||||
'show': 'tv',
|
path = path.replace(window('remapSMB%sOrg' % typus),
|
||||||
'season': 'tv',
|
window('remapSMB%sNew' % typus),
|
||||||
'episode': 'tv',
|
|
||||||
'artist': 'music',
|
|
||||||
'album': 'music',
|
|
||||||
'song': 'music',
|
|
||||||
'track': 'music',
|
|
||||||
'clip': 'clip',
|
|
||||||
'photo': 'photo'
|
|
||||||
}
|
|
||||||
typus = types[typus]
|
|
||||||
if settings('remapSMB') == 'true':
|
|
||||||
path = path.replace(settings('remapSMB%sOrg' % typus),
|
|
||||||
settings('remapSMB%sNew' % typus),
|
|
||||||
1)
|
1)
|
||||||
# There might be backslashes left over:
|
# There might be backslashes left over:
|
||||||
path = path.replace('\\', '/')
|
path = path.replace('\\', '/')
|
||||||
elif settings('replaceSMB') == 'true':
|
elif window('replaceSMB') == 'true':
|
||||||
if path.startswith('\\\\'):
|
if path.startswith('\\\\'):
|
||||||
path = 'smb:' + path.replace('\\', '/')
|
path = 'smb:' + path.replace('\\', '/')
|
||||||
if settings('plex_pathverified') == 'true' and forceCheck is False:
|
if window('plex_pathverified') == 'true' and forceCheck is False:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
# exist() needs a / or \ at the end to work for directories
|
# exist() needs a / or \ at the end to work for directories
|
||||||
|
@ -2558,12 +2547,12 @@ class API():
|
||||||
if self.askToValidate(path):
|
if self.askToValidate(path):
|
||||||
window('plex_shouldStop', value="true")
|
window('plex_shouldStop', value="true")
|
||||||
path = None
|
path = None
|
||||||
settings('plex_pathverified', value='true')
|
window('plex_pathverified', value='true')
|
||||||
else:
|
else:
|
||||||
path = None
|
path = None
|
||||||
elif forceCheck is False:
|
elif forceCheck is False:
|
||||||
if settings('plex_pathverified') != 'true':
|
if window('plex_pathverified') != 'true':
|
||||||
settings('plex_pathverified', value='true')
|
window('plex_pathverified', value='true')
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def askToValidate(self, url):
|
def askToValidate(self, url):
|
||||||
|
|
|
@ -61,6 +61,20 @@ KODITYPE_FROM_PLEXTYPE = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
REMAP_TYPE_FROM_PLEXTYPE = {
|
||||||
|
'movie': 'movie',
|
||||||
|
'show': 'tv',
|
||||||
|
'season': 'tv',
|
||||||
|
'episode': 'tv',
|
||||||
|
'artist': 'music',
|
||||||
|
'album': 'music',
|
||||||
|
'song': 'music',
|
||||||
|
'track': 'music',
|
||||||
|
'clip': 'clip',
|
||||||
|
'photo': 'photo'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def ConvertPlexToKodiTime(plexTime):
|
def ConvertPlexToKodiTime(plexTime):
|
||||||
"""
|
"""
|
||||||
Converts Plextime to Koditime. Returns an int (in seconds).
|
Converts Plextime to Koditime. Returns an int (in seconds).
|
||||||
|
|
|
@ -13,7 +13,7 @@ import embydb_functions as embydb
|
||||||
import kodidb_functions as kodidb
|
import kodidb_functions as kodidb
|
||||||
import playbackutils as pbutils
|
import playbackutils as pbutils
|
||||||
from utils import window, settings, CatchExceptions, tryDecode, tryEncode
|
from utils import window, settings, CatchExceptions, tryDecode, tryEncode
|
||||||
from PlexFunctions import scrobble
|
from PlexFunctions import scrobble, REMAP_TYPE_FROM_PLEXTYPE
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -50,8 +50,16 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
'logLevel': 'plex_logLevel',
|
'logLevel': 'plex_logLevel',
|
||||||
'enableContext': 'plex_context',
|
'enableContext': 'plex_context',
|
||||||
'plex_restricteduser': 'plex_restricteduser',
|
'plex_restricteduser': 'plex_restricteduser',
|
||||||
'dbSyncIndicator': 'dbSyncIndicator'
|
'dbSyncIndicator': 'dbSyncIndicator',
|
||||||
|
'remapSMB': 'remapSMB',
|
||||||
|
'replaceSMB': 'replaceSMB',
|
||||||
}
|
}
|
||||||
|
# Path replacement
|
||||||
|
for typus in REMAP_TYPE_FROM_PLEXTYPE.values():
|
||||||
|
for arg in ('Org', 'New'):
|
||||||
|
key = 'remapSMB%s%s' % (typus, arg)
|
||||||
|
items[key] = key
|
||||||
|
# Reset the window variables from the settings variables
|
||||||
for settings_value, window_value in items.iteritems():
|
for settings_value, window_value in items.iteritems():
|
||||||
if window(window_value) != settings(settings_value):
|
if window(window_value) != settings(settings_value):
|
||||||
log.debug('PKC settings changed: %s is now %s'
|
log.debug('PKC settings changed: %s is now %s'
|
||||||
|
|
|
@ -392,6 +392,13 @@ class LibrarySync(Thread):
|
||||||
'enableBackgroundSync') == "true"
|
'enableBackgroundSync') == "true"
|
||||||
self.limitindex = int(settings('limitindex'))
|
self.limitindex = int(settings('limitindex'))
|
||||||
|
|
||||||
|
# Init for replacing paths
|
||||||
|
window('remapSMB', value=settings('remapSMB'))
|
||||||
|
window('replaceSMB', value=settings('replaceSMB'))
|
||||||
|
for typus in PF.REMAP_TYPE_FROM_PLEXTYPE.values():
|
||||||
|
for arg in ('Org', 'New'):
|
||||||
|
key = 'remapSMB%s%s' % (typus, arg)
|
||||||
|
window(key, value=settings(key))
|
||||||
# Just in case a time sync goes wrong
|
# Just in case a time sync goes wrong
|
||||||
self.timeoffset = int(settings('kodiplextimeoffset'))
|
self.timeoffset = int(settings('kodiplextimeoffset'))
|
||||||
window('kodiplextimeoffset', value=str(self.timeoffset))
|
window('kodiplextimeoffset', value=str(self.timeoffset))
|
||||||
|
|
|
@ -68,7 +68,6 @@
|
||||||
<setting id="enableExportSongRating" type="bool" label="30525" default="false" visible="false" />
|
<setting id="enableExportSongRating" type="bool" label="30525" default="false" visible="false" />
|
||||||
<setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" />
|
<setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" />
|
||||||
<setting id="enableUpdateSongRating" type="bool" label="30526" default="false" visible="false" />
|
<setting id="enableUpdateSongRating" type="bool" label="30526" default="false" visible="false" />
|
||||||
<setting id="plex_pathverified" type="bool" default="false" visible="false" /> <!-- If 'false': one single warning message pops up if PKC cannot verify direct paths -->
|
|
||||||
<setting id="themoviedbAPIKey" type="text" default="ae06df54334aa653354e9a010f4b81cb" visible="false"/>
|
<setting id="themoviedbAPIKey" type="text" default="ae06df54334aa653354e9a010f4b81cb" visible="false"/>
|
||||||
<setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/>
|
<setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/>
|
||||||
</category>
|
</category>
|
||||||
|
|
Loading…
Reference in a new issue