def _start( self ):
     mpaa = audio = genre = movie = equivalent_mpaa = ""
     try:
         # create the playlist
         self.playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
         # Check to see if multiple features have been set in settings
         # if multiple features is greater than 1(not a single feature)
         # add the intermission videos and audio files for the 2, third, etc movies
         if self.playlistsize > 1:
             if int( _S_( "intermission_video") ) > 0 or _S_( "intermission_audio") or _S_( "intermission_ratings"):
                 mpaa, audio, genre, movie, equivalent_mpaa = self._add_intermission_videos()
         # otherwise just build for a single video
         else:
             mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = 0 )
         self._create_playlist( mpaa, audio, genre, movie, equivalent_mpaa )
         # play the trivia slide show
     except:
         traceback.print_exc()
예제 #2
0
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 _add_intermission_videos( self ):
     xbmc.log( "[script.cinema.experience] - Adding intermission Video(s)", level=xbmc.LOGNOTICE )
     count = 0
     index_count = 1
     for feature in range( 1, self.playlistsize ):
         mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( feature = index_count )
         #count = index_count
         # add intermission video
         if int( _S_( "intermission_video") ) > 0:
             xbmc.log( "[script.cinema.experience] - Inserting intermission Video(s): %s" % (0, 1, 1, 2, 3, 4, 5,)[ int( _S_( "intermission_video" ) ) ], level=xbmc.LOGNOTICE )
             xbmc.log( "[script.cinema.experience] -     playlist Position: %d" % index_count, level=xbmc.LOGDEBUG )
             p_size = xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size()
             xbmc.log( "[script.cinema.experience] -     p_size: %d" % p_size, level=xbmc.LOGDEBUG )
             _get_special_items(    playlist=self.playlist,
                                       items=( 0, 1, 1, 2, 3, 4, 5, )[ int( _S_( "intermission_video" ) ) ],
                                        path=( xbmc.translatePath( _S_( "intermission_video_file" ) ), xbmc.translatePath( _S_( "intermission_video_folder" ) ), )[ int( _S_( "intermission_video" ) ) > 1 ],
                                       genre=_L_( 32612 ),
                                      writer=_L_( 32612 ),
                                       index=index_count
                                )
             for count in range( 0, ( xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() - p_size ) ):
                 # Insert Intermission Label into Trigger List
                 self.trigger_list.insert( index_count, _L_( 32612 ) ) 
             if xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() > p_size and int( _S_( "intermission_video" ) ) > 1:
                 index_count += int( _S_( "intermission_video" ) ) - 1
             elif xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() > p_size and int( _S_( "intermission_video" ) ) == 1:
                 index_count += int( _S_( "intermission_video" ) )                 
         # get rating video
         if ( _S_( "enable_ratings" ) ) == "true"  and (_S_( "intermission_ratings") ) == "true":
             xbmc.log( "[script.cinema.experience] - Inserting Intermission Rating Video",level=xbmc.LOGNOTICE )
             xbmc.log( "[script.cinema.experience] -     playlist Position: %d" % index_count, level=xbmc.LOGDEBUG )
             p_size = xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size()
             xbmc.log( "[script.cinema.experience] -     p_size: %d" % p_size, level=xbmc.LOGDEBUG )
             _get_special_items(    playlist=self.playlist,
                                       items=1 * ( _S_( "rating_videos_folder" ) != "" ),
                                        path=xbmc.translatePath( _S_( "rating_videos_folder" ) ) + mpaa + ".avi",
                                       genre=_L_( 32603 ),
                                      writer=_L_( 32603 ),
                                      index = index_count
                                )
             for count in range( 0, ( xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() - p_size ) ):
                 # Insert Rating Label into Trigger List
                 self.trigger_list.insert( index_count, _L_( 32603 ) )
             if xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() > p_size:
                 index_count += 1
         # get Dolby/DTS videos
         if ( _S_( "enable_audio" ) ) == "true"  and (_S_( "intermission_audio") ) == "true":
             xbmc.log( "[script.cinema.experience] - Inserting Intermission Audio Format Video",level=xbmc.LOGNOTICE )
             xbmc.log( "[script.cinema.experience] -     playlist Position: %d" % index_count, level=xbmc.LOGDEBUG )
             p_size = xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size()
             xbmc.log( "[script.cinema.experience] -     p_size: %d" % p_size, level=xbmc.LOGDEBUG )
             _get_special_items(    playlist=self.playlist,
                                       items=1 * ( _S_( "audio_videos_folder" ) != "" ),
                                       path = xbmc.translatePath( _S_( "audio_videos_folder" ) ) + { "dca": "DTS", "ac3": "Dolby", "dtsma": "DTSHD-MA", "dtshd_ma": "DTSHD-MA", "a_truehd": "Dolby TrueHD", "truehd": "Dolby TrueHD" }.get( audio, "Other" ) + xbmc.translatePath( _S_( "audio_videos_folder" ) )[ -1 ],
                                       genre=_L_( 32606 ),
                                      writer=_L_( 32606 ),
                                      index = index_count
                                )
             for count in range( 0, ( xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() - p_size ) ):
                 # Insert Audio Format Label into Trigger List
                 self.trigger_list.insert( index_count, _L_( 32606 ) )
             if xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() > p_size:
                 index_count += 1
         index_count += 1
     # return info from first movie in playlist
     mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info( 0 )
     return mpaa, audio, genre, movie, equivalent_mpaa