This commit is contained in:
SpootDev 2016-03-31 10:58:49 -05:00
parent 065bff5215
commit 243a12c263

View file

@ -48,7 +48,6 @@ class PlaybackUtils():
def play(self, itemid, dbid=None): def play(self, itemid, dbid=None):
log = self.logMsg
window = utils.window window = utils.window
settings = utils.settings settings = utils.settings
@ -58,7 +57,7 @@ class PlaybackUtils():
listitem = xbmcgui.ListItem() listitem = xbmcgui.ListItem()
playutils = putils.PlayUtils(item) playutils = putils.PlayUtils(item)
log("Play called.", 1) self.logMsg("Play called.", 1)
playurl = playutils.getPlayUrl() playurl = playutils.getPlayUrl()
if not playurl: if not playurl:
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem) return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
@ -81,9 +80,9 @@ class PlaybackUtils():
introsPlaylist = False introsPlaylist = False
dummyPlaylist = False dummyPlaylist = False
log("Playlist start position: %s" % startPos, 2) self.logMsg("Playlist start position: %s" % startPos, 2)
log("Playlist plugin position: %s" % currentPosition, 2) self.logMsg("Playlist plugin position: %s" % currentPosition, 2)
log("Playlist size: %s" % sizePlaylist, 2) self.logMsg("Playlist size: %s" % sizePlaylist, 2)
############### RESUME POINT ################ ############### RESUME POINT ################
@ -95,12 +94,12 @@ class PlaybackUtils():
if not propertiesPlayback: if not propertiesPlayback:
window('emby_playbackProps', value="true") window('emby_playbackProps', value="true")
log("Setting up properties in playlist.", 1) self.logMsg("Setting up properties in playlist.", 1)
if (not homeScreen and not seektime and if (not homeScreen and not seektime and
window('emby_customPlaylist') != "true"): window('emby_customPlaylist') != "true"):
log("Adding dummy file to playlist.", 2) self.logMsg("Adding dummy file to playlist.", 2)
dummyPlaylist = True dummyPlaylist = True
playlist.add(playurl, listitem, index=startPos) playlist.add(playurl, listitem, index=startPos)
# Remove the original item from playlist # Remove the original item from playlist
@ -124,14 +123,14 @@ class PlaybackUtils():
if not resp: if not resp:
# User selected to not play trailers # User selected to not play trailers
getTrailers = False getTrailers = False
log("Skip trailers.", 1) self.logMsg("Skip trailers.", 1)
if getTrailers: if getTrailers:
for intro in intros['Items']: for intro in intros['Items']:
# The server randomly returns intros, process them. # The server randomly returns intros, process them.
introListItem = xbmcgui.ListItem() introListItem = xbmcgui.ListItem()
introPlayurl = putils.PlayUtils(intro).getPlayUrl() introPlayurl = putils.PlayUtils(intro).getPlayUrl()
log("Adding Intro: %s" % introPlayurl, 1) self.logMsg("Adding Intro: %s" % introPlayurl, 1)
# Set listitem and properties for intros # Set listitem and properties for intros
pbutils = PlaybackUtils(intro) pbutils = PlaybackUtils(intro)
@ -147,7 +146,7 @@ class PlaybackUtils():
if homeScreen and not seektime and not sizePlaylist: if homeScreen and not seektime and not sizePlaylist:
# Extend our current playlist with the actual item to play # Extend our current playlist with the actual item to play
# only if there's no playlist first # only if there's no playlist first
log("Adding main item to playlist.", 1) self.logMsg("Adding main item to playlist.", 1)
self.pl.addtoPlaylist(dbid, item['Type'].lower()) self.pl.addtoPlaylist(dbid, item['Type'].lower())
# Ensure that additional parts are played after the main item # Ensure that additional parts are played after the main item
@ -164,7 +163,7 @@ class PlaybackUtils():
additionalListItem = xbmcgui.ListItem() additionalListItem = xbmcgui.ListItem()
additionalPlayurl = putils.PlayUtils(part).getPlayUrl() additionalPlayurl = putils.PlayUtils(part).getPlayUrl()
log("Adding additional part: %s" % partcount, 1) self.logMsg("Adding additional part: %s" % partcount, 1)
# Set listitem and properties for each additional parts # Set listitem and properties for each additional parts
pbutils = PlaybackUtils(part) pbutils = PlaybackUtils(part)
@ -178,13 +177,13 @@ class PlaybackUtils():
if dummyPlaylist: if dummyPlaylist:
# Added a dummy file to the playlist, # Added a dummy file to the playlist,
# because the first item is going to fail automatically. # because the first item is going to fail automatically.
log("Processed as a playlist. First item is skipped.", 1) self.logMsg("Processed as a playlist. First item is skipped.", 1)
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem) return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
# We just skipped adding properties. Reset flag for next time. # We just skipped adding properties. Reset flag for next time.
elif propertiesPlayback: elif propertiesPlayback:
log("Resetting properties playback flag.", 2) self.logMsg("Resetting properties playback flag.", 2)
window('emby_playbackProps', clear=True) window('emby_playbackProps', clear=True)
#self.pl.verifyPlaylist() #self.pl.verifyPlaylist()
@ -201,18 +200,18 @@ class PlaybackUtils():
############### PLAYBACK ################ ############### PLAYBACK ################
if homeScreen and seektime and window('emby_customPlaylist') != "true": if homeScreen and seektime and window('emby_customPlaylist') != "true":
log("Play as a widget item.", 1) self.logMsg("Play as a widget item.", 1)
self.setListItem(listitem) self.setListItem(listitem)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
elif ((introsPlaylist and window('emby_customPlaylist') == "true") or elif ((introsPlaylist and window('emby_customPlaylist') == "true") or
(homeScreen and not sizePlaylist)): (homeScreen and not sizePlaylist)):
# Playlist was created just now, play it. # Playlist was created just now, play it.
log("Play playlist.", 1) self.logMsg("Play playlist.", 1)
xbmc.Player().play(playlist, startpos=startPos) xbmc.Player().play(playlist, startpos=startPos)
else: else:
log("Play as a regular item.", 1) self.logMsg("Play as a regular item.", 1)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def setProperties(self, playurl, listitem): def setProperties(self, playurl, listitem):