From df67b9276845e5c7e1f36e9fa0a364b3600ca170 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 6 Nov 2016 15:37:22 +0100 Subject: [PATCH] New contextmenu: Force transcode video --- resources/lib/context_entry.py | 7 ++++--- resources/lib/player.py | 11 ++++++----- resources/lib/playutils.py | 5 +++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/resources/lib/context_entry.py b/resources/lib/context_entry.py index 3d923633..d5996b9e 100644 --- a/resources/lib/context_entry.py +++ b/resources/lib/context_entry.py @@ -92,8 +92,8 @@ class ContextMenu(object): self.item_type in PF.KODI_VIDEOTYPES): options.append(OPTIONS['PMS_Play']) - # if self.item_type in ("movie", "episode", "song"): - # options.append(OPTIONS['Transcode']) + if self.item_type in PF.KODI_VIDEOTYPES: + options.append(OPTIONS['Transcode']) # userdata = self.api.getUserData() # if userdata['Favorite']: @@ -134,7 +134,8 @@ class ContextMenu(object): selected = self._selected_option if selected == OPTIONS['Transcode']: - pass + window('plex_forcetranscode', value='true') + self._PMS_play() elif selected == OPTIONS['PMS_Play']: self._PMS_play() diff --git a/resources/lib/player.py b/resources/lib/player.py index 718caec6..06b6b0f8 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -305,11 +305,12 @@ class Player(xbmc.Player): self.stopAll() - window('plex_currently_playing_itemid', clear=True) - window('plex_customplaylist', clear=True) - window('plex_customplaylist.seektime', clear=True) - window('plex_customplaylist.seektime', clear=True) - window('plex_playbackProps', clear=True) + for item in ('plex_currently_playing_itemid', + 'plex_customplaylist', + 'plex_customplaylist.seektime', + 'plex_playbackProps', + 'plex_forcetranscode'): + window(item, clear=True) log.debug("Cleared playlist properties.") def onPlayBackEnded(self): diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 4b1489ce..abd695c4 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -155,6 +155,8 @@ class PlayUtils(): - codec is in h265 - 10bit video codec - HEVC codec + - window variable 'plex_forcetranscode' set to 'true' + (excepting trailers etc.) if the corresponding file settings are set to 'true' """ videoCodec = self.API.getVideoCodec() @@ -171,6 +173,9 @@ class PlayUtils(): # e.g. trailers. Avoids TypeError with "'h265' in codec" log.info('No codec from PMS, not transcoding.') return False + if window('plex_forcetranscode') == 'true': + log.info('User chose to force-transcode') + return True try: resolution = int(videoCodec['resolution']) except (TypeError, ValueError):