Fix playing trailers directly via Plex Companion
This commit is contained in:
parent
b2663da584
commit
613e033b48
6 changed files with 27 additions and 12 deletions
|
@ -802,7 +802,7 @@ class PlexAPI():
|
||||||
'X-Plex-Client-Platform': self.platform,
|
'X-Plex-Client-Platform': self.platform,
|
||||||
'X-Plex-Device-Name': self.deviceName,
|
'X-Plex-Device-Name': self.deviceName,
|
||||||
'X-Plex-Platform': self.addonName,
|
'X-Plex-Platform': self.addonName,
|
||||||
'X-Plex-Platform-Version': 'no idea',
|
'X-Plex-Platform-Version': 'unknown',
|
||||||
'X-Plex-Model': 'unknown',
|
'X-Plex-Model': 'unknown',
|
||||||
'X-Plex-Product': self.addonName,
|
'X-Plex-Product': self.addonName,
|
||||||
'X-Plex-Version': self.plexversion,
|
'X-Plex-Version': self.plexversion,
|
||||||
|
|
|
@ -68,7 +68,7 @@ class DownloadUtils():
|
||||||
def setToken(self, token):
|
def setToken(self, token):
|
||||||
# Reserved for userclient only
|
# Reserved for userclient only
|
||||||
self.token = token
|
self.token = token
|
||||||
self.logMsg("Set token: %s" % token, 2)
|
self.logMsg("Set token: xxxxxxx", 2)
|
||||||
|
|
||||||
def setSSL(self, ssl, sslclient):
|
def setSSL(self, ssl, sslclient):
|
||||||
# Reserved for userclient only
|
# Reserved for userclient only
|
||||||
|
|
|
@ -40,6 +40,7 @@ def plexCompanion(fullurl, resume=None):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# No matches found, url not like:
|
# No matches found, url not like:
|
||||||
# http://192.168.0.2:32400/library/metadata/243480
|
# http://192.168.0.2:32400/library/metadata/243480
|
||||||
|
utils.logMsg("plexCompanion", "Could not parse url: %s" % fullurl, -1)
|
||||||
return False
|
return False
|
||||||
# TODO: direct play an URL
|
# TODO: direct play an URL
|
||||||
# Initialize embydb
|
# Initialize embydb
|
||||||
|
@ -47,11 +48,19 @@ def plexCompanion(fullurl, resume=None):
|
||||||
embycursor = embyconn.cursor()
|
embycursor = embyconn.cursor()
|
||||||
emby = embydb_functions.Embydb_Functions(embycursor)
|
emby = embydb_functions.Embydb_Functions(embycursor)
|
||||||
# Get dbid using itemid
|
# Get dbid using itemid
|
||||||
dbid = emby.getItem_byId(itemid)[0]
|
# Works only for library items, not e.g. for trailers
|
||||||
|
try:
|
||||||
|
dbid = emby.getItem_byId(itemid)[0]
|
||||||
|
except TypeError:
|
||||||
|
# Trailers and the like
|
||||||
|
dbid = None
|
||||||
embyconn.close()
|
embyconn.close()
|
||||||
# Fix resume timing
|
# Fix resume timing
|
||||||
if resume:
|
if resume:
|
||||||
resume = round(float(resume) / 1000.0, 6)
|
if resume == '0':
|
||||||
|
resume = None
|
||||||
|
else:
|
||||||
|
resume = round(float(resume) / 1000.0, 6)
|
||||||
# Start playing
|
# Start playing
|
||||||
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid)
|
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid)
|
||||||
pbutils.PlaybackUtils(item).play(itemid, dbid, seektime=resume)
|
pbutils.PlaybackUtils(item).play(itemid, dbid, seektime=resume)
|
||||||
|
@ -77,7 +86,7 @@ def resetAuth():
|
||||||
"Plex might lock your account if you fail to log in too many times. "
|
"Plex might lock your account if you fail to log in too many times. "
|
||||||
"Proceed anyway?"))
|
"Proceed anyway?"))
|
||||||
if resp == 1:
|
if resp == 1:
|
||||||
utils.logMsg("EMBY", "Reset login attempts.", 1)
|
utils.logMsg("PLEX", "Reset login attempts.", 1)
|
||||||
utils.window('emby_serverStatus', value="Auth")
|
utils.window('emby_serverStatus', value="Auth")
|
||||||
else:
|
else:
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||||
|
|
|
@ -178,7 +178,7 @@ class PlaybackUtils():
|
||||||
playlist.add(additionalPlayurl, additionalListItem, index=currentPosition)
|
playlist.add(additionalPlayurl, additionalListItem, index=currentPosition)
|
||||||
self.pl.verifyPlaylist()
|
self.pl.verifyPlaylist()
|
||||||
currentPosition += 1
|
currentPosition += 1
|
||||||
i = i + 1
|
i += 1
|
||||||
API.setPartNumber(0)
|
API.setPartNumber(0)
|
||||||
|
|
||||||
if dummyPlaylist:
|
if dummyPlaylist:
|
||||||
|
|
|
@ -25,6 +25,14 @@ plexbmc = xbmcaddon.Addon('plugin.video.plexkodiconnect')
|
||||||
settings['debug'] = utils.settings('companionDebugging')
|
settings['debug'] = utils.settings('companionDebugging')
|
||||||
settings['gdm_debug'] = utils.settings('companionGDMDebugging')
|
settings['gdm_debug'] = utils.settings('companionGDMDebugging')
|
||||||
|
|
||||||
|
# Transform 'true' into True because of the way Kodi's file settings work
|
||||||
|
kodiSettingsList = ['debug', 'gdm_debug']
|
||||||
|
for entry in kodiSettingsList:
|
||||||
|
if settings[entry] == 'true':
|
||||||
|
settings[entry] = True
|
||||||
|
else:
|
||||||
|
settings[entry] = False
|
||||||
|
|
||||||
settings['client_name'] = plexbmc.getSetting('deviceName')
|
settings['client_name'] = plexbmc.getSetting('deviceName')
|
||||||
|
|
||||||
# XBMC web server settings
|
# XBMC web server settings
|
||||||
|
|
|
@ -151,15 +151,13 @@ class UserClient(threading.Thread):
|
||||||
if not s_token:
|
if not s_token:
|
||||||
# Save access token if it's missing from settings
|
# Save access token if it's missing from settings
|
||||||
utils.settings('accessToken', value=w_token)
|
utils.settings('accessToken', value=w_token)
|
||||||
self.logMsg(
|
self.logMsg("Returning accessToken from WINDOW for username: %s "
|
||||||
"Returning accessToken from WINDOW for username: %s accessToken: %s"
|
"accessToken: xxxxx" % username, 2)
|
||||||
% (username, w_token), 2)
|
|
||||||
return w_token
|
return w_token
|
||||||
# Verify the settings
|
# Verify the settings
|
||||||
elif s_token:
|
elif s_token:
|
||||||
self.logMsg(
|
self.logMsg("Returning accessToken from SETTINGS for username: %s "
|
||||||
"Returning accessToken from SETTINGS for username: %s accessToken: %s"
|
"accessToken: xxxxx" % username, 2)
|
||||||
% (username, s_token), 2)
|
|
||||||
utils.window('emby_accessToken%s' % username, value=s_token)
|
utils.window('emby_accessToken%s' % username, value=s_token)
|
||||||
return s_token
|
return s_token
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue