Plex trailers directly playable now
This commit is contained in:
parent
0b38176fa9
commit
57e6d40af2
4 changed files with 70 additions and 13 deletions
|
@ -1914,6 +1914,45 @@ class API():
|
|||
}
|
||||
return videoCodec
|
||||
|
||||
def getExtras(self):
|
||||
"""
|
||||
Returns a list of trailer and extras from PMS XML. Returns None if
|
||||
no extras are found.
|
||||
Extratypes:
|
||||
'1': Trailer
|
||||
'5': Behind the scenes
|
||||
|
||||
Output: list of dicts with one entry of the form:
|
||||
'key': e.g. /library/metadata/xxxx
|
||||
'title':
|
||||
'thumb': artwork
|
||||
'duration':
|
||||
'extraType':
|
||||
'originallyAvailableAt':
|
||||
'year':
|
||||
"""
|
||||
extras = self.item[0].find('Extras')
|
||||
if not extras:
|
||||
return None
|
||||
elements = []
|
||||
for extra in extras:
|
||||
# Trailer:
|
||||
key = extra.attrib['key']
|
||||
title = extra.attrib['title']
|
||||
thumb = extra.attrib['thumb']
|
||||
duration = extra.attrib['duration']
|
||||
year = extra.attrib['year']
|
||||
extraType = extra.attrib['extraType']
|
||||
originallyAvailableAt = extra.attrib['originallyAvailableAt']
|
||||
elements.append({'key': key,
|
||||
'title': title,
|
||||
'thumb': thumb,
|
||||
'duration': duration,
|
||||
'extraType': extraType,
|
||||
'originallyAvailableAt': originallyAvailableAt,
|
||||
'year': year})
|
||||
return elements
|
||||
|
||||
def getMediaStreams(self):
|
||||
"""
|
||||
Returns the media streams
|
||||
|
@ -2291,7 +2330,12 @@ class API():
|
|||
"""
|
||||
item = self.item
|
||||
key = self.getKey()
|
||||
try:
|
||||
uuid = item.attrib['librarySectionUUID']
|
||||
# if not found: probably trying to start a trailer directly
|
||||
# Hence no playlist needed
|
||||
except KeyError:
|
||||
return None
|
||||
mediatype = item[self.child].tag.lower()
|
||||
trailerNumber = utils.settings('trailerNumber')
|
||||
if not trailerNumber:
|
||||
|
|
|
@ -34,7 +34,12 @@ def doPlayback(itemid, dbid):
|
|||
# Get a first XML to get the librarySectionUUID
|
||||
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid)
|
||||
# Use that to call the playlist
|
||||
item = PlexAPI.API(item).GetPlexPlaylist()
|
||||
playlist = PlexAPI.API(item).GetPlexPlaylist()
|
||||
if playlist:
|
||||
pbutils.PlaybackUtils(playlist).play(itemid, dbid)
|
||||
|
||||
else:
|
||||
# No playlist received e.g. when directly playing trailers
|
||||
pbutils.PlaybackUtils(item).play(itemid, dbid)
|
||||
|
||||
##### DO RESET AUTH #####
|
||||
|
|
|
@ -349,9 +349,17 @@ class Movies(Items):
|
|||
studio = None
|
||||
self.logMsg("Retrieved metadata for %s" % itemid, 2)
|
||||
|
||||
# TODO: trailers
|
||||
# Find one trailer
|
||||
trailer = None
|
||||
self.logMsg("Retrieved trailer for %s" % itemid, 2)
|
||||
extras = API.getExtras()
|
||||
if extras:
|
||||
for item in extras:
|
||||
# Only get 1st trailer element
|
||||
if item['extraType'] == '1':
|
||||
trailer = item['key']
|
||||
trailer = "plugin://plugin.video.plexkodiconnect/trailer/?id=%s&mode=play" % trailer
|
||||
self.logMsg("Trailer for %s: %s" % (itemid, trailer), 2)
|
||||
break
|
||||
|
||||
##### GET THE FILE AND PATH #####
|
||||
playurl = API.getFilePath()
|
||||
|
|
Loading…
Reference in a new issue