Voidless playback. Slightly important

This commit is contained in:
Matt 2020-11-17 12:10:04 -05:00
parent 4a437f7a2b
commit feea23e9da
3 changed files with 11 additions and 12 deletions

View file

@ -844,7 +844,7 @@ def get_themes(api_client):
paths = []
for theme in themes['ThemeVideosResult']['Items'] + themes['ThemeSongsResult']['Items']:
putils = PlayUtils(theme, False, None, server, token)
putils = PlayUtils(theme, False, None, server, api_client)
if play:
paths.append(putils.direct_play(theme['MediaSources'][0]))

View file

@ -12,7 +12,6 @@ from kodi_six import xbmc, xbmcvfs
import client
import requests
from helper import LazyLogger
from jellyfin import Jellyfin
from . import translate, settings, window, dialog, api
@ -53,26 +52,26 @@ def set_properties(item, method, server_id=None):
class PlayUtils(object):
def __init__(self, item, force_transcode=False, server_id=None, server=None, token=None):
def __init__(self, item, force_transcode=False, server_id=None, server=None, api_client=None):
''' Item will be updated with the property PlaybackInfo, which
holds all the playback information.
'''
self.item = item
self.item['PlaybackInfo'] = {}
self.jellyfin_client = Jellyfin(server_id).get_client()
self.api_client = api_client
self.info = {
'ServerId': server_id,
'ServerAddress': server,
'ForceTranscode': force_transcode,
'Token': token or self.jellyfin_client.auth.jellyfin_token()
'Token': api_client.config.data['auth.token']
}
def get_sources(self, source_id=None):
''' Return sources based on the optional source_id or the device profile.
'''
info = self.jellyfin_client.jellyfin.get_play_info(self.item['Id'], self.get_device_profile())
info = self.api_client.get_play_info(self.item['Id'], self.get_device_profile())
LOG.info(info)
self.info['PlaySessionId'] = info['PlaySessionId']
sources = []
@ -213,7 +212,7 @@ class PlayUtils(object):
''' Get live stream media info.
'''
info = self.jellyfin_client.jellyfin.get_live_stream(self.item['Id'], self.info['PlaySessionId'], source['OpenToken'], self.get_device_profile())
info = self.api_client.get_live_stream(self.item['Id'], self.info['PlaySessionId'], source['OpenToken'], self.get_device_profile())
LOG.info(info)
if info['MediaSource'].get('RequiresClosing'):
@ -498,7 +497,7 @@ class PlayUtils(object):
mapping = {}
kodi = 0
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
server_settings = self.api_client.get_transcode_settings()
for stream in source['MediaStreams']:
if stream['SupportsExternalStream'] and stream['Type'] == 'Subtitle' and stream['DeliveryMethod'] == 'External':
@ -587,7 +586,7 @@ class PlayUtils(object):
subs_streams = collections.OrderedDict()
streams = source['MediaStreams']
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
server_settings = self.api_client.get_transcode_settings()
allow_burned_subs = settings('allowBurnedSubs.bool')
for stream in streams:
@ -654,7 +653,7 @@ class PlayUtils(object):
if subtitle:
index = subtitle
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
server_settings = self.api_client.get_transcode_settings()
stream = streams[index]
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
@ -674,7 +673,7 @@ class PlayUtils(object):
if index is not None:
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
server_settings = self.api_client.get_transcode_settings()
stream = streams[index]
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:

View file

@ -51,7 +51,7 @@ class Actions(object):
transcode = transcode or settings('playFromTranscode.bool')
kodi_playlist = self.get_playlist(item)
play = playutils.PlayUtils(item, transcode, self.server_id, self.server)
play = playutils.PlayUtils(item, transcode, self.server_id, self.server, self.api_client)
source = play.select_source(play.get_sources())
play.set_external_subs(source, listitem)