Ejemplo n.º 1
0
 def onPlayBackResumed(self):
     if xbmcgui.Window(10025).getProperty(
             "CinemaExperienceRunning") == "True":
         log('Playback Resumed')
         if ha_settings["ha_enable"]:
             Launch_automation().launch_automation(trigger="Resume",
                                                   prev_trigger="Paused",
                                                   mode="normal")
Ejemplo n.º 2
0
 def onNotification(self, sender, method, data):
     if sender == "xbmc":
         if xbmcgui.Window(10025).getProperty(
                 "CinemaExperienceRunning") == "True":
             if method.startswith("Player."):
                 if method == "Player.OnPause":
                     utils.log('Playback Paused')
                     if ha_settings["ha_enable"]:
                         Launch_automation().launch_automation(
                             trigger="Pause",
                             prev_trigger="Playing",
                             mode="normal")
                 elif method == "Player.OnPlay" and self.previous_method == "Player.OnPause":
                     utils.log('Playback Resumed')
                     if ha_settings["ha_enable"]:
                         Launch_automation().launch_automation(
                             trigger="Resume",
                             prev_trigger="Paused",
                             mode="normal")
                 elif method == "Player.OnStop":
                     utils.log("Playback Stopped")
                 elif method == "Player.OnPlay":
                     utils.log('Playback Started')
                 self.previous_method = method
Ejemplo n.º 3
0
             exit = Script().start_script("oldway")
         else:
             __addon__.openSettings()
             exit = True
     #xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, __language__( 32545 ), time_delay, image) )
     utils.log("messy_exit: %s" % exit, xbmc.LOGNOTICE)
     if exit:
         __addon__.setSetting(id='number_of_features',
                              value='%d' % (number_of_features - 1))
         xbmcgui.Window(10025).setProperty("CinemaExperienceRunning",
                                           "False")
         xbmcgui.Window(10025).setProperty("CinemaExperienceTriggered",
                                           "False")
     else:
         _clear_playlists()
         prev_trigger = Launch_automation().launch_automation(
             "Script End", None)  # Script End
         __addon__.setSetting(id='number_of_features',
                              value='%d' % (number_of_features - 1))
         xbmcgui.Window(10025).setProperty("CinemaExperienceRunning",
                                           "False")
         xbmcgui.Window(10025).setProperty("CinemaExperienceTriggered",
                                           "False")
 except:
     traceback.print_exc()
     # if script fails, changes settings back
     __addon__.setSetting(id='number_of_features',
                          value='%d' % (number_of_features - 1))
     prev_trigger = Launch_automation().launch_automation(
         "Script End", None)  # Script End
     xbmcgui.Window(10025).setProperty("CinemaExperienceRunning", "False")
     xbmcgui.Window(10025).setProperty("CinemaExperienceTriggered", "False")
Ejemplo n.º 4
0
 def start_script(self, library_view="oldway"):
     messy_exit = False
     log("Library_view: %s" % library_view, xbmc.LOGNOTICE)
     early_exit = False
     movie_next = False
     prev_trigger = None
     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 feature_settings["enable_notification"]:
             xbmc.executebuiltin(
                 "Notification( %s, %s, %d, %s)" %
                 (header, __language__(32546), 300000, image))
         # wait until playlist is full to the required number of features
         log(
             "Waiting for queue to be filled with %s Feature films" %
             number_of_features, xbmc.LOGNOTICE)
         count = 0
         while playlist.size() < number_of_features:
             if playlist.size() > count:
                 log(
                     "User queued %s of %s Feature films" %
                     (playlist.size(), number_of_features), xbmc.LOGNOTICE)
                 header1 = header + " - Feature " + "%d" % playlist.size()
                 message = __language__(32543) + playlist[
                     playlist.size() - 1].getdescription()
                 if feature_settings["enable_notification"]:
                     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
         log("User queued %s Feature films" % playlist.size(),
             xbmc.LOGNOTICE)
         if not early_exit:
             header1 = header + " - Feature " + "%d" % playlist.size()
             message = __language__(32543) + playlist[playlist.size() -
                                                      1].getdescription()
             if feature_settings["enable_notification"]:
                 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 feature_settings["enable_notification"]:
             xbmc.executebuiltin(
                 "Notification( %s, %s, %d, %s)" %
                 (header, __language__(32544), time_delay, image))
         _clear_playlists()
     else:
         mpaa, audio, genre, movie, equivalent_mpaa = _get_queued_video_info(
             feature=0)
         plist = _store_playlist()  # need to store movie playlist
         self._play_trivia(mpaa, genre, plist, equivalent_mpaa)
         mplaylist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
         mplaylist.clear()
         trigger_list = self.load_trigger_list()
         self.player.play(playlist)
         count = -1
         stop_check = 0
         paused = False
         # wait until fullscreen video is shown
         while not xbmc.getCondVisibility(
                 "Window.IsActive(fullscreenvideo)"):
             pass
         while not playlist.getposition() == (playlist.size() - 1):
             if playlist.getposition() > count:
                 try:
                     log(
                         "Item From Trigger List: %s" %
                         trigger_list[playlist.getposition()],
                         xbmc.LOGNOTICE)
                 except:
                     log("Problem With Trigger List", xbmc.LOGNOTICE)
                 log(
                     "Playlist Position: %s  Playlist Size: %s " %
                     ((playlist.getposition() + 1), (playlist.size())),
                     xbmc.LOGNOTICE)
                 if not playlist.getposition() == (playlist.size() - 1):
                     prev_trigger = Launch_automation().launch_automation(
                         trigger_list[playlist.getposition()], prev_trigger)
                     count = playlist.getposition()
                 else:
                     break  # Reached the last item in the playlist
             try:
                 #if not self.player.isPlayingVideo() and not is_paused:
                 if not xbmc.getCondVisibility(
                         "Window.IsActive(fullscreenvideo)"):
                     log("Video may have stopped", xbmc.LOGNOTICE)
                     xbmc.sleep(
                         5000
                     )  # wait 5 seconds for fullscreen video to show up(during playback)
                     if not xbmc.getCondVisibility(
                             "Window.IsActive(fullscreenvideo)"
                     ):  # if fullscreen video does not show up, break and exit script
                         messy_exit = True
                         break
             except:
                 if xbmc.getCondVisibility("Container.Content(movies)"):
                     log("Video Definitely Stopped", xbmc.LOGNOTICE)
                     messy_exit = True
                     break
         if not playlist.size(
         ) < 1 and not messy_exit:  # To catch an already running script when a new instance started
             log(
                 "Playlist Position: %s  Playlist Size: %s " %
                 (playlist.getposition() + 1, (playlist.size())),
                 xbmc.LOGNOTICE)
             prev_trigger = Launch_automation().launch_automation(
                 trigger_list[playlist.getposition()], prev_trigger)
             if trigger_list[playlist.getposition()] == "Movie":
                 log(
                     "Item From Trigger List: %s" %
                     trigger_list[playlist.getposition()], xbmc.LOGNOTICE)
             else:
                 log(
                     "Item From Trigger List: %s" %
                     trigger_list[playlist.getposition()], xbmc.LOGNOTICE)
             messy_exit = False
             xbmc.sleep(1000)
             self._wait_until_end()
         else:
             log("User might have pressed stop", xbmc.LOGNOTICE)
             log("Stopping Script", xbmc.LOGNOTICE)
             messy_exit = False
     return messy_exit
Ejemplo n.º 5
0
    def _play_trivia(self, mpaa, genre, plist, equivalent_mpaa):
        Launch_automation().launch_automation(
            triggers[0])  # Script Start - Or where it seems to be
        if trivia_settings["trivia_mode"] == 2:  # Start Movie Quiz Script
            log("Starting script.moviequiz", xbmc.LOGNOTICE)
            self.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
                    log("Loaded question module", xbmc.LOGNOTICE)
                except ImportError:
                    traceback.print_exc()
                    log("Failed to Load question module", xbmc.LOGNOTICE)
                except:
                    traceback.print_exc()
                try:
                    import quizlib.mq_ce_play as moviequiz
                    log("Loaded mq_ce_play module", xbmc.LOGNOTICE)
                except ImportError:
                    traceback.print_exc()
                    log("Failed to Load mq_ce_play module", xbmc.LOGNOTICE)
                except:
                    traceback.print_exc()

    #            pDialog.close()
                self.trivia_intro()
                if playlist.size() > 0:
                    self._wait_until_end()
                xbmc.sleep(500)  # wait .5 seconds
                xbmc.Player().stop()
                path = _MA_.getAddonInfo('path')
                question_type = 1
                mode = (True, False)[trivia_settings["trivia_moviequiz_mode"]]
                mpaa = (
                    trivia_settings["trivia_rating"],
                    equivalent_mpaa,
                )[trivia_settings["trivia_limit_query"]]
                question_limit = trivia_settings["trivia_moviequiz_qlimit"]
                completion = moviequiz.runCinemaExperience(
                    question_type, mode, mpaa, genre, question_limit)
                if completion:
                    log("Completed script.moviequiz", xbmc.LOGNOTICE)
                else:
                    log("Failed in script.moviequiz", xbmc.LOGNOTICE)
            except:
                traceback.print_exc()
                log("Failed to start script.moviequiz", xbmc.LOGNOTICE)
            _rebuild_playlist(plist)
            import xbmcscript_player as script
            script.Main()
            xbmc.executebuiltin("XBMC.ActivateWindow(fullscreenvideo)")
            #xbmc.sleep(500) # wait .5 seconds
            #xbmc.Player().play( playlist )
        elif trivia_settings["trivia_folder"] and trivia_settings[
                "trivia_mode"] == 1:  # Start Slide Show
            self.start_downloader(mpaa, genre, equivalent_mpaa)
            if not trivia_settings["trivia_music"] == 0:
                build_music_playlist()
            # set the proper mpaa rating user preference
            mpaa = (
                trivia_settings["trivia_rating"],
                equivalent_mpaa,
            )[trivia_settings["trivia_limit_query"]]
            log("Slide MPAA Rating: %s" % equivalent_mpaa, xbmc.LOGNOTICE)
            # import trivia module and execute the gui
            slide_playlist = _fetch_slides(equivalent_mpaa)
            self.trivia_intro()
            if playlist.size() > 0:
                Launch_automation().launch_automation(
                    triggers[1])  # Trivia Intro
                xbmc.sleep(500)  # wait .5 seconds
                self._wait_until_end()
            #xbmc.sleep(500) # wait .5 seconds
            xbmc.Player().stop()
            __builtin__.plist = plist
            __builtin__.slide_playlist = slide_playlist
            __builtin__.movie_mpaa = mpaa
            __builtin__.movie_genre = genre
            from xbmcscript_trivia import Trivia
            log("Starting Trivia script", xbmc.LOGNOTICE)
            Launch_automation().launch_automation(triggers[2])  # Trivia Start
            ui = Trivia("script-CExperience-trivia.xml",
                        __addon__.getAddonInfo('path'), "Default", "720p")
            ui.doModal()
            del ui
            # we need to activate the video window
            #xbmc.sleep(5) # wait .005 seconds
            xbmc.executebuiltin("XBMC.ActivateWindow(fullscreenvideo)")
            #xbmc.Player().play( playlist )
        elif trivia_settings["trivia_mode"] == 0:  # No Trivia
            # no trivia slide show so play the video
            self.start_downloader(mpaa, genre, equivalent_mpaa)
            _rebuild_playlist(plist)
            # play the video playlist
            import xbmcscript_player as script
            script.Main()
            xbmc.executebuiltin("XBMC.ActivateWindow(fullscreenvideo)")
            xbmc.sleep(500)  # wait .5 seconds
Ejemplo n.º 6
0
                                    (xbmcgui.getCurrentWindowId() - 10000, ))
                log(
                    "Action(Queue,%d)" %
                    (xbmcgui.getCurrentWindowId() - 10000, ), xbmc.LOGNOTICE)
                # we need to sleep so the video gets queued properly
                xbmc.sleep(500)
                exit = Script().start_script("oldway")
            else:
                __addon__.openSettings()
                exit = True
        #xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % (header, __language__( 32545 ), time_delay, image) )
        log("messy_exit: %s" % exit, xbmc.LOGNOTICE)
        if exit:
            pass
        else:
            _clear_playlists()
            prev_trigger = Launch_automation().launch_automation(
                triggers[16], None)  # Script End
            __addon__.setSetting(id='number_of_features',
                                 value='%d' % (number_of_features - 1))
            xbmcgui.Window(10025).setProperty("CinemaExperienceRunning",
                                              "False")
    except:
        traceback.print_exc()
        # if script fails, changes settings back
        __addon__.setSetting(id='number_of_features',
                             value='%d' % (number_of_features - 1))
        prev_trigger = Launch_automation().launch_automation(
            triggers[16], None)  # Script End
        xbmcgui.Window(10025).setProperty("CinemaExperienceRunning", "False")
Ejemplo n.º 7
0
 def start_script(self, library_view="oldway", original_autorefresh=0):
     messy_exit = False
     utils.log("Library_view: %s" % library_view, xbmc.LOGNOTICE)
     early_exit = False
     movie_next = False
     prev_trigger = None
     self.video_window = xbmcgui.WindowXML("script_CExperience-video.xml",
                                           __addon__.getAddonInfo('path'),
                                           "Default", "720p")
     self.video_window.show()
     autorefresh_movie = False
     self.autorefresh = original_autorefresh
     self.original_autorefresh = original_autorefresh
     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 extra_settings["enable_notification"]:
             xbmc.executebuiltin(
                 "Notification( %s, %s, %d, %s)" %
                 (header, __language__(32546), 300000, image))
         # wait until playlist is full to the required number of features
         utils.log(
             "Waiting for queue to be filled with %s Feature films" %
             number_of_features, xbmc.LOGNOTICE)
         count = 0
         while playlist.size() < number_of_features:
             if playlist.size() > count:
                 utils.log(
                     "User queued %s of %s Feature films" %
                     (playlist.size(), number_of_features), xbmc.LOGNOTICE)
                 header1 = header + " - Feature " + "%d" % playlist.size()
                 message = __language__(32543) + playlist[
                     playlist.size() - 1].getdescription()
                 if extra_settings["enable_notification"]:
                     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
         utils.log("User queued %s Feature films" % playlist.size(),
                   xbmc.LOGNOTICE)
         if not early_exit:
             header1 = header + " - Feature " + "%d" % playlist.size()
             message = __language__(32543) + playlist[playlist.size() -
                                                      1].getdescription()
             if extra_settings["enable_notification"]:
                 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 extra_settings["enable_notification"]:
             xbmc.executebuiltin(
                 "Notification( %s, %s, %d, %s)" %
                 (header, __language__(32544), time_delay, image))
         _clear_playlists()
     else:
         mpaa, audio, genre, movie, equivalent_mpaa, is_3d_movie = _get_queued_video_info(
             feature=0)
         plist = _store_playlist()  # need to store movie playlist
         self._play_trivia(mpaa, genre, plist, equivalent_mpaa)
         mplaylist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
         mplaylist.clear()
         jsonquery = '''{"jsonrpc": "2.0", "method": "Settings.SetSettingValue",  "params": { "setting": "screensaver.mode", "value": "None" }, "id": 1}'''
         jsonresponse = xbmc.executeJSONRPC(jsonquery)
         trigger_list = self.load_trigger_list()
         self.player.play(playlist)
         count = -1
         stop_check = 0
         paused = False
         # wait until fullscreen video is shown
         while not xbmc.getCondVisibility(
                 "Window.IsActive(fullscreenvideo)"):
             pass
         while (not playlist.getposition() == (playlist.size() - 1) or
                xbmcgui.Window(10025).getProperty("CinemaExperienceRunning")
                == "True"):
             if playlist.getposition() > count:
                 try:
                     utils.log(
                         "Item From Trigger List: %s" %
                         trigger_list[playlist.getposition()],
                         xbmc.LOGNOTICE)
                 except:
                     utils.log("Problem With Trigger List", xbmc.LOGNOTICE)
                 utils.log(
                     "Playlist Position: %s  Playlist Size: %s " %
                     ((playlist.getposition() + 1), (playlist.size())),
                     xbmc.LOGNOTICE)
                 if not playlist.getposition() == (playlist.size() - 1):
                     prev_trigger = Launch_automation().launch_automation(
                         trigger_list[playlist.getposition()], prev_trigger)
                     if trigger_list[playlist.getposition()] == "Movie":
                         if extra_settings["autorefresh"] and extra_settings[
                                 "autorefresh_movie"]:
                             self.auto_refresh("enable")
                             autorefresh_movie = True
                     else:
                         if extra_settings["autorefresh"]:
                             self.auto_refresh("disable")
                             autorefresh_movie = False
                     utils.log(
                         "[ script.cinema.experience ] - autorefresh_movie: %s"
                         % autorefresh_movie)
                     count = playlist.getposition()
                 else:
                     break  # Reached the last item in the playlist
             try:
                 #if not self.player.isPlayingVideo() and not is_paused:
                 if not xbmc.getCondVisibility(
                         "Window.IsActive(fullscreenvideo)"):
                     utils.log("Video may have stopped", xbmc.LOGNOTICE)
                     xbmc.sleep(
                         5000
                     )  # wait 5 seconds for fullscreen video to show up(during playback)
                     if not xbmc.getCondVisibility(
                             "Window.IsActive(fullscreenvideo)"
                     ):  # if fullscreen video does not show up, break and exit script
                         messy_exit = True
                         break
             except:
                 if xbmc.getCondVisibility("Container.Content(movies)"):
                     utils.log("Video Definitely Stopped", xbmc.LOGNOTICE)
                     messy_exit = True
                     break
         if not playlist.size(
         ) < 1 and not messy_exit:  # To catch an already running script when a new instance started
             utils.log(
                 "Playlist Position: %s  Playlist Size: %s " %
                 (playlist.getposition() + 1, (playlist.size())),
                 xbmc.LOGNOTICE)
             prev_trigger = Launch_automation().launch_automation(
                 trigger_list[playlist.getposition()], prev_trigger)
             if trigger_list[playlist.getposition()] == "Movie":
                 utils.log(
                     "Item From Trigger List: %s" %
                     trigger_list[playlist.getposition()], xbmc.LOGNOTICE)
                 if extra_settings["autorefresh"] and extra_setting[
                         "autorefresh_movie"]:
                     self.auto_refresh("enable")
                     autorefresh_movie = True
             else:
                 utils.log(
                     "Item From Trigger List: %s" %
                     trigger_list[playlist.getposition()], xbmc.LOGNOTICE)
                 if extra_settings["autorefresh"]:
                     self.auto_refresh("disable")
                     autorefresh_movie = False
             messy_exit = False
             xbmc.sleep(1000)
             self._wait_until_end()
             if extra_settings[
                     "autorefresh"] and self.original_autorefresh > 0:
                 self.auto_refresh("enable")
         else:
             if extra_settings[
                     "autorefresh"] and self.original_autorefresh > 0:
                 self.auto_refresh("enable")
             utils.log("User might have pressed stop", xbmc.LOGNOTICE)
             utils.log("Stopping Script", xbmc.LOGNOTICE)
             messy_exit = False
     return messy_exit