diff --git a/resources/lib/playback.py b/resources/lib/playback.py index 1e8f80f7..77e613af 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -413,6 +413,11 @@ def _conclude_playback(playqueue, pos): else: api = None playurl = item.file + if not playurl: + LOG.info('Did not get a playurl, aborting playback silently') + state.RESUME_PLAYBACK = False + pickler.pickle_me(result) + return listitem.setPath(utils.try_encode(playurl)) if item.playmethod == 'DirectStream': listitem.setSubtitles(api.cache_external_subs()) diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 68d45fe5..0021fcc8 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -24,12 +24,11 @@ class PlayUtils(): def getPlayUrl(self): """ - Returns the playurl for the part + Returns the playurl [unicode] for the part or returns None. (movie might consist of several files) - - playurl is in unicode! """ - self.api.mediastream_number() + if self.api.mediastream_number() is None: + return playurl = self.isDirectPlay() if playurl is not None: LOG.info("File is direct playing.") @@ -232,8 +231,9 @@ class PlayUtils(): stream by a PUT request to the PMS """ # Set media and part where we're at - if self.api.mediastream is None: - self.api.mediastream_number() + if (self.api.mediastream is None and + self.api.mediastream_number() is None): + return try: mediastreams = self.api.plex_media_streams() except (TypeError, IndexError): diff --git a/resources/lib/plex_api.py b/resources/lib/plex_api.py index 526076d9..baf56a7e 100644 --- a/resources/lib/plex_api.py +++ b/resources/lib/plex_api.py @@ -203,7 +203,8 @@ class API(object): files are present for the same PMS item """ if self.mediastream is None and force_first_media is False: - self.mediastream_number() + if self.mediastream_number() is None: + return try: if force_first_media is False: ans = self.item[self.mediastream][self.part].attrib['file'] @@ -1294,6 +1295,9 @@ class API(object): Returns the Media stream as an int (mostly 0). Will let the user choose if several media streams are present for a PMS item (if settings are set accordingly) + + Returns None if the user aborted selection (leaving self.mediastream at + its default of None) """ # How many streams do we have? count = 0 @@ -1345,6 +1349,9 @@ class API(object): option = utils.try_encode(option.strip()) dialoglist.append(option) media = utils.dialog('select', 'Select stream', dialoglist) + if media == -1: + LOG.info('User cancelled media stream selection') + return else: media = 0 self.mediastream = media @@ -1371,8 +1378,8 @@ class API(object): TODO: mediaIndex """ - if self.mediastream is None: - self.mediastream_number() + if self.mediastream is None and self.mediastream_number() is None: + return if quality is None: quality = {} xargs = clientinfo.getXArgsDeviceInfo()