From 612bb418e7103ffe9b21c61855861df846b9c74f Mon Sep 17 00:00:00 2001 From: Bugatsinho Date: Thu, 5 Jul 2018 12:10:18 -0500 Subject: [PATCH] Add Subtitle option If torrent file contains its subtitle file Kodi Player loads it automatically! --- plugin.video.yatp/libs/client/actions.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugin.video.yatp/libs/client/actions.py b/plugin.video.yatp/libs/client/actions.py index bd3b3a0..be4891e 100644 --- a/plugin.video.yatp/libs/client/actions.py +++ b/plugin.video.yatp/libs/client/actions.py @@ -25,7 +25,24 @@ def _play(path): :return: """ plugin.log_notice('Path to play: {0}'.format(path)) - return plugin.resolve_url(path, succeeded=bool(path)) + try: + #check if torrent contains subtitle file. + import xbmc, urllib + d_dir = plugin.get_setting('download_dir') or xbmc.translatePath('special://temp') + srt = d_dir + urllib.unquote(path.split('stream/')[-1][:-3] + 'srt') + sub_file = os.path.join(d_dir, srt) + + #if subtitle exists, pass it to the play_item + if os.path.isfile(sub_file): + plugin.log_notice('Path to subtitle: {0}'.format(sub_file)) + set_subs = {'path': path, 'subtitles': [sub_file]} + return plugin.resolve_url(play_item=set_subs, succeeded=bool(path)) + else: + #if no subtitle + return plugin.resolve_url(path, succeeded=bool(path)) + + except: + pass @plugin.action()