def main_controller(slotvalue,slotname,id_slot_name,json_d,session_id,intent_filter,playlistid): ''' serch id of title in json from kodi library. if id is found get episodes/songs ids, stop kodi, insert playlist, (shuffle playlist), play. if id not found: search(). if search finds only one(search "big bang" find "the big bang theroy"): main_controller with slotvalue=search() return. if found multiple (search "iron" find "iron man 1, iron man 2..." keep session alive and add media_selected to custom_data. playlist size is limited to 20 items cause kodi keeps crashing while adding to much items slotvalue: the media title from snips e.g. Iron Man slotname: the name of the slot of the snips intent e.g. movies id_slot_name: the key value name of the media id from the kodi library json session_id: the snips session id intent_filter: the intents for new or keep alive snips sessions israndom: from snips if the media should played in random order e.g. hey snips play seinfeld in random order playlistid: the playlist id for kodi. 0=Music; 1=Movies; 2=Pictures ''' global playing_state_old ausgabe('main_controller',1) media_id_of_title_found = kodi.find_title_id(slotvalue,'label',id_slot_name,json_d) print("on défini si c'est une série ou un film") if media_id_of_title_found != 0: intent_filter="" print("media id trouvé dans la library kodi") if slotname =='shows': print("je cherche les épisodes") id_slot_name='episodeid' json_episodes = kodi.get_episodes_unseen(media_id_of_title_found) print("j'ai cherché les épisodes") if json_episodes['limits']['total'] != 0: id_tupel = build_tupel(json_episodes['episodes'], id_slot_name) print("j'ai trouvé des épisodes") else: return "aucun épisode trouvé" elif slotname=='movies': id_tupel = [media_id_of_title_found] playing_state_old = 0 #end_session(session_id, text="") if slotname =='shows': print("voila ce que j'ai trouvé") kodi_navigation_gui("shows") elif slotname == 'videos': kodi_navigation_gui("videos") kodi.insert_playlist(id_tupel,id_slot_name, playlistid) kodi.start_play(playlistid) else: titles = search(slotvalue,slotname,json_d) ausgabe(titles) if len(titles) == 1: end_session(session_id, text="") main_controller(titles[0],slotname,id_slot_name,json_d,session_id,intent_filter,playlistid) return elif len(titles) > 1: keep_session_alive(session_id,text="okay. C'est lequel?",intent_filter=intent_filter,customData="media_selected") return
def start_tv(): ausgabe("start_tv", 1) kodi.stop() kodi_navigation_gui("videoplaylist") showsid_tupel = build_tupel(kodi.get_tv_shows("tv"), "tvshowid") ausgabe(len(showsid_tupel)) #kodi.show_notification(len(showsid_tupel)+" Serien gefunden. Episoden werden gesucht") id_tupel = [] kodi.show_notification("Programm wird geladen") kodi.clear_playlist("1") json_data = kodi.get_tv_shows_episodeids(showsid_tupel) for item in json_data: if item['result']['limits']['total'] != 0: id_tupel_temp = build_tupel(item['result']['episodes'], "episodeid") shuffle(id_tupel_temp) id_tupel = id_tupel + [id_tupel_temp[0]] + [id_tupel_temp[1]] + [ id_tupel_temp[2] ] + [id_tupel_temp[3]] ausgabe(len(id_tupel)) shuffle(id_tupel) kodi.insert_playlist(id_tupel, 'episodeid', '1') kodi.start_play('1') return
def main_controller(slotvalue,slotname,id_slot_name,json_d,session_id,intent_filter,israndom,playlistid): ''' serch id of title in json from kodi library. if id is found get episodes/songs ids, stop kodi, insert playlist, (shuffle playlist), play. if id not found: search(). if search finds only one(search "big bang" find "the big bang theroy"): main_controller with slotvalue=search() return. if found multiple (search "iron" find "iron man 1, iron man 2..." keep session alive and add media_selected to custom_data. playlist size is limited to 20 items cause kodi keeps crashing while adding to much items slotvalue: the media title from snips e.g. Iron Man slotname: the name of the slot of the snips intent e.g. movies id_slot_name: the key value name of the media id from the kodi library json session_id: the snips session id intent_filter: the intents for new or keep alive snips sessions israndom: from snips if the media should played in random order e.g. hey snips play seinfeld in random order playlistid: the playlist id for kodi. 0=Music; 1=Movies; 2=Pictures ''' global playing_state_old ausgabe('main_controller',1) media_id_of_title_found = kodi.find_title_id(slotvalue,'label',id_slot_name,json_d) if media_id_of_title_found != 0: intent_filter="" if slotname =='shows': id_slot_name='episodeid' if str(israndom) == "random": json_episodes = kodi.get_episodes_all(media_id_of_title_found) else: json_episodes = kodi.get_episodes_unseen(media_id_of_title_found) if json_episodes['limits']['total'] != 0: id_tupel = build_tupel(json_episodes['episodes'], id_slot_name) else: start_session(session_type="notification", text="keine episoden gefunden") elif slotname=='movies': id_tupel = [media_id_of_title_found] elif slotname=='genre': json_songs = kodi.get_songs_by(id_slot_name,media_id_of_title_found) id_slot_name="songid" id_tupel = build_tupel(json_songs, id_slot_name) elif slotname=='artist': json_songs = kodi.get_songs_by(id_slot_name,media_id_of_title_found) id_slot_name="songid" id_tupel = build_tupel(json_songs, id_slot_name) elif slotname=='albums': json_songs = kodi.get_songs_by(id_slot_name,media_id_of_title_found) id_slot_name="songid" id_tupel = build_tupel(json_songs, id_slot_name) playing_state_old = 0 if israndom == "random": shuffle(id_tupel) end_session(session_id, text="") kodi.stop() kodi.insert_playlist(id_tupel,id_slot_name, playlistid) kodi.start_play(playlistid) else: titles = search(slotvalue,slotname,json_d) ausgabe(titles) if len(titles) == 1: end_session(session_id, text="") main_controller(titles[0],slotname,id_slot_name,json_d,session_id,intent_filter,israndom,playlistid) return keep_session_alive(session_id,text="",intent_filter=intent_filter,customData="media_selected") return