From 53614c7b7874c68a58a9586203a7b5e56cef9737 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Fri, 19 Mar 2021 15:34:44 +0100 Subject: [PATCH] comments --- addon.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/addon.py b/addon.py index a8f6059..2d88a5e 100644 --- a/addon.py +++ b/addon.py @@ -115,32 +115,50 @@ def get_feature(movieid): # entry point if __name__ == '__main__': - movieid = xbmc.getInfoLabel('ListItem.DBID').decode('utf-8') cinematic_path = ADDON.getSettingString('cinematic_path') + # collect info about the selected feature movie + movieid = xbmc.getInfoLabel('ListItem.DBID').decode('utf-8') feature = get_feature(movieid) print(feature) + + # let user select one of the JSON programs programs = list_programs(cinematic_path) program_file = cinematic_path + show_dialog(programs) - program = conduct_program(program_file, feature) + # conduct and show playlist + program = conduct_program(program_file, feature) print('=== playlist') for entry in program: print(" * [%s] -- %s" % (entry['type'], entry['data'])) + # close modal movie information window if xbmc.getCondVisibility('Window.IsVisible(MovieInformation)'): xbmc.executebuiltin('Dialog.Close(MovieInformation)') - print('=== playing') + """ + TODO: this is not the intended way of playing back the conducted playlist. + hints for a better implementation are welcome. + the plan is to play each video file in the list separately, so the addon is + able to perform further tasks in between, like controlling home automation + systems. unfortunately, research has to be done in order to find out how + that should be implemented. + """ + + # build kodi style playlist playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() for entry in program: - print(" * [%s] -- %s" % (entry['type'], entry['data'])) if entry['type'] == 'video': playlist.add(entry['data']) else: + # it is planned to implement features other than video playback + # e. g. call scripts in home automation to dim the lights print(" unable to handle %s yet" % entry['type']) + + # start playback xbmc.Player().play(playlist) xbmc.sleep(500) + + # wait until program is finished while xbmc.getCondVisibility('Player.HasMedia'): xbmc.sleep(100) - print('=== done playing')