diff --git a/addon.py b/addon.py index f1e0e0a..d2c216e 100644 --- a/addon.py +++ b/addon.py @@ -12,6 +12,7 @@ ADDON = xbmcaddon.Addon() CWD = ADDON.getAddonInfo('path').decode('utf-8') #CWD = ADDON.getAddonInfo('path') # for kodi 19 +# reads program names from JSON files and returns a dict def list_programs(cinematic_path): dirs, files = xbmcvfs.listdir(cinematic_path) programs = {} @@ -24,6 +25,7 @@ def list_programs(cinematic_path): programs[program_data['name']] = filename return programs +# shows the selection dialog with program names, returns JSON filename def show_dialog(programs): entries = programs.keys() dialog = xbmcgui.Dialog() @@ -31,6 +33,7 @@ def show_dialog(programs): del dialog return programs[entries[ret]] +# get a number of random files from a directory def files_from_dir(count, location): dirs, files = xbmcvfs.listdir(location) files = random.sample(files, count) @@ -38,6 +41,7 @@ def files_from_dir(count, location): files[i] = location + files[i] return files +# reads the JSON file and conducts a pre-program for the feature movie def conduct_program(program_file, feature): filehandle = xbmcvfs.File(program_file) program_json = filehandle.read() @@ -91,6 +95,7 @@ def conduct_program(program_file, feature): program.append(entry) return program +# fetches information on the feature movie def get_feature(movieid): query = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"movieid": %s, "properties": ["file", "mpaa", "uniqueid"]}, "id": "1"}' % movieid json_response = xbmc.executeJSONRPC(query) @@ -108,10 +113,13 @@ def get_feature(movieid): } return feature +# entry point if __name__ == '__main__': if (sys.argv[1] == 'experience'): + # addon is called like the experience plugin (Estuary skin does that) movieid = xbmc.getInfoLabel('ListItem.DBID').decode('utf-8') else: + # addon is called like CinemaVision plugin (Aeon Nox does that) for arg in sys.argv[1:]: (name, value) = arg.split('=') if name == 'dbid':