Fix subtitles not following server settings

This commit is contained in:
angelblue05 2018-11-09 18:13:08 -06:00
parent 702ce0beac
commit a1851069ed

View file

@ -171,15 +171,14 @@ class Player(xbmc.Player):
if audio and len(self.getAvailableAudioStreams()) > 1: if audio and len(self.getAvailableAudioStreams()) > 1:
self.setAudioStream(audio - 1) self.setAudioStream(audio - 1)
if subtitle is None: if subtitle == -1 or subtitle is None:
self.showSubtitles(False)
return return
tracks = len(self.getAvailableAudioStreams()) tracks = len(self.getAvailableAudioStreams())
if subtitle == -1 or subtitle is None: if mapping:
self.showSubtitles(False)
elif mapping:
for index in mapping: for index in mapping:
if mapping[index] == subtitle: if mapping[index] == subtitle:
@ -390,61 +389,60 @@ class Player(xbmc.Player):
for file in self.played: for file in self.played:
item = self.get_file_info(file) item = self.get_file_info(file)
if item: window('emby.skip.%s.bool' % item['Id'], True)
window('emby.skip.%s.bool' % item['Id'], True)
if window('emby.external.bool'): if window('emby.external.bool'):
window('emby.external', clear=True) window('emby.external', clear=True)
if int(item['CurrentPosition']) == 1: if int(item['CurrentPosition']) == 1:
item['CurrentPosition'] = int(item['Runtime']) item['CurrentPosition'] = int(item['Runtime'])
data = { data = {
'ItemId': item['Id'], 'ItemId': item['Id'],
'MediaSourceId': item['MediaSourceId'], 'MediaSourceId': item['MediaSourceId'],
'PositionTicks': int(item['CurrentPosition'] * 10000000), 'PositionTicks': int(item['CurrentPosition'] * 10000000),
'PlaySessionId': item['PlaySessionId'] 'PlaySessionId': item['PlaySessionId']
} }
item['Server']['api'].session_stop(data) item['Server']['api'].session_stop(data)
if item.get('LiveStreamId'): if item.get('LiveStreamId'):
LOG.info("<[ livestream/%s ]", item['LiveStreamId']) LOG.info("<[ livestream/%s ]", item['LiveStreamId'])
item['Server']['api'].close_live_stream(item['LiveStreamId']) item['Server']['api'].close_live_stream(item['LiveStreamId'])
elif item['PlayMethod'] == 'Transcode': elif item['PlayMethod'] == 'Transcode':
LOG.info("<[ transcode/%s ]", item['Id']) LOG.info("<[ transcode/%s ]", item['Id'])
item['Server']['api'].close_transcode(item['DeviceId']) item['Server']['api'].close_transcode(item['DeviceId'])
path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8') path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')
if xbmcvfs.exists(path): if xbmcvfs.exists(path):
dirs, files = xbmcvfs.listdir(path) dirs, files = xbmcvfs.listdir(path)
for file in files: for file in files:
xbmcvfs.delete(os.path.join(path, file.decode('utf-8'))) xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))
result = item['Server']['api'].get_item(item['Id']) or {} result = item['Server']['api'].get_item(item['Id']) or {}
if 'UserData' in result and result['UserData']['Played']: if 'UserData' in result and result['UserData']['Played']:
delete = False
if result['Type'] == 'Episode' and settings('deleteTV.bool'):
delete = True
elif result['Type'] == 'Movie' and settings('deleteMovies.bool'):
delete = True
if not settings('offerDelete.bool'):
delete = False delete = False
if result['Type'] == 'Episode' and settings('deleteTV.bool'): if delete:
delete = True LOG.info("Offer delete option")
elif result['Type'] == 'Movie' and settings('deleteMovies.bool'):
delete = True
if not settings('offerDelete.bool'): if dialog("yesno", heading=_(30091), line1=_(33015), autoclose=120000):
delete = False item['Server']['api'].delete_item(item['Id'])
if delete: window('emby.external_check', clear=True)
LOG.info("Offer delete option")
if dialog("yesno", heading=_(30091), line1=_(33015), autoclose=120000):
item['Server']['api'].delete_item(item['Id'])
window('emby.external_check', clear=True)
self.played.clear() self.played.clear()