Exemple #1
0
    def lookup(self, entry, search_allowed=True, key=None):
        """
        Perform Rotten Tomatoes lookup for entry.

        :param entry: Entry instance
        :param search_allowed: Allow fallback to search
        :param key: optionally specify an API key to use
        :raises PluginError: Failure reason
        """
        if not key:
            key = self.key or plugin_api_rottentomatoes.API_KEY
        movie = plugin_api_rottentomatoes.lookup_movie(
            smart_match=entry['title'],
            rottentomatoes_id=entry.get('rt_id', eval_lazy=False),
            only_cached=(not search_allowed),
            api_key=key,
        )
        log.debug(u'Got movie: %s' % movie)
        entry.update_using_map(self.field_map, movie)

        if not entry.get('imdb_id', eval_lazy=False):
            for alt_id in movie.alternate_ids:
                if alt_id.name == 'imdb':
                    entry['imdb_id'] = 'tt' + alt_id.id
                    break
    def lookup(self, entry, search_allowed=True, key=None):
        """
        Perform Rotten Tomatoes lookup for entry.

        :param entry: Entry instance
        :param search_allowed: Allow fallback to search
        :param key: optionally specify an API key to use
        :raises PluginError: Failure reason
        """
        if not key:
            key = self.key or API_KEY
        movie = lookup_movie(smart_match=entry['title'],
                             rottentomatoes_id=entry.get('rt_id', eval_lazy=False),
                             only_cached=(not search_allowed),
                             api_key=key
                             )
        log.debug(u'Got movie: %s' % movie)
        entry.update_using_map(self.field_map, movie)

        if not entry.get('imdb_id', eval_lazy=False):
            for alt_id in movie.alternate_ids:
                if alt_id.name == 'imdb':
                    entry['imdb_id'] = 'tt' + alt_id.id
                    break