def start_script( library_view = "oldway" ): messy_exit = False xbmc.log( "[ script.cinema.experience ] - Library_view: %s" % library_view, level=xbmc.LOGNOTICE ) # turn off autorefresh early_exit = False autorefresh_movie = False movie_next = False prev_trigger = None auto_refresh( autorefresh, "disable" ) if library_view != "oldway": xbmc.executebuiltin( "ActivateWindow(videolibrary,%s,return)" % library_view ) # wait until Video Library shows while not xbmc.getCondVisibility( "Container.Content(movies)" ): pass if _S_( "enable_notification" ) == "true": xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32546 ), 300000, image) ) # wait until playlist is full to the required number of features xbmc.log( "[ script.cinema.experience ] - Waiting for queue to be filled with %s Feature films" % number_of_features, level=xbmc.LOGNOTICE ) count = 0 while playlist.size() < number_of_features: if playlist.size() > count: xbmc.log( "[ script.cinema.experience ] - User queued %s of %s Feature films" % (playlist.size(), number_of_features), level=xbmc.LOGNOTICE ) header1 = header + " - Feature " + "%d" % playlist.size() message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription() if _S_( "enable_notification" ) == "true": xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) ) count = playlist.size() xbmc.sleep(time_delay*2) if not xbmc.getCondVisibility( "Container.Content(movies)" ): early_exit = True break xbmc.log( "[ script.cinema.experience ] - User queued %s Feature films" % playlist.size(), level=xbmc.LOGNOTICE ) if not early_exit: header1 = header + " - Feature " + "%d" % playlist.size() message = _L_( 32543 ) + playlist[playlist.size() -1].getdescription() if _S_( "enable_notification" ) == "true": xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header1, message, time_delay, image) ) early_exit = False # If for some reason the limit does not get reached and the window changed, cancel script if playlist.size() < number_of_features and library_view != "oldway": if _S_( "enable_notification" ) == "true": xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, _L_( 32544 ), time_delay, image) ) _clear_playlists() else: mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = 0 ) voxcommando() plist = _store_playlist() # need to store movie playlist _play_trivia( mpaa, genre, plist, equivalent_mpaa ) _clear_playlists( "music" ) trigger_list = _load_trigger_list() count = -1 stop_check = 0 paused = False # prelim programming for adding - Activate script and other additions while not playlist.getposition() == ( playlist.size() - 1 ): try: pauseCheck = xbmc.Player().getTime() xbmc.sleep( int( ce_pause_time * 1000 ) ) if xbmc.Player().isPlayingVideo(): stop_check = 0 if ( xbmc.Player().getTime() == pauseCheck ) and not paused: prev_trigger = activate_ha( _L_( 32618 ), prev_trigger ) paused = True elif not ( xbmc.Player().getTime() == pauseCheck ) and paused: prev_trigger = activate_ha( _L_( 32619 ), prev_trigger ) paused = False else: pass elif not xbmc.Player().isPlayingVideo(): xbmc.log( "[ script.cinema.experience ] - Video may have stopped", level=xbmc.LOGNOTICE ) except: if xbmc.getCondVisibility( "Container.Content(movies)" ): xbmc.log( "[ script.cinema.experience ] - Video Definitely Stopped", level=xbmc.LOGNOTICE ) messy_exit = True break #if stop_check == 60: # xbmc.log( "[ script.cinema.experience ] - Video Definitely Stopped", level=xbmc.LOGNOTICE ) # messy_exit = True # break #else: # xbmc.sleep( 1000 ) # stop_check += 1 if playlist.getposition() > count: try: xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE ) except: xbmc.log( "[ script.cinema.experience ] - Problem With Trigger List", level=xbmc.LOGNOTICE ) xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( ( playlist.getposition() + 1 ), ( playlist.size() ) ), level=xbmc.LOGNOTICE ) if not playlist.getposition() == ( playlist.size() - 1 ): prev_trigger = activate_ha( trigger_list[ playlist.getposition() ], prev_trigger ) if trigger_list[ playlist.getposition() ] == "Movie": if _S_( "autorefresh" ) == "true" and _S_( "autorefresh_movie" ) == "true": auto_refresh( autorefresh, "enable" ) autorefresh_movie = True else: if autorefresh_movie: auto_refresh( autorefresh, "disable" ) autorefresh_movie = False xbmc.log( "[ script.cinema.experience ] - autorefresh_movie: %s" % autorefresh_movie, level=xbmc.LOGNOTICE ) count = playlist.getposition() else: break # Reached the last item in the playlist if not playlist.size() < 1 and not messy_exit: # To catch an already running script when a new instance started xbmc.log( "[ script.cinema.experience ] - Playlist Position: %s Playlist Size: %s " % ( playlist.getposition() + 1, ( playlist.size() ) ), level=xbmc.LOGNOTICE ) prev_trigger = activate_ha( trigger_list[ playlist.getposition() ], prev_trigger, "normal" ) if trigger_list[ playlist.getposition() ] == "Movie": xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE ) if _S_( "autorefresh" ) == "true" and _S_( "autorefresh_movie" ) == "true": auto_refresh( autorefresh, "enable" ) autorefresh_movie = True else: xbmc.log( "[ script.cinema.experience ] - Item From Trigger List: %s" % trigger_list[ playlist.getposition() ], level=xbmc.LOGNOTICE ) if autorefresh_movie: auto_refresh( autorefresh, "disable" ) autorefresh_movie == False messy_exit = False _wait_until_end() else: xbmc.log( "[ script.cinema.experience ] - User might have pressed stop", level=xbmc.LOGNOTICE ) xbmc.log( "[ script.cinema.experience ] - Stopping Script", level=xbmc.LOGNOTICE ) messy_exit = False return messy_exit
def _play_trivia( mpaa, genre, plist, equivalent_mpaa ): activate_ha( _L_( 32613 ) ) # Script Start - Or where it seems to be # if trivia path and time to play the trivia slides pDialog = xbmcgui.DialogProgress() pDialog.create( __script__, _L_( 32520 ) ) pDialog.update( 0 ) if int( _S_( "trivia_mode" ) ) == 2: # Start Movie Quiz Script xbmc.log( "[ script.cinema.experience ] - Starting script.moviequiz", level=xbmc.LOGNOTICE ) start_downloader( mpaa, genre, equivalent_mpaa ) try: _MA_= xbmcaddon.Addon( "script.moviequiz" ) BASE_MOVIEQUIZ_PATH = xbmc.translatePath( _MA_.getAddonInfo('path') ) sys.path.append( BASE_MOVIEQUIZ_PATH ) try: import quizlib.question as question xbmc.log( "[ script.cinema.experience ] - Loaded question module", level=xbmc.LOGNOTICE ) except ImportError: traceback.print_exc() xbmc.log( "[ script.cinema.experience ] - Failed to Load question module", level=xbmc.LOGNOTICE ) except: traceback.print_exc() try: import quizlib.mq_ce_play as moviequiz xbmc.log( "[ script.cinema.experience ] - Loaded mq_ce_play module", level=xbmc.LOGNOTICE ) except ImportError: traceback.print_exc() xbmc.log( "[ script.cinema.experience ] - Failed to Load mq_ce_play module", level=xbmc.LOGNOTICE ) except: traceback.print_exc() pDialog.close() activate_ha( _L_( 32613 ) ) # Script Start - Or where it seems to be trivia_intro() if playlist.size() > 0: _wait_until_end() xbmc.sleep(500) # wait .5 seconds path = _MA_.getAddonInfo('path') question_type = 1 mode = ( True, False )[int( _S_( "trivia_moviequiz_mode" ) ) ] mpaa = ( _S_( "trivia_rating" ), equivalent_mpaa, )[ _S_( "trivia_limit_query" ) == "true" ] question_limit = int( float( _S_( "trivia_moviequiz_qlimit" ) ) ) completion = moviequiz.runCinemaExperience( question_type, mode, mpaa, genre, question_limit ) if completion: xbmc.log( "[ script.cinema.experience ] - Completed script.moviequiz", level=xbmc.LOGNOTICE ) else: xbmc.log( "[ script.cinema.experience ] - Failed in script.moviequiz", level=xbmc.LOGNOTICE ) except: traceback.print_exc() xbmc.log( "[ script.cinema.experience ] - Failed to start script.moviequiz", level=xbmc.LOGNOTICE ) _rebuild_playlist( plist ) import xbmcscript_player as script script.Main() xbmc.sleep(500) # wait .5 seconds xbmc.Player().play( playlist ) elif _S_( "trivia_folder" ) and int( _S_( "trivia_mode" ) ) == 1: # Start Slide Show start_downloader( mpaa, genre, equivalent_mpaa ) ## update dialog with new message pDialog.update( -1, _L_( 32510 ) ) # trivia settings, grab them here so we don't need another _S_() object if not int( _S_( "trivia_music" ) )== 0: pDialog.update( -1, _L_( 32511 ) ) build_music_playlist() # set the proper mpaa rating user preference mpaa = ( _S_( "trivia_rating" ), equivalent_mpaa, )[ _S_( "trivia_limit_query" ) == "true" ] xbmc.log( "[ script.cinema.experience ] - Slide MPAA Rating: %s" % equivalent_mpaa, level=xbmc.LOGNOTICE ) # import trivia module and execute the gui pDialog.update( 50 ) slide_playlist = _fetch_slides( equivalent_mpaa ) pDialog.close() trivia_intro() if playlist.size() > 0: activate_ha( _L_( 32609 ) ) # Trivia Intro _wait_until_end() xbmc.sleep(1500) # wait 1.5 seconds from xbmcscript_trivia import Trivia xbmc.log( "[ script.cinema.experience ] - Starting Trivia script", level=xbmc.LOGNOTICE ) activate_ha( _L_( 32615 ) ) # Trivia Start __builtin__.plist = plist __builtin__.slide_playlist = slide_playlist __builtin__.movie_mpaa = mpaa __builtin__.movie_genre = genre ui = Trivia( "script-CExperience-trivia.xml", _A_.getAddonInfo('path'), "default", "720p" ) ui.doModal() del ui # we need to activate the video window xbmc.sleep(500) # wait .5 seconds xbmc.executebuiltin( "XBMC.ActivateWindow(2005)" ) xbmc.Player().play( playlist ) elif int( _S_( "trivia_mode" ) ) == 0: # No Trivia # no trivia slide show so play the video pDialog.close() start_downloader( mpaa, genre, equivalent_mpaa ) _rebuild_playlist( plist ) # play the video playlist import xbmcscript_player as script script.Main() activate_ha( _L_( 32613 ) ) # Script Start - Or where it seems to be xbmc.sleep(500) # wait .5 seconds xbmc.Player().play( playlist )