Fix force transcoding

This commit is contained in:
croneter 2019-04-14 17:21:57 +02:00
parent 3aa5c87ca0
commit 2dac26ffc4
3 changed files with 23 additions and 22 deletions

View file

@ -64,7 +64,5 @@ class PlayState(object):
self.audioplaylist = None self.audioplaylist = None
# Was the playback initiated by the user using the Kodi context menu? # Was the playback initiated by the user using the Kodi context menu?
self.context_menu_play = False self.context_menu_play = False
# Set by context menu - shall we force-transcode the next playing item?
self.force_transcode = False
# Which Kodi player is/has been active? (either int 1, 2 or 3) # Which Kodi player is/has been active? (either int 1, 2 or 3)
self.active_players = set() self.active_players = set()

View file

@ -7,7 +7,7 @@ import xbmcgui
from .plex_api import API from .plex_api import API
from .plex_db import PlexDB from .plex_db import PlexDB
from . import context, plex_functions as PF, playqueue as PQ from . import context, plex_functions as PF
from . import utils, variables as v, app from . import utils, variables as v, app
############################################################################### ###############################################################################
@ -112,8 +112,7 @@ class ContextMenu(object):
""" """
selected = self._selected_option selected = self._selected_option
if selected == OPTIONS['Transcode']: if selected == OPTIONS['Transcode']:
app.PLAYSTATE.force_transcode = True self._PMS_play(transcode=True)
self._PMS_play()
elif selected == OPTIONS['PMS_Play']: elif selected == OPTIONS['PMS_Play']:
self._PMS_play() self._PMS_play()
elif selected == OPTIONS['Extras']: elif selected == OPTIONS['Extras']:
@ -139,17 +138,21 @@ class ContextMenu(object):
if PF.delete_item_from_pms(self.plex_id) is False: if PF.delete_item_from_pms(self.plex_id) is False:
utils.dialog("ok", heading="{plex}", line1=utils.lang(30414)) utils.dialog("ok", heading="{plex}", line1=utils.lang(30414))
def _PMS_play(self): def _PMS_play(self, transcode=False):
""" """
For using direct paths: Initiates playback using the PMS For using direct paths: Initiates playback using the PMS
""" """
playqueue = PQ.get_playqueue_from_type( path = ('http://127.0.0.1:%s/plex/play/file.strm?plex_id=%s'
v.KODI_PLAYLIST_TYPE_FROM_KODI_TYPE[self.kodi_type]) % (v.WEBSERVICE_PORT, self.plex_id))
playqueue.clear() if self.plex_type:
app.PLAYSTATE.context_menu_play = True path += '&plex_type=%s' % self.plex_type
handle = self.api.path(force_first_media=False, force_addon=True) if self.kodi_id:
handle = 'RunPlugin(%s)' % handle path += '&kodi_id=%s' % self.kodi_id
xbmc.executebuiltin(handle.encode('utf-8')) if self.kodi_type:
path += '&kodi_type=%s' % self.kodi_type
if transcode:
path += '&transcode=true'
xbmc.executebuiltin(('PlayMedia(%s)' % path).encode('utf-8'))
def _extras(self): def _extras(self):
""" """

View file

@ -108,9 +108,12 @@ class PlayStrm(object):
else: else:
self.xml[0].set('pkc_db_item', None) self.xml[0].set('pkc_db_item', None)
self.api = API(self.xml[0]) self.api = API(self.xml[0])
self.playqueue_item = PL.playlist_item_from_xml(self.xml[0],
kodi_id=self.kodi_id, def set_playqueue_item(self, xml, kodi_id, kodi_type):
kodi_type=self.kodi_type) self.playqueue_item = PL.playlist_item_from_xml(xml,
kodi_id=kodi_id,
kodi_type=kodi_type)
self.playqueue_item.force_transcode = self.transcode
def start_playback(self, index=0): def start_playback(self, index=0):
LOG.debug('Starting playback at %s', index) LOG.debug('Starting playback at %s', index)
@ -196,7 +199,6 @@ class PlayStrm(object):
utils.lang(30128), utils.lang(30128),
icon='{error}') icon='{error}')
app.PLAYSTATE.context_menu_play = False app.PLAYSTATE.context_menu_play = False
app.PLAYSTATE.force_transcode = False
app.PLAYSTATE.resume_playback = False app.PLAYSTATE.resume_playback = False
return return
PL.get_playlist_details_from_xml(self.playqueue, xml) PL.get_playlist_details_from_xml(self.playqueue, xml)
@ -208,7 +210,7 @@ class PlayStrm(object):
else: else:
listitem = widgets.get_listitem(self.xml[0], resume=False) listitem = widgets.get_listitem(self.xml[0], resume=False)
listitem.setSubtitles(self.api.cache_external_subs()) listitem.setSubtitles(self.api.cache_external_subs())
self.playqueue_item = PL.playlist_item_from_xml(self.xml[0]) self.set_playqueue_item(self.xml[0], self.kodi_id, self.kodi_type)
play = PlayUtils(self.api, self.playqueue_item) play = PlayUtils(self.api, self.playqueue_item)
url = play.getPlayUrl().encode('utf-8') url = play.getPlayUrl().encode('utf-8')
listitem.setPath(url) listitem.setPath(url)
@ -250,7 +252,7 @@ class PlayStrm(object):
continue continue
LOG.debug('Adding trailer: %s', api.title()) LOG.debug('Adding trailer: %s', api.title())
listitem = widgets.get_listitem(intro, resume=False) listitem = widgets.get_listitem(intro, resume=False)
self.playqueue_item = PL.playlist_item_from_xml(intro) self.set_playqueue_item(intro, None, None)
play = PlayUtils(api, self.playqueue_item) play = PlayUtils(api, self.playqueue_item)
url = play.getPlayUrl().encode('utf-8') url = play.getPlayUrl().encode('utf-8')
listitem.setPath(url) listitem.setPath(url)
@ -265,9 +267,7 @@ class PlayStrm(object):
continue continue
self.api.set_part_number(part) self.api.set_part_number(part)
LOG.debug('Adding addional part %s', part) LOG.debug('Adding addional part %s', part)
self.playqueue_item = PL.playlist_item_from_xml(self.xml[0], self.set_playqueue_item(self.xml[0], self.kodi_id, self.kodi_type)
kodi_id=self.kodi_id,
kodi_type=self.kodi_type)
self.playqueue_item.part = part self.playqueue_item.part = part
listitem = widgets.get_listitem(self.xml[0], resume=False) listitem = widgets.get_listitem(self.xml[0], resume=False)
listitem.setSubtitles(self.api.cache_external_subs()) listitem.setSubtitles(self.api.cache_external_subs())