Esempio n. 1
0
    def onAVStarted(self):
        # type: () ->None
        """
            Detect when the player is playing something not initiated by this
            script. This can be due to a JSON RPC call or similar.Starting the
            player via keyboard or remote (that does not use JSON RPC)is
            detected by other means (onAction).

            Compare the movie that the player is playing versus what we expect
            it to play. If they don't match, then assume that something else
            launched the movie.

        :return:
        """
        try:
            # All local trailers played by Random Trailers will have a fake genre of
            # 'randomtrailers'. However, if a trailer is from a remote source
            # such that youtube plugin does the actual playing, then the
            # genre will NOT be set to 'randomtrailers'. The use of caching
            # of remote trailers will eliminate this issue.

            genre = self.getVideoInfoTag().getGenre()
            # self._logger.debug('genre:', genre)
            if genre != 'randomtrailers':
                playing_file = super().getPlayingFile()
                playing_file = playing_file
                if not (self._is_url and DiskUtils.is_url(playing_file)):
                    self._is_activated = False
                    if self._logger.isEnabledFor(LazyLogger.DEBUG):
                        self._logger.debug(
                            'Player is playing movie:', playing_file)
                    self.notify_non_random_trailer_video()
        except Exception as e:
            pass
    def is_more_discovery_needed(cls, movie: MovieType) -> bool:
        if movie[Movie.DISCOVERY_STATE] <= Movie.DISCOVERY_COMPLETE:
            return False

        more_discovery_needed = False
        title = movie[Movie.TITLE]
        try:
            normalized_trailer_path = movie.get(Movie.NORMALIZED_TRAILER)
            if normalized_trailer_path is None:
                normalized_trailer_path = ''
            cached_trailer_path = movie.get(Movie.CACHED_TRAILER)
            if cached_trailer_path is None:
                cached_trailer_path = ''

            if DiskUtils.is_url(movie.get(Movie.TRAILER, '')):
                # Remote Trailer

                if Settings.is_normalize_volume_of_downloaded_trailers():
                    try:
                        if not os.path.exists(normalized_trailer_path):
                            cls._logger.debug(
                                f'title: {title} does not exist: '
                                f'{normalized_trailer_path}')
                            movie[Movie.NORMALIZED_TRAILER] = None
                            more_discovery_needed = True
                    except Exception as e:
                        cls._logger.log_exception(e)

                elif Settings.is_use_trailer_cache():
                    try:
                        if not os.path.exists(cached_trailer_path):
                            cls._logger.debug(
                                f'title: {title} does not exist: '
                                f'{cached_trailer_path}')
                            movie[Movie.CACHED_TRAILER] = None
                            movie[Movie.NORMALIZED_TRAILER] = None
                            more_discovery_needed = True
                    except Exception as e:
                        cls._logger.log_exception(e)
            elif Settings.is_normalize_volume_of_local_trailers():
                # Local trailer
                try:
                    if not os.path.exists(normalized_trailer_path):
                        cls._logger.debug(f'title: {title} does not exist: '
                                          f'{normalized_trailer_path}')
                        movie[Movie.NORMALIZED_TRAILER] = None
                        more_discovery_needed = True
                except Exception as e:
                    cls._logger.log_exception(e)

        except Exception as e:
            cls._logger.log_exception()

        if more_discovery_needed:
            movie[Movie.DISCOVERY_STATE] = Movie.DISCOVERY_COMPLETE
            cls._logger.debug(f'More discovery needed: {title}')

        return more_discovery_needed
Esempio n. 3
0
    def set_playing_file_path(self, file_path):
        # type: (str) -> None
        """

        :param file_path:
        :return:
        """
        file_path = file_path
        self._is_url = DiskUtils.is_url(file_path)
        self._expected_file_path = file_path