Move playbackutils methods to API

This commit is contained in:
tomkat83 2017-01-08 15:03:41 +01:00
parent 1b9ae0c924
commit 0dfafbbe3e
10 changed files with 135 additions and 130 deletions

View file

@ -50,7 +50,8 @@ 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, PLEX_TYPE_MOVIE, PLEX_TYPE_SHOW REMAP_TYPE_FROM_PLEXTYPE, PLEX_TYPE_MOVIE, PLEX_TYPE_SHOW, \
PLEX_TYPE_EPISODE
import plexdb_functions as plexdb import plexdb_functions as plexdb
############################################################################### ###############################################################################
@ -2318,7 +2319,7 @@ class API():
externalsubs.append(url) externalsubs.append(url)
kodiindex += 1 kodiindex += 1
mapping = json.dumps(mapping) mapping = json.dumps(mapping)
window('emby_%s.indexMapping' % playurl, value=mapping) window('plex_%s.indexMapping' % playurl, value=mapping)
log.info('Found external subs: %s' % externalsubs) log.info('Found external subs: %s' % externalsubs)
return externalsubs return externalsubs
@ -2563,3 +2564,68 @@ class API():
line1=lang(39031) + url, line1=lang(39031) + url,
line2=lang(39032)) line2=lang(39032))
return resp return resp
def set_listitem_artwork(self, listitem):
"""
Set all artwork to the listitem
"""
allartwork = self.getAllArtwork(parentInfo=True)
arttypes = {
'poster': "Primary",
'tvshow.poster': "Thumb",
'clearart': "Art",
'tvshow.clearart': "Art",
'clearart': "Primary",
'tvshow.clearart': "Primary",
'clearlogo': "Logo",
'tvshow.clearlogo': "Logo",
'discart': "Disc",
'fanart_image': "Backdrop",
'landscape': "Backdrop",
"banner": "Banner"
}
for arttype in arttypes:
art = arttypes[arttype]
if art == "Backdrop":
try:
# Backdrop is a list, grab the first backdrop
self._set_listitem_artprop(listitem,
arttype,
allartwork[art][0])
except:
pass
else:
self._set_listitem_artprop(listitem, arttype, allartwork[art])
def _set_listitem_artprop(self, listitem, arttype, path):
if arttype in (
'thumb', 'fanart_image', 'small_poster', 'tiny_poster',
'medium_landscape', 'medium_poster', 'small_fanartimage',
'medium_fanartimage', 'fanart_noindicators'):
listitem.setProperty(arttype, path)
else:
listitem.setArt({arttype: path})
def set_playback_win_props(self, playurl, listitem):
"""
Set all properties necessary for plugin path playback for listitem
"""
itemtype = self.getType()
userdata = self.getUserData()
plexitem = "plex_%s" % playurl
window('%s.runtime' % plexitem, value=str(userdata['Runtime']))
window('%s.type' % plexitem, value=itemtype)
window('%s.itemid' % plexitem, value=self.getRatingKey())
window('%s.playcount' % plexitem, value=str(userdata['PlayCount']))
if itemtype == PLEX_TYPE_EPISODE:
window('%s.refreshid' % plexitem, value=self.getParentRatingKey())
else:
window('%s.refreshid' % plexitem, value=self.getRatingKey())
# Append external subtitles to stream
playmethod = window('%s.playmethod' % plexitem)
if playmethod in ("DirectStream", "DirectPlay"):
subtitles = self.externalSubs(playurl)
listitem.setSubtitles(subtitles)

View file

@ -1035,14 +1035,14 @@ def BrowsePlexContent(viewid, mediatype="", folderid=""):
li.setProperty('IsPlayable', 'false') li.setProperty('IsPlayable', 'false')
path = "%s?id=%s&mode=browseplex&type=%s&folderid=%s" \ path = "%s?id=%s&mode=browseplex&type=%s&folderid=%s" \
% (sys.argv[0], viewid, mediatype, API.getKey()) % (sys.argv[0], viewid, mediatype, API.getKey())
pbutils.PlaybackUtils(item).setArtwork(li) API.set_listitem_artwork(li)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
url=path, url=path,
listitem=li, listitem=li,
isFolder=True) isFolder=True)
else: else:
li = API.CreateListItemFromPlexItem() li = API.CreateListItemFromPlexItem()
pbutils.PlaybackUtils(item).setArtwork(li) API.set_listitem_artwork(li)
xbmcplugin.addDirectoryItem( xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]), handle=int(sys.argv[1]),
url=li.getProperty("path"), url=li.getProperty("path"),
@ -1099,7 +1099,7 @@ def getOnDeck(viewid, mediatype, tagname, limit):
appendShowTitle=appendShowTitle, appendShowTitle=appendShowTitle,
appendSxxExx=appendSxxExx) appendSxxExx=appendSxxExx)
API.AddStreamInfo(listitem) API.AddStreamInfo(listitem)
pbutils.PlaybackUtils(item).setArtwork(listitem) API.set_listitem_artwork(listitem)
if directpaths: if directpaths:
url = API.getFilePath() url = API.getFilePath()
else: else:
@ -1252,7 +1252,7 @@ def watchlater():
API = PlexAPI.API(item) API = PlexAPI.API(item)
listitem = API.CreateListItemFromPlexItem() listitem = API.CreateListItemFromPlexItem()
API.AddStreamInfo(listitem) API.AddStreamInfo(listitem)
pbutils.PlaybackUtils(item).setArtwork(listitem) API.set_listitem_artwork(listitem)
params['id'] = item.attrib.get('key') params['id'] = item.attrib.get('key')
params['viewOffset'] = item.attrib.get('viewOffset', '0') params['viewOffset'] = item.attrib.get('viewOffset', '0')
params['plex_type'] = item.attrib.get('type') params['plex_type'] = item.attrib.get('type')

View file

@ -32,8 +32,8 @@ class GetKodiDB():
def __enter__(self): def __enter__(self):
self.kodiconn = kodiSQL(self.itemType) self.kodiconn = kodiSQL(self.itemType)
self.emby_db = Kodidb_Functions(self.kodiconn.cursor()) kodi_db = Kodidb_Functions(self.kodiconn.cursor())
return self.emby_db return kodi_db
def __exit__(self, type, value, traceback): def __exit__(self, type, value, traceback):
self.kodiconn.commit() self.kodiconn.commit()

View file

@ -3,17 +3,16 @@
############################################################################### ###############################################################################
import logging import logging
import json from json import loads
import xbmc from xbmc import Monitor, Player, sleep
import xbmcgui
import downloadutils import downloadutils
import plexdb_functions as plexdb import plexdb_functions as plexdb
import playbackutils as pbutils
from utils import window, settings, CatchExceptions, tryDecode, tryEncode from utils import window, settings, CatchExceptions, tryDecode, tryEncode
from PlexFunctions import scrobble, REMAP_TYPE_FROM_PLEXTYPE from PlexFunctions import scrobble, REMAP_TYPE_FROM_PLEXTYPE
from kodidb_functions import get_kodiid_from_filename from kodidb_functions import get_kodiid_from_filename
from PlexAPI import API
############################################################################### ###############################################################################
@ -22,14 +21,14 @@ log = logging.getLogger("PLEX."+__name__)
############################################################################### ###############################################################################
class KodiMonitor(xbmc.Monitor): class KodiMonitor(Monitor):
def __init__(self, callback): def __init__(self, callback):
self.mgr = callback self.mgr = callback
self.doUtils = downloadutils.DownloadUtils().downloadUrl self.doUtils = downloadutils.DownloadUtils().downloadUrl
self.xbmcplayer = xbmc.Player() self.xbmcplayer = Player()
self.playqueue = self.mgr.playqueue self.playqueue = self.mgr.playqueue
xbmc.Monitor.__init__(self) Monitor.__init__(self)
log.info("Kodi monitor started.") log.info("Kodi monitor started.")
def onScanStarted(self, library): def onScanStarted(self, library):
@ -71,7 +70,7 @@ class KodiMonitor(xbmc.Monitor):
def onNotification(self, sender, method, data): def onNotification(self, sender, method, data):
if data: if data:
data = json.loads(data, 'utf-8') data = loads(data, 'utf-8')
log.debug("Method: %s Data: %s" % (method, data)) log.debug("Method: %s Data: %s" % (method, data))
if method == "Player.OnPlay": if method == "Player.OnPlay":
@ -102,9 +101,9 @@ class KodiMonitor(xbmc.Monitor):
"video library update") "video library update")
else: else:
# Stop from manually marking as watched unwatched, with actual playback. # Stop from manually marking as watched unwatched, with actual playback.
if window('emby_skipWatched%s' % itemid) == "true": if window('plex_skipWatched%s' % itemid) == "true":
# property is set in player.py # property is set in player.py
window('emby_skipWatched%s' % itemid, clear=True) window('plex_skipWatched%s' % itemid, clear=True)
else: else:
# notify the server # notify the server
if playcount != 0: if playcount != 0:
@ -122,13 +121,13 @@ class KodiMonitor(xbmc.Monitor):
elif method == "System.OnWake": elif method == "System.OnWake":
# Allow network to wake up # Allow network to wake up
xbmc.sleep(10000) sleep(10000)
window('plex_onWake', value="true") window('plex_onWake', value="true")
window('plex_online', value="false") window('plex_online', value="false")
elif method == "GUI.OnScreensaverDeactivated": elif method == "GUI.OnScreensaverDeactivated":
if settings('dbSyncScreensaver') == "true": if settings('dbSyncScreensaver') == "true":
xbmc.sleep(5000) sleep(5000)
window('plex_runLibScan', value="full") window('plex_runLibScan', value="full")
def PlayBackStart(self, data): def PlayBackStart(self, data):
@ -142,7 +141,7 @@ class KodiMonitor(xbmc.Monitor):
currentFile = None currentFile = None
count = 0 count = 0
while currentFile is None: while currentFile is None:
xbmc.sleep(100) sleep(100)
try: try:
currentFile = self.xbmcplayer.getPlayingFile() currentFile = self.xbmcplayer.getPlayingFile()
except: except:
@ -166,7 +165,7 @@ class KodiMonitor(xbmc.Monitor):
# Try to get a Kodi ID # Try to get a Kodi ID
# If PKC was used - native paths, not direct paths # If PKC was used - native paths, not direct paths
plexid = window('emby_%s.itemid' % tryEncode(currentFile)) plexid = window('plex_%s.itemid' % tryEncode(currentFile))
# Get rid of the '' if the window property was not set # Get rid of the '' if the window property was not set
plexid = None if not plexid else plexid plexid = None if not plexid else plexid
kodiid = None kodiid = None
@ -210,24 +209,25 @@ class KodiMonitor(xbmc.Monitor):
# Save currentFile for cleanup later and to be able to access refs # Save currentFile for cleanup later and to be able to access refs
window('plex_lastPlayedFiled', value=currentFile) window('plex_lastPlayedFiled', value=currentFile)
window('plex_currently_playing_itemid', value=plexid) window('plex_currently_playing_itemid', value=plexid)
window("emby_%s.itemid" % tryEncode(currentFile), value=plexid) window("plex_%s.itemid" % tryEncode(currentFile), value=plexid)
log.info('Finish playback startup') log.info('Finish playback startup')
def StartDirectPath(self, plexid, type, currentFile): def StartDirectPath(self, plexid, type, currentFile):
""" """
Set some additional stuff if playback was initiated by Kodi, not PKC Set some additional stuff if playback was initiated by Kodi, not PKC
""" """
result = self.doUtils('{server}/library/metadata/%s' % plexid) xml = self.doUtils('{server}/library/metadata/%s' % plexid)
try: try:
result[0].attrib xml[0].attrib
except: except:
log.error('Did not receive a valid XML for plexid %s.' % plexid) log.error('Did not receive a valid XML for plexid %s.' % plexid)
return False return False
# Setup stuff, because playback was started by Kodi, not PKC # Setup stuff, because playback was started by Kodi, not PKC
pbutils.PlaybackUtils(result[0]).setProperties( api = API(xml[0])
currentFile, xbmcgui.ListItem()) listitem = api.CreateListItemFromPlexItem()
api.set_playback_win_props(currentFile, listitem)
if type == "song" and settings('streamMusic') == "true": if type == "song" and settings('streamMusic') == "true":
window('emby_%s.playmethod' % currentFile, value="DirectStream") window('plex_%s.playmethod' % currentFile, value="DirectStream")
else: else:
window('emby_%s.playmethod' % currentFile, value="DirectPlay") window('plex_%s.playmethod' % currentFile, value="DirectPlay")
log.debug('Window properties set for direct paths!') log.debug('Window properties set for direct paths!')

View file

@ -45,7 +45,7 @@ class Playback_Starter(Thread):
api = API(xml[0]) api = API(xml[0])
listitem = api.CreateListItemFromPlexItem(listitem) listitem = api.CreateListItemFromPlexItem(listitem)
api.AddStreamInfo(listitem) api.AddStreamInfo(listitem)
listitem = PlaybackUtils(xml[0], self.mgr).setArtwork(listitem) api.set_listitem_artwork(listitem)
result.listitem = listitem result.listitem = listitem
else: else:
# Video and Music # Video and Music

View file

@ -68,10 +68,10 @@ class PlaybackUtils():
# Item is not in Kodi database, is a trailer/clip or plex redirect # Item is not in Kodi database, is a trailer/clip or plex redirect
# e.g. plex.tv watch later # e.g. plex.tv watch later
api.CreateListItemFromPlexItem(listitem) api.CreateListItemFromPlexItem(listitem)
self.setArtwork(listitem) api.set_listitem_artwork(listitem)
if kodi_id == 'plexnode': if kodi_id == 'plexnode':
# Need to get yet another xml to get final url # Need to get yet another xml to get final url
window('emby_%s.playmethod' % playurl, clear=True) window('plex_%s.playmethod' % playurl, clear=True)
xml = downloadutils.DownloadUtils().downloadUrl( xml = downloadutils.DownloadUtils().downloadUrl(
'{server}%s' % item[0][0].attrib.get('key')) '{server}%s' % item[0][0].attrib.get('key'))
try: try:
@ -81,16 +81,16 @@ class PlaybackUtils():
% item[0][0].attrib.get('key')) % item[0][0].attrib.get('key'))
return return
playurl = tryEncode(xml[0].attrib.get('key')) playurl = tryEncode(xml[0].attrib.get('key'))
window('emby_%s.playmethod' % playurl, value='DirectStream') window('plex_%s.playmethod' % playurl, value='DirectStream')
playmethod = window('emby_%s.playmethod' % playurl) playmethod = window('plex_%s.playmethod' % playurl)
if playmethod == "Transcode": if playmethod == "Transcode":
window('emby_%s.playmethod' % playurl, clear=True) window('plex_%s.playmethod' % playurl, clear=True)
playurl = tryEncode(playutils.audioSubsPref( playurl = tryEncode(playutils.audioSubsPref(
listitem, tryDecode(playurl))) listitem, tryDecode(playurl)))
window('emby_%s.playmethod' % playurl, "Transcode") window('plex_%s.playmethod' % playurl, "Transcode")
listitem.setPath(playurl) listitem.setPath(playurl)
self.setProperties(playurl, listitem) api.set_playback_win_props(playurl, listitem)
result.listitem = listitem result.listitem = listitem
return result return result
@ -197,16 +197,16 @@ class PlaybackUtils():
# 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")
if window('emby_%s.playmethod' % playurl) == "Transcode": if window('plex_%s.playmethod' % playurl) == "Transcode":
window('emby_%s.playmethod' % playurl, window('plex_%s.playmethod' % playurl,
clear=True) clear=True)
playurl = tryEncode(playutils.audioSubsPref( playurl = tryEncode(playutils.audioSubsPref(
listitem, tryDecode(playurl))) listitem, tryDecode(playurl)))
window('emby_%s.playmethod' % playurl, window('plex_%s.playmethod' % playurl,
value="Transcode") value="Transcode")
api.CreateListItemFromPlexItem(listitem) api.CreateListItemFromPlexItem(listitem)
self.setProperties(playurl, listitem) api.set_playback_win_props(playurl, listitem)
self.setArtwork(listitem) api.set_listitem_artwork(listitem)
kodiPl.add(playurl, listitem, index=self.currentPosition+1) kodiPl.add(playurl, listitem, index=self.currentPosition+1)
else: else:
# Full metadata # Full metadata
@ -236,8 +236,9 @@ class PlaybackUtils():
log.debug("Adding additional part: %s, url: %s" log.debug("Adding additional part: %s, url: %s"
% (counter, additionalPlayurl)) % (counter, additionalPlayurl))
api.CreateListItemFromPlexItem(additionalListItem) api.CreateListItemFromPlexItem(additionalListItem)
self.setProperties(additionalPlayurl, additionalListItem) api.set_playback_win_props(additionalPlayurl,
self.setArtwork(additionalListItem) additionalListItem)
api.set_listitem_artwork(additionalListItem)
add_listitem_to_playlist( add_listitem_to_playlist(
playqueue, playqueue,
self.currentPosition, self.currentPosition,
@ -266,15 +267,16 @@ class PlaybackUtils():
# SETUP MAIN ITEM ########## # SETUP MAIN ITEM ##########
# For transcoding only, ask for audio/subs pref # For transcoding only, ask for audio/subs pref
if (window('emby_%s.playmethod' % playurl) == "Transcode" and if (window('plex_%s.playmethod' % playurl) == "Transcode" and
not contextmenu_play): not contextmenu_play):
window('emby_%s.playmethod' % playurl, clear=True) window('plex_%s.playmethod' % playurl, clear=True)
playurl = tryEncode(playutils.audioSubsPref( playurl = tryEncode(playutils.audioSubsPref(
listitem, tryDecode(playurl))) listitem, tryDecode(playurl)))
window('emby_%s.playmethod' % playurl, value="Transcode") window('plex_%s.playmethod' % playurl, value="Transcode")
listitem.setPath(playurl) listitem.setPath(playurl)
self.setProperties(playurl, listitem) api.set_playback_win_props(playurl, listitem)
api.set_listitem_artwork(listitem)
# PLAYBACK ################ # PLAYBACK ################
if (homeScreen and seektime and window('plex_customplaylist') != "true" if (homeScreen and seektime and window('plex_customplaylist') != "true"
@ -325,7 +327,7 @@ class PlaybackUtils():
params['id'] = introAPI.getRatingKey() params['id'] = introAPI.getRatingKey()
params['filename'] = introAPI.getKey() params['filename'] = introAPI.getKey()
introPlayurl = path + '?' + urlencode(params) introPlayurl = path + '?' + urlencode(params)
self.setArtwork(listitem, introAPI) introAPI.set_listitem_artwork(listitem)
# Overwrite the Plex url # Overwrite the Plex url
listitem.setPath(introPlayurl) listitem.setPath(introPlayurl)
log.info("Adding Intro: %s" % introPlayurl) log.info("Adding Intro: %s" % introPlayurl)
@ -337,67 +339,3 @@ class PlaybackUtils():
intro) intro)
self.currentPosition += 1 self.currentPosition += 1
return True return True
def setProperties(self, playurl, listitem):
# Set all properties necessary for plugin path playback
itemid = self.api.getRatingKey()
itemtype = self.api.getType()
userdata = self.api.getUserData()
embyitem = "emby_%s" % playurl
window('%s.runtime' % embyitem, value=str(userdata['Runtime']))
window('%s.type' % embyitem, value=itemtype)
window('%s.itemid' % embyitem, value=itemid)
window('%s.playcount' % embyitem, value=str(userdata['PlayCount']))
if itemtype == "episode":
window('%s.refreshid' % embyitem,
value=self.api.getParentRatingKey())
else:
window('%s.refreshid' % embyitem, value=itemid)
# Append external subtitles to stream
playmethod = window('%s.playmethod' % embyitem)
if playmethod in ("DirectStream", "DirectPlay"):
subtitles = self.api.externalSubs(playurl)
listitem.setSubtitles(subtitles)
self.setArtwork(listitem)
def setArtwork(self, listItem, api=None):
if api is None:
api = self.api
allartwork = api.getAllArtwork(parentInfo=True)
arttypes = {
'poster': "Primary",
'tvshow.poster': "Thumb",
'clearart': "Art",
'tvshow.clearart': "Art",
'clearart': "Primary",
'tvshow.clearart': "Primary",
'clearlogo': "Logo",
'tvshow.clearlogo': "Logo",
'discart': "Disc",
'fanart_image': "Backdrop",
'landscape': "Backdrop",
"banner": "Banner"
}
for arttype in arttypes:
art = arttypes[arttype]
if art == "Backdrop":
try:
# Backdrop is a list, grab the first backdrop
self.setArtProp(listItem, arttype, allartwork[art][0])
except:
pass
else:
self.setArtProp(listItem, arttype, allartwork[art])
def setArtProp(self, listItem, arttype, path):
if arttype in (
'thumb', 'fanart_image', 'small_poster', 'tiny_poster',
'medium_landscape', 'medium_poster', 'small_fanartimage',
'medium_fanartimage', 'fanart_noindicators'):
listItem.setProperty(arttype, path)
else:
listItem.setArt({arttype: path})

View file

@ -77,11 +77,11 @@ class Player(xbmc.Player):
self.currentFile = currentFile self.currentFile = currentFile
window('plex_lastPlayedFiled', value=currentFile) window('plex_lastPlayedFiled', value=currentFile)
# We may need to wait for info to be set in kodi monitor # We may need to wait for info to be set in kodi monitor
itemId = window("emby_%s.itemid" % currentFile) itemId = window("plex_%s.itemid" % currentFile)
count = 0 count = 0
while not itemId: while not itemId:
xbmc.sleep(200) xbmc.sleep(200)
itemId = window("emby_%s.itemid" % currentFile) itemId = window("plex_%s.itemid" % currentFile)
if count == 5: if count == 5:
log.warn("Could not find itemId, cancelling playback report!") log.warn("Could not find itemId, cancelling playback report!")
return return
@ -89,7 +89,7 @@ class Player(xbmc.Player):
log.info("ONPLAYBACK_STARTED: %s itemid: %s" % (currentFile, itemId)) log.info("ONPLAYBACK_STARTED: %s itemid: %s" % (currentFile, itemId))
plexitem = "emby_%s" % currentFile plexitem = "plex_%s" % currentFile
runtime = window("%s.runtime" % plexitem) runtime = window("%s.runtime" % plexitem)
refresh_id = window("%s.refreshid" % plexitem) refresh_id = window("%s.refreshid" % plexitem)
playMethod = window("%s.playmethod" % plexitem) playMethod = window("%s.playmethod" % plexitem)
@ -98,7 +98,7 @@ class Player(xbmc.Player):
playcount = int(window("%s.playcount" % plexitem)) playcount = int(window("%s.playcount" % plexitem))
except ValueError: except ValueError:
playcount = 0 playcount = 0
window('emby_skipWatched%s' % itemId, value="true") window('plex_skipWatched%s' % itemId, value="true")
log.debug("Playing itemtype is: %s" % itemType) log.debug("Playing itemtype is: %s" % itemType)
@ -339,7 +339,7 @@ class Player(xbmc.Player):
playMethod = data['playmethod'] playMethod = data['playmethod']
# Prevent manually mark as watched in Kodi monitor # Prevent manually mark as watched in Kodi monitor
window('emby_skipWatched%s' % itemid, value="true") window('plex_skipWatched%s' % itemid, value="true")
if currentPosition and runtime: if currentPosition and runtime:
try: try:
@ -392,13 +392,13 @@ class Player(xbmc.Player):
# Clean the WINDOW properties # Clean the WINDOW properties
for filename in self.played_info: for filename in self.played_info:
cleanup = ( cleanup = (
'emby_%s.itemid' % filename, 'plex_%s.itemid' % filename,
'emby_%s.runtime' % filename, 'plex_%s.runtime' % filename,
'emby_%s.refreshid' % filename, 'plex_%s.refreshid' % filename,
'emby_%s.playmethod' % filename, 'plex_%s.playmethod' % filename,
'emby_%s.type' % filename, 'plex_%s.type' % filename,
'emby_%s.runtime' % filename, 'plex_%s.runtime' % filename,
'emby_%s.playcount' % filename, 'plex_%s.playcount' % filename,
'plex_%s.playlistPosition' % filename 'plex_%s.playlistPosition' % filename
) )
for item in cleanup: for item in cleanup:

View file

@ -212,7 +212,7 @@ def update_playlist_from_PMS(playlist, playlist_id=None, xml=None):
try: try:
xml.attrib['%sVersion' % playlist.kind] xml.attrib['%sVersion' % playlist.kind]
except: except:
log.error('Could not download Plex playlist.') log.error('Could not process Plex playlist')
return return
# Clear our existing playlist and the associated Kodi playlist # Clear our existing playlist and the associated Kodi playlist
playlist.clear() playlist.clear()

View file

@ -85,7 +85,8 @@ class Playqueue(Thread):
with lock: with lock:
if playqueue_id != playqueue.ID: if playqueue_id != playqueue.ID:
log.debug('Need to fetch new playQueue from the PMS') log.debug('Need to fetch new playQueue from the PMS')
PL.update_playlist_from_PMS(playqueue, playqueue_id) xml = PL.get_PMS_playlist(playqueue, playqueue_id)
PL.update_playlist_from_PMS(playqueue, playqueue_id, xml=xml)
else: else:
log.debug('Restarting existing playQueue') log.debug('Restarting existing playQueue')
PL.refresh_playlist_from_PMS(playqueue) PL.refresh_playlist_from_PMS(playqueue)

View file

@ -45,14 +45,14 @@ class PlayUtils():
log.info("File is direct playing.") log.info("File is direct playing.")
playurl = tryEncode(playurl) playurl = tryEncode(playurl)
# Set playmethod property # Set playmethod property
window('emby_%s.playmethod' % playurl, "DirectPlay") window('plex_%s.playmethod' % playurl, "DirectPlay")
elif self.isDirectStream(): elif self.isDirectStream():
log.info("File is direct streaming.") log.info("File is direct streaming.")
playurl = tryEncode( playurl = tryEncode(
self.API.getTranscodeVideoPath('DirectStream')) self.API.getTranscodeVideoPath('DirectStream'))
# Set playmethod property # Set playmethod property
window('emby_%s.playmethod' % playurl, "DirectStream") window('plex_%s.playmethod' % playurl, "DirectStream")
else: else:
log.info("File is transcoding.") log.info("File is transcoding.")
@ -64,7 +64,7 @@ class PlayUtils():
'videoQuality': '100' 'videoQuality': '100'
})) }))
# Set playmethod property # Set playmethod property
window('emby_%s.playmethod' % playurl, value="Transcode") window('plex_%s.playmethod' % playurl, value="Transcode")
log.info("The playurl is: %s" % playurl) log.info("The playurl is: %s" % playurl)
return playurl return playurl