示例#1
0
    def action_request(self):
        """
        Action a Search request.
        """
        titles = API.match_search_term(self.str_input)
        # titles = [Title('The Martian', 2015, 'movie')]  # OMDb is down!!!
        self.build_response(titles)

        # set the message according to local rules
        if len(self.response.avail_titles) == 0 and len(self.response.unavail_titles) > 0:
            self.response.message = 'Unfortunately no titles matching your search are available to ' \
                                    'stream. You might want to set up an alert, or read the FAQs.'

        elif len(self.response.avail_titles) == 0 and len(self.response.unavail_titles) == 0:
            self.response.message = "We couldn't find any titles matching '%s'." % self.str_input

        elif len(self.response.avail_titles) > 0 and len(self.response.unavail_titles) == 0:
            self.response.message = 'Great! All titles matching your search are available to stream!'

        else:
            self.response.message = 'Great! Some titles matching your search are available to stream!'