示例#1
0
    def __init__(self, defaultFilters):
        """
        WhatTagLineBelongsToMovieQuestion
        """
        super(WhatTagLineBelongsToMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(['title', 'tagline', 'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item['tagline']:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No movies found')
        self.addCorrectAnswer(id=movie['movieid'], text=movie['tagline'])

        otherMovies = library.getMovies(['tagline']).withFilters(defaultFilters).excludeTitles(movie['title']).limitTo(
            10).asList()
        for otherMovie in otherMovies:
            if not otherMovie['tagline']:
                continue

            self.addAnswer(id=otherMovie['movieid'], text=otherMovie['tagline'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_TAGLINE_BELONGS_TO_MOVIE, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#2
0
    def __init__(self, defaultFilters):
        """
        WhatTagLineBelongsToMovieQuestion
        """
        super(WhatTagLineBelongsToMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(['title', 'tagline', 'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item['tagline']:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No movies found')
        self.addCorrectAnswer(id=movie['movieid'], text=movie['tagline'])

        otherMovies = library.getMovies(['tagline']).withFilters(defaultFilters).excludeTitles(movie['title']).limitTo(
            10).asList()
        for otherMovie in otherMovies:
            if not otherMovie['tagline']:
                continue

            self.addAnswer(id=otherMovie['movieid'], text=otherMovie['tagline'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_TAGLINE_BELONGS_TO_MOVIE, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#3
0
    def __init__(self, defaultFilters):
        """
        WhatQuoteIsThisFrom
        """
        quoteDisplayType = QuoteDisplayType()
        super(WhatMovieIsThisQuoteFrom, self).__init__(quoteDisplayType)

        quoteText = None
        row = None
        for item in library.getMovies(['title', 'art']).withFilters(defaultFilters).limitTo(10).asList():
            quoteText = IMDB.getRandomQuote(item['title'], maxLength=128)

            if quoteText is not None:
                row = item
                break

        if quoteText is None:
            raise QuestionException('Did not find any quotes')

        self.addCorrectAnswer(row['movieid'], row['title'], image=row['art']['poster'])

        theRest = library.getMovies(['title', 'art']).withFilters(defaultFilters).excludeTitles(
            self.getAnswerTexts()).limitTo(3).asList()
        for movie in theRest:
            self.addAnswer(movie['movieid'], movie['title'], image=movie['art']['poster'])

        random.shuffle(self.answers)
        quoteDisplayType.setQuoteText(quoteText)
        self.text = strings(Q_WHAT_MOVIE_IS_THIS_QUOTE_FROM)
示例#4
0
    def __init__(self, defaultFilters):
        """
        WhatMovieIsNewestQuestion
        """
        super(WhatMovieIsNewestQuestion, self).__init__()

        movie = (
            library.getMovies(["title", "year", "art"]).withFilters(defaultFilters).fromYear(1900).limitTo(1).asItem()
        )
        if not movie:
            raise QuestionException("No movies found")

        self.addCorrectAnswer(id=movie["movieid"], text=movie["title"], image=movie["art"]["poster"])

        otherMovies = (
            library.getMovies(["title", "art"])
            .withFilters(defaultFilters)
            .fromYear(1900)
            .toYear(movie["year"])
            .limitTo(3)
            .asList()
        )
        if len(otherMovies) < 3:
            raise QuestionException("Less than 3 movies found; bailing out")

        for otherMovie in otherMovies:
            self.addAnswer(otherMovie["movieid"], otherMovie["title"], image=otherMovie["art"]["poster"])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_THE_NEWEST)
示例#5
0
    def __init__(self, defaultFilters):
        """
        WhatQuoteIsThisFrom
        """
        quoteDisplayType = QuoteDisplayType()
        super(WhatMovieIsThisQuoteFrom, self).__init__(quoteDisplayType)

        quoteText = None
        row = None
        for item in library.getMovies(['title', 'art']).withFilters(defaultFilters).limitTo(10).asList():
            quoteText = IMDB.getRandomQuote(item['title'], maxLength=128)

            if quoteText is not None:
                row = item
                break

        if quoteText is None:
            raise QuestionException('Did not find any quotes')

        self.addCorrectAnswer(row['movieid'], row['title'], image=row['art']['poster'])

        theRest = library.getMovies(['title', 'art']).withFilters(defaultFilters).excludeTitles(
            self.getAnswerTexts()).limitTo(3).asList()
        for movie in theRest:
            self.addAnswer(movie['movieid'], movie['title'], image=movie['art']['poster'])

        random.shuffle(self.answers)
        quoteDisplayType.setQuoteText(quoteText)
        self.text = strings(Q_WHAT_MOVIE_IS_THIS_QUOTE_FROM)
示例#6
0
    def __init__(self, defaultFilters):
        """
        WhatMovieIsNewestQuestion
        """
        super(WhatMovieIsNewestQuestion, self).__init__()

        movie = library.getMovies([
            'title', 'year', 'art'
        ]).withFilters(defaultFilters).fromYear(1900).limitTo(1).asItem()
        if not movie:
            raise QuestionException('No movies found')

        self.addCorrectAnswer(id=movie['movieid'],
                              text=movie['title'],
                              image=movie['art']['poster'])

        otherMovies = library.getMovies(
            ['title',
             'art']).withFilters(defaultFilters).fromYear(1900).toYear(
                 movie['year']).limitTo(3).asList()
        if len(otherMovies) < 3:
            raise QuestionException("Less than 3 movies found; bailing out")

        for otherMovie in otherMovies:
            self.addAnswer(otherMovie['movieid'],
                           otherMovie['title'],
                           image=otherMovie['art']['poster'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_THE_NEWEST)
示例#7
0
    def __init__(self, defaultFilters):
        """
        What movie is this?
        """
        videoDisplayType = VideoDisplayType()
        super(WhatMovieIsThisQuestion, self).__init__(videoDisplayType)

        correctAnswer = library.getMovies(
            ['title', 'set', 'genre', 'file', 'resume',
             'art']).withFilters(defaultFilters).limitTo(1).asItem()
        if not correctAnswer:
            raise QuestionException('No movies found')

        self.addCorrectAnswer(id=correctAnswer['movieid'],
                              text=correctAnswer['title'],
                              image=correctAnswer['art']['poster'])

        # Find other movies in set
        if correctAnswer['set'] is not None:
            otherMoviesInSet = library.getMovies(
                ['title', 'art']).withFilters(defaultFilters).inSet(
                    correctAnswer['set']).excludeTitles(
                        self.getAnswerTexts()).limitTo(3).asList()
            for movie in otherMoviesInSet:
                self.addAnswer(id=movie['movieid'],
                               text=movie['title'],
                               image=movie['art']['poster'])

        # Find other movies in genre
        if len(self.answers) < 4:
            otherMoviesInGenre = library.getMovies([
                'title', 'art'
            ]).withFilters(defaultFilters).inGenre(
                correctAnswer['genre']).excludeTitles(
                    self.getAnswerTexts()).limitTo(4 -
                                                   len(self.answers)).asList()
            for movie in otherMoviesInGenre:
                self.addAnswer(id=movie['movieid'],
                               text=movie['title'],
                               image=movie['art']['poster'])

        # Fill with random movies
        if len(self.answers) < 4:
            theRest = library.getMovies([
                'title', 'art'
            ]).withFilters(defaultFilters).excludeTitles(
                self.getAnswerTexts()).limitTo(4 - len(self.answers)).asList()
            for movie in theRest:
                self.addAnswer(id=movie['movieid'],
                               text=movie['title'],
                               image=movie['art']['poster'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_THIS)
        videoDisplayType.setVideoFile(correctAnswer['file'],
                                      correctAnswer['resume']['position'])
示例#8
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsInTheseMoviesQuestion
        """
        threePhotoDisplayType = ThreePhotoDisplayType()
        super(WhatActorIsInTheseMoviesQuestion, self).__init__(threePhotoDisplayType)

        # Find a bunch of actors
        actors = list()
        items = library.getMovies(['title', 'cast']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            actors.extend(iter(item['cast']))

        # Find one that has at least three movies
        movies = None
        actor = None
        for actor in actors:
            if not 'thumbnail' in actor:
                continue
            movies = library.getMovies(['title', 'art']).withFilters(defaultFilters).withActor(actor['name']).limitTo(
                3).asList()

            if len(movies) >= 3:
                break

        if len(movies) < 3:
            raise QuestionException("Didn't find an actor with at least three movies")

        # Setup the display with three movies
        for movie in movies:
            threePhotoDisplayType.addPhoto(movie['art']['poster'], movie['title'])

        # Find movie without actor
        otherMovie = library.getMovies(['title', 'art']).withFilters(defaultFilters).withoutActor(
            actor['name']).limitTo(1).asItem()
        if not otherMovie:
            raise QuestionException('No movie found')
        self.addCorrectAnswer(actor['name'], actor['title'], image=actor['thumbnail'])

        # Find another bunch of actors
        actors = list()
        items = library.getMovies(['title', 'cast']).withFilters(defaultFilters).withoutActor(actor['name']).limitTo(
            10).asList()
        for item in items:
            actors.extend(iter(item['cast']))

        random.shuffle(actors)
        for actor in actors:
            if not 'thumbnail' in actor:
                continue
            self.addAnswer(-1, actor['name'], image=actor['thumbnail'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_IN_THESE_MOVIES)
示例#9
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsInTheseMoviesQuestion
        """
        threePhotoDisplayType = ThreePhotoDisplayType()
        super(WhatActorIsInTheseMoviesQuestion, self).__init__(threePhotoDisplayType)

        # Find a bunch of actors
        actors = list()
        items = library.getMovies(['title', 'cast']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            actors.extend(iter(item['cast']))

        # Find one that has at least three movies
        movies = None
        actor = None
        for actor in actors:
            if not 'thumbnail' in actor:
                continue
            movies = library.getMovies(['title', 'art']).withFilters(defaultFilters).withActor(actor['name']).limitTo(
                3).asList()

            if len(movies) >= 3:
                break

        if len(movies) < 3:
            raise QuestionException("Didn't find an actor with at least three movies")

        # Setup the display with three movies
        for movie in movies:
            threePhotoDisplayType.addPhoto(movie['art']['poster'], movie['title'])

        # Find movie without actor
        otherMovie = library.getMovies(['title', 'art']).withFilters(defaultFilters).withoutActor(
            actor['name']).limitTo(1).asItem()
        if not otherMovie:
            raise QuestionException('No movie found')
        self.addCorrectAnswer(actor['name'], actor['title'], image=actor['thumbnail'])

        # Find another bunch of actors
        actors = list()
        items = library.getMovies(['title', 'cast']).withFilters(defaultFilters).withoutActor(actor['name']).limitTo(
            10).asList()
        for item in items:
            actors.extend(iter(item['cast']))

        random.shuffle(actors)
        for actor in actors:
            if not 'thumbnail' in actor:
                continue
            self.addAnswer(-1, actor['name'], image=actor['thumbnail'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_IN_THESE_MOVIES)
示例#10
0
    def __init__(self, defaultFilters):
        """
        Actor not in movie?
        """
        photoDisplayType = PhotoDisplayType()
        super(ActorNotInMovieQuestion, self).__init__(photoDisplayType)

        actors = list()
        for movie in library.getMovies(["cast"]).withFilters(defaultFilters).limitTo(10).asList():
            for actor in movie["cast"]:
                if "thubmnail" in actor:
                    actors.append(actor)

        if not actors:
            raise QuestionException("Didn't find any actors with thumbnail")

        random.shuffle(actors)

        actor = None
        for actor in actors:
            # Movie actor is in
            movies = (
                library.getMovies(["title", "art"])
                .withFilters(defaultFilters)
                .withActor(actor["name"])
                .limitTo(3)
                .asList()
            )
            if len(movies) < 3:
                continue

            for movie in movies:
                self.addAnswer(-1, movie["title"], image=movie["art"]["poster"])

            # Movies actor is not in
            correctAnswer = (
                library.getMovies(["title", "art"])
                .withFilters(defaultFilters)
                .withoutActor(actor["name"])
                .limitTo(1)
                .asItem()
            )
            if not correctAnswer:
                raise QuestionException("No movies found")
            self.addCorrectAnswer(actor["name"], correctAnswer["title"], image=correctAnswer["art"]["poster"])

            break

        if not self.answers:
            raise QuestionException("Didn't find any actors with at least three movies")

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_ACTOR_NOT_IN, actor["name"])
        photoDisplayType.setPhotoFile(actor["thumbnail"])
示例#11
0
    def __init__(self, defaultFilters):
        """
        Actor not in movie?
        """
        photoDisplayType = PhotoDisplayType()
        super(ActorNotInMovieQuestion, self).__init__(photoDisplayType)

        actors = list()
        for movie in library.getMovies(
            ['cast']).withFilters(defaultFilters).limitTo(10).asList():
            for actor in movie['cast']:
                if 'thubmnail' in actor:
                    actors.append(actor)

        if not actors:
            raise QuestionException("Didn't find any actors with thumbnail")

        random.shuffle(actors)

        actor = None
        for actor in actors:
            # Movie actor is in
            movies = library.getMovies(
                ['title', 'art']).withFilters(defaultFilters).withActor(
                    actor['name']).limitTo(3).asList()
            if len(movies) < 3:
                continue

            for movie in movies:
                self.addAnswer(-1,
                               movie['title'],
                               image=movie['art']['poster'])

            # Movies actor is not in
            correctAnswer = library.getMovies(
                ['title', 'art']).withFilters(defaultFilters).withoutActor(
                    actor['name']).limitTo(1).asItem()
            if not correctAnswer:
                raise QuestionException('No movies found')
            self.addCorrectAnswer(actor['name'],
                                  correctAnswer['title'],
                                  image=correctAnswer['art']['poster'])

            break

        if not self.answers:
            raise QuestionException(
                "Didn't find any actors with at least three movies")

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_ACTOR_NOT_IN, actor['name'])
        photoDisplayType.setPhotoFile(actor['thumbnail'])
示例#12
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsInMovieBesidesOtherActorQuestion
        """
        super(WhatActorIsInMovieBesidesOtherActorQuestion, self).__init__()

        # Find a bunch of movies
        items = library.getMovies(
            ['title', 'cast',
             'art']).withFilters(defaultFilters).limitTo(10).asList()
        movie = None
        for item in items:
            if len(item['cast']) >= 2:
                movie = item
                break

        if not movie:
            raise QuestionException('No movies with two actors found')

        actors = movie['cast']
        random.shuffle(actors)
        actorOne = actors[0]
        actorTwo = actors[1]
        self.addCorrectAnswer(actorOne['name'],
                              actorOne['name'],
                              image=actorOne['thumbnail'])

        # Find another bunch of actors
        otherActors = list()
        items = library.getMovies(
            ['title', 'cast']).withFilters(defaultFilters).withoutActor(
                actorOne['name']).withoutActor(
                    actorTwo['name']).limitTo(10).asList()
        for item in items:
            otherActors.extend(iter(item['cast']))
        random.shuffle(otherActors)

        for otherActor in otherActors:
            if not 'thumbnail' in otherActor:
                continue
            self.addAnswer(otherActor['name'].encode('utf-8', 'ignore'),
                           otherActor['name'],
                           image=otherActor['thumbnail'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_IN_MOVIE_BESIDES_OTHER_ACTOR,
                            (movie['title'], actorTwo['name']))
        self.setFanartFile(movie['art']['fanart'])
示例#13
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsInMovieBesidesOtherActorQuestion
        """
        super(WhatActorIsInMovieBesidesOtherActorQuestion, self).__init__()

        # Find a bunch of movies
        items = library.getMovies(["title", "cast", "art"]).withFilters(defaultFilters).limitTo(10).asList()
        movie = None
        for item in items:
            if len(item["cast"]) >= 2:
                movie = item
                break

        if not movie:
            raise QuestionException("No movies with two actors found")

        actors = movie["cast"]
        random.shuffle(actors)
        actorOne = actors[0]
        actorTwo = actors[1]
        self.addCorrectAnswer(actorOne["name"], actorOne["name"], image=actorOne["thumbnail"])

        # Find another bunch of actors
        otherActors = list()
        items = (
            library.getMovies(["title", "cast"])
            .withFilters(defaultFilters)
            .withoutActor(actorOne["name"])
            .withoutActor(actorTwo["name"])
            .limitTo(10)
            .asList()
        )
        for item in items:
            otherActors.extend(iter(item["cast"]))
        random.shuffle(otherActors)

        for otherActor in otherActors:
            if not "thumbnail" in otherActor:
                continue
            self.addAnswer(
                otherActor["name"].encode("utf-8", "ignore"), otherActor["name"], image=otherActor["thumbnail"]
            )
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_IN_MOVIE_BESIDES_OTHER_ACTOR, (movie["title"], actorTwo["name"]))
        self.setFanartFile(movie["art"]["fanart"])
示例#14
0
    def __init__(self, defaultFilters):
        """
        WhoDirectedThisMovieQuestion
        """
        super(WhoDirectedThisMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(["title", "director", "art"]).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item["director"]:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException("No movies found")

        director = random.choice(movie["director"])
        self.addCorrectAnswer(id=movie["movieid"], text=director)

        otherMovies = (
            library.getMovies(["director"])
            .withFilters(defaultFilters)
            .excludeTitles(movie["title"])
            .limitTo(10)
            .asList()
        )
        for otherMovie in otherMovies:
            if not otherMovie["director"]:
                continue

            directorFound = False
            for otherDirector in otherMovie["director"]:
                if otherDirector in self.getAnswerTexts():
                    directorFound = True
                    break

            if directorFound:
                continue

            self.addAnswer(id=otherMovie["movieid"], text=random.choice(otherMovie["director"]))
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_DIRECTED_THIS_MOVIE, movie["title"])
        self.setFanartFile(movie["art"]["fanart"])
示例#15
0
    def __init__(self, defaultFilters):
        """
        WhatMovieHasTheLongestRuntimeQuestion
        """
        super(WhatMovieHasTheLongestRuntimeQuestion, self).__init__()

        # Find a bunch of movies
        items = library.getMovies(['title', 'runtime', 'art']).withFilters(defaultFilters).limitTo(10).asList()
        movie = None
        otherMovies = list()
        for item in items:
            if movie is None or movie['runtime'] < item['runtime']:
                movie = item
            else:
                otherMovies.append(item)

        if not movie or len(otherMovies) < 3:
            raise QuestionException('Not enough movies found')

        self.addCorrectAnswer(id=movie['movieid'], text=movie['title'], image=movie['art']['poster'])

        for otherMovie in otherMovies:
            self.addAnswer(id=otherMovie['movieid'], text=otherMovie['title'], image=otherMovie['art']['poster'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_HAS_THE_LONGEST_RUNTIME)
示例#16
0
    def __init__(self, defaultFilters):
        """
        WhatYearWasMovieReleasedQuestion
        """
        super(WhatYearWasMovieReleasedQuestion, self).__init__()

        movie = library.getMovies(['title', 'year', 'art']).withFilters(defaultFilters).fromYear(1900).limitTo(
            1).asItem()
        if not movie:
            raise QuestionException('No movies found')

        skew = random.randint(0, 10)
        minYear = int(movie['year']) - skew
        maxYear = int(movie['year']) + (10 - skew)

        thisYear = datetime.datetime.today().year
        if maxYear > thisYear:
            maxYear = thisYear
            minYear = thisYear - 10

        years = list()
        years.append(int(movie['year']))
        while len(years) < 4:
            year = random.randint(minYear, maxYear)
            if not year in years:
                years.append(year)

        list.sort(years)

        for year in years:
            self.addAnswer(id=movie['movieid'], text=str(year), correct=(year == int(movie['year'])))

        self.text = strings(Q_WHAT_YEAR_WAS_MOVIE_RELEASED, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#17
0
    def __init__(self, defaultFilters):
        """
        WhatMovieHasTheLongestRuntimeQuestion
        """
        super(WhatMovieHasTheLongestRuntimeQuestion, self).__init__()

        # Find a bunch of movies
        items = library.getMovies(['title', 'runtime', 'art']).withFilters(defaultFilters).limitTo(10).asList()
        movie = None
        otherMovies = list()
        for item in items:
            if movie is None or movie['runtime'] < item['runtime']:
                movie = item
            else:
                otherMovies.append(item)

        if not movie or len(otherMovies) < 3:
            raise QuestionException('Not enough movies found')

        self.addCorrectAnswer(id=movie['movieid'], text=movie['title'], image=movie['art']['poster'])

        for otherMovie in otherMovies:
            self.addAnswer(id=otherMovie['movieid'], text=otherMovie['title'], image=otherMovie['art']['poster'])
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_HAS_THE_LONGEST_RUNTIME)
示例#18
0
    def __init__(self, defaultFilters):
        """
        WhatYearWasMovieReleasedQuestion
        """
        super(WhatYearWasMovieReleasedQuestion, self).__init__()

        movie = library.getMovies(['title', 'year', 'art']).withFilters(defaultFilters).fromYear(1900).limitTo(
            1).asItem()
        if not movie:
            raise QuestionException('No movies found')

        skew = random.randint(0, 10)
        minYear = int(movie['year']) - skew
        maxYear = int(movie['year']) + (10 - skew)

        thisYear = datetime.datetime.today().year
        if maxYear > thisYear:
            maxYear = thisYear
            minYear = thisYear - 10

        years = list()
        years.append(int(movie['year']))
        while len(years) < 4:
            year = random.randint(minYear, maxYear)
            if not year in years:
                years.append(year)

        list.sort(years)

        for year in years:
            self.addAnswer(id=movie['movieid'], text=str(year), correct=(year == int(movie['year'])))

        self.text = strings(Q_WHAT_YEAR_WAS_MOVIE_RELEASED, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#19
0
    def __init__(self, defaultFilters):
        """
        WhoDirectedThisMovieQuestion
        """
        super(WhoDirectedThisMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(
            ['title', 'director',
             'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item['director']:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No movies found')

        director = random.choice(movie['director'])
        self.addCorrectAnswer(id=movie['movieid'], text=director)

        otherMovies = library.getMovies(
            ['director']).withFilters(defaultFilters).excludeTitles(
                movie['title']).limitTo(10).asList()
        for otherMovie in otherMovies:
            if not otherMovie['director']:
                continue

            directorFound = False
            for otherDirector in otherMovie['director']:
                if otherDirector in self.getAnswerTexts():
                    directorFound = True
                    break

            if directorFound:
                continue

            self.addAnswer(id=otherMovie['movieid'],
                           text=random.choice(otherMovie['director']))
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_DIRECTED_THIS_MOVIE, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#20
0
    def __init__(self, defaultFilters):
        """
        WhatStudioReleasedMovieQuestion
        """
        super(WhatStudioReleasedMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(
            ['title', 'studio',
             'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item['studio']:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No movies found')

        studio = random.choice(movie['studio'])
        self.addCorrectAnswer(id=movie['movieid'], text=studio)

        otherMovies = library.getMovies(
            ['studio']).withFilters(defaultFilters).excludeTitles(
                movie['title']).limitTo(10).asList()
        for otherMovie in otherMovies:
            if not otherMovie['studio']:
                continue

            studioFound = False
            for otherStudio in otherMovie['studio']:
                if otherStudio in self.getAnswerTexts():
                    studioFound = True
                    break

            if studioFound:
                continue

            self.addAnswer(id=otherMovie['movieid'],
                           text=random.choice(otherMovie['studio']))
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_STUDIO_RELEASED_MOVIE, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#21
0
    def __init__(self, defaultFilters):
        """
        WhatStudioReleasedMovieQuestion
        """
        super(WhatStudioReleasedMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(["title", "studio", "art"]).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if not item["studio"]:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException("No movies found")

        studio = random.choice(movie["studio"])
        self.addCorrectAnswer(id=movie["movieid"], text=studio)

        otherMovies = (
            library.getMovies(["studio"]).withFilters(defaultFilters).excludeTitles(movie["title"]).limitTo(10).asList()
        )
        for otherMovie in otherMovies:
            if not otherMovie["studio"]:
                continue

            studioFound = False
            for otherStudio in otherMovie["studio"]:
                if otherStudio in self.getAnswerTexts():
                    studioFound = True
                    break

            if studioFound:
                continue

            self.addAnswer(id=otherMovie["movieid"], text=random.choice(otherMovie["studio"]))
            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_STUDIO_RELEASED_MOVIE, movie["title"])
        self.setFanartFile(movie["art"]["fanart"])
示例#22
0
    def __init__(self, defaultFilters):
        """
        WhatMovieIsNotDirectedByQuestion
        """
        super(WhatMovieIsNotDirectedByQuestion, self).__init__()

        # Find a bunch of directors
        directors = list()
        items = library.getMovies(
            ['title',
             'director']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            directors.extend(iter(item['director']))

        # Find one that has at least three movies
        movies = None
        director = None
        for director in directors:
            #            if not director['thumbnail']:
            #                continue
            movies = library.getMovies(['title', 'art']).withFilters(
                defaultFilters).directedBy(director).limitTo(3).asList()

            if len(movies) >= 3:
                break

        if len(movies) < 3:
            raise QuestionException(
                "Didn't find a director with at least three movies")

        # Find movie not directed by director
        otherMovie = library.getMovies(['title', 'art']).withFilters(
            defaultFilters).notDirectedBy(director).limitTo(1).asItem()
        if not otherMovie:
            raise QuestionException('No movie found')
        self.addCorrectAnswer(director,
                              otherMovie['title'],
                              image=otherMovie['art']['poster'])

        for movie in movies:
            self.addAnswer(-1, movie['title'], image=movie['art']['poster'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_NOT_DIRECTED_BY, director)
示例#23
0
    def __init__(self, defaultFilters):
        """
        WhatMovieIsNotDirectedByQuestion
        """
        super(WhatMovieIsNotDirectedByQuestion, self).__init__()

        # Find a bunch of directors
        directors = list()
        items = library.getMovies(["title", "director"]).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            directors.extend(iter(item["director"]))

        # Find one that has at least three movies
        movies = None
        director = None
        for director in directors:
            #            if not director['thumbnail']:
            #                continue
            movies = (
                library.getMovies(["title", "art"]).withFilters(defaultFilters).directedBy(director).limitTo(3).asList()
            )

            if len(movies) >= 3:
                break

        if len(movies) < 3:
            raise QuestionException("Didn't find a director with at least three movies")

        # Find movie not directed by director
        otherMovie = (
            library.getMovies(["title", "art"]).withFilters(defaultFilters).notDirectedBy(director).limitTo(1).asItem()
        )
        if not otherMovie:
            raise QuestionException("No movie found")
        self.addCorrectAnswer(director, otherMovie["title"], image=otherMovie["art"]["poster"])

        for movie in movies:
            self.addAnswer(-1, movie["title"], image=movie["art"]["poster"])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_NOT_DIRECTED_BY, director)
示例#24
0
    def __init__(self, defaultFilters):
        """
        What movie is this?
        """
        videoDisplayType = VideoDisplayType()
        super(WhatMovieIsThisQuestion, self).__init__(videoDisplayType)

        correctAnswer = library.getMovies(['title', 'set', 'genre', 'file', 'art']).withFilters(
            defaultFilters).limitTo(1).asItem()
        if not correctAnswer:
            raise QuestionException('No movies found')

        self.addCorrectAnswer(id=correctAnswer['movieid'], text=correctAnswer['title'],
                              image=correctAnswer['art']['poster'])

        # Find other movies in set
        if correctAnswer['set'] is not None:
            otherMoviesInSet = library.getMovies(['title', 'art']).withFilters(defaultFilters).inSet(
                correctAnswer['set']).excludeTitles(self.getAnswerTexts()).limitTo(3).asList()
            for movie in otherMoviesInSet:
                self.addAnswer(id=movie['movieid'], text=movie['title'], image=movie['art']['poster'])

        # Find other movies in genre
        if len(self.answers) < 4:
            otherMoviesInGenre = library.getMovies(['title', 'art']).withFilters(defaultFilters).inGenre(
                correctAnswer['genre']).excludeTitles(self.getAnswerTexts()).limitTo(4 - len(self.answers)).asList()
            for movie in otherMoviesInGenre:
                self.addAnswer(id=movie['movieid'], text=movie['title'], image=movie['art']['poster'])

        # Fill with random movies
        if len(self.answers) < 4:
            theRest = library.getMovies(['title', 'art']).withFilters(defaultFilters).excludeTitles(
                self.getAnswerTexts()).limitTo(4 - len(self.answers)).asList()
            for movie in theRest:
                self.addAnswer(id=movie['movieid'], text=movie['title'], image=movie['art']['poster'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_THIS)
        videoDisplayType.setVideoFile(correctAnswer['file'])
示例#25
0
    def __init__(self, defaultFilters):
        """
        WhoPlayedRoleInMovieQuestion
        """
        super(WhoPlayedRoleInMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(
            ['title', 'cast', 'genre',
             'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if len(item['cast']) < 4:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No applicable movie found')

        actor = random.choice(movie['cast'])
        role = actor['role']
        if re.search('[|/,]', role):
            roles = re.split('[|/,]', role)
            # find random role
            role = roles[random.randint(0, len(roles) - 1)]

        self.addCorrectAnswer(actor['name'],
                              actor['name'],
                              image=actor['thumbnail'])

        for otherActor in movie['cast']:
            if otherActor['name'] == actor['name']:
                continue

            self.addAnswer(otherActor['name'].encode('utf-8', 'ignore'),
                           otherActor['name'],
                           image=otherActor['thumbnail'])

            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)

        if self._isAnimationGenre(movie['genre']):
            self.text = strings(Q_WHO_VOICES_ROLE_IN_MOVIE) % (role,
                                                               movie['title'])
        else:
            self.text = strings(Q_WHO_PLAYS_ROLE_IN_MOVIE) % (role,
                                                              movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#26
0
    def __init__(self, defaultFilters):
        """
        WhoPlayedRoleInMovieQuestion
        """
        super(WhoPlayedRoleInMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(["title", "cast", "genre", "art"]).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if len(item["cast"]) < 4:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException("No applicable movie found")

        actor = random.choice(movie["cast"])
        role = actor["role"]
        if re.search("[|/,]", role):
            roles = re.split("[|/,]", role)
            # find random role
            role = roles[random.randint(0, len(roles) - 1)]

        self.addCorrectAnswer(actor["name"], actor["name"], image=actor["thumbnail"])

        for otherActor in movie["cast"]:
            if otherActor["name"] == actor["name"]:
                continue

            self.addAnswer(
                otherActor["name"].encode("utf-8", "ignore"), otherActor["name"], image=otherActor["thumbnail"]
            )

            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)

        if self._isAnimationGenre(movie["genre"]):
            self.text = strings(Q_WHO_VOICES_ROLE_IN_MOVIE) % (role, movie["title"])
        else:
            self.text = strings(Q_WHO_PLAYS_ROLE_IN_MOVIE) % (role, movie["title"])
        self.setFanartFile(movie["art"]["fanart"])
示例#27
0
    def __init__(self, defaultFilters):
        """
        WhoPlayedRoleInMovieQuestion
        """
        super(WhoPlayedRoleInMovieQuestion, self).__init__()

        movie = None
        items = library.getMovies(['title', 'cast', 'genre', 'art']).withFilters(defaultFilters).limitTo(10).asList()
        for item in items:
            if len(item['cast']) < 4:
                continue

            movie = item
            break

        if not movie:
            raise QuestionException('No applicable movie found')

        actor = random.choice(movie['cast'])
        role = actor['role']
        if re.search('[|/,]', role):
            roles = re.split('[|/,]', role)
            # find random role
            role = roles[random.randint(0, len(roles) - 1)]

        self.addCorrectAnswer(actor['name'], actor['name'], image=actor['thumbnail'])

        for otherActor in movie['cast']:
            if otherActor['name'] == actor['name']:
                continue

            self.addAnswer(otherActor['name'].encode('utf-8', 'ignore'), otherActor['name'], image=otherActor['thumbnail'])

            if len(self.answers) == 4:
                break

        random.shuffle(self.answers)

        if self._isAnimationGenre(movie['genre']):
            self.text = strings(Q_WHO_VOICES_ROLE_IN_MOVIE) % (role, movie['title'])
        else:
            self.text = strings(Q_WHO_PLAYS_ROLE_IN_MOVIE) % (role, movie['title'])
        self.setFanartFile(movie['art']['fanart'])
示例#28
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsThisQuestion
        """
        photoDisplayType = PhotoDisplayType()
        super(WhatActorIsThisQuestion, self).__init__(photoDisplayType)

        # Find a bunch of actors with thumbnails
        actors = list()
        names = list()
        for movie in library.getMovies(
            ['cast']).withFilters(defaultFilters).limitTo(10).asList():
            for actor in movie['cast']:
                if 'thumbnail' in actor and actor['name'] not in names:
                    actors.append(actor)
                    names.append(actor['name'])

        if not actors:
            raise QuestionException("Didn't find any actors with thumbnail")

        random.shuffle(actors)
        actor = actors.pop()

        # The actor
        self.addCorrectAnswer(id=actor['name'], text=actor['name'])

        # Check gender
        actorGender = IMDB.isActor(actor['name'])

        for otherActor in actors:
            if IMDB.isActor(otherActor['name']) == actorGender:
                self.addAnswer(otherActor['name'].encode('utf-8', 'ignore'),
                               otherActor['name'])
                if len(self.answers) == 4:
                    break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_THIS)
        photoDisplayType.setPhotoFile(actor['thumbnail'])
示例#29
0
    def __init__(self, defaultFilters):
        """
        WhatActorIsThisQuestion
        """
        photoDisplayType = PhotoDisplayType()
        super(WhatActorIsThisQuestion, self).__init__(photoDisplayType)

        # Find a bunch of actors with thumbnails
        actors = list()
        names = list()
        for movie in library.getMovies(['cast']).withFilters(defaultFilters).limitTo(10).asList():
            for actor in movie['cast']:
                if 'thumbnail' in actor and actor['name'] not in names:
                    actors.append(actor)
                    names.append(actor['name'])

        if not actors:
            raise QuestionException("Didn't find any actors with thumbnail")

        random.shuffle(actors)
        actor = actors.pop()

        # The actor
        self.addCorrectAnswer(id=actor['name'], text=actor['name'])

        # Check gender
        actorGender = IMDB.isActor(actor['name'])

        for otherActor in actors:
            if IMDB.isActor(otherActor['name']) == actorGender:
                self.addAnswer(otherActor['name'].encode('utf-8', 'ignore'), otherActor['name'])
                if len(self.answers) == 4:
                    break

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_ACTOR_IS_THIS)
        photoDisplayType.setPhotoFile(actor['thumbnail'])
示例#30
0
    def __init__(self, defaultFilters):
        """
        What movie is this?
        """
        videoDisplayType = VideoDisplayType()
        super(WhatMovieIsThisQuestion, self).__init__(videoDisplayType)

        correctAnswer = (
            library.getMovies(["title", "set", "genre", "file", "resume", "art"])
            .withFilters(defaultFilters)
            .limitTo(1)
            .asItem()
        )
        if not correctAnswer:
            raise QuestionException("No movies found")

        self.addCorrectAnswer(
            id=correctAnswer["movieid"], text=correctAnswer["title"], image=correctAnswer["art"]["poster"]
        )

        # Find other movies in set
        if correctAnswer["set"] is not None:
            otherMoviesInSet = (
                library.getMovies(["title", "art"])
                .withFilters(defaultFilters)
                .inSet(correctAnswer["set"])
                .excludeTitles(self.getAnswerTexts())
                .limitTo(3)
                .asList()
            )
            for movie in otherMoviesInSet:
                self.addAnswer(id=movie["movieid"], text=movie["title"], image=movie["art"]["poster"])

        # Find other movies in genre
        if len(self.answers) < 4:
            otherMoviesInGenre = (
                library.getMovies(["title", "art"])
                .withFilters(defaultFilters)
                .inGenre(correctAnswer["genre"])
                .excludeTitles(self.getAnswerTexts())
                .limitTo(4 - len(self.answers))
                .asList()
            )
            for movie in otherMoviesInGenre:
                self.addAnswer(id=movie["movieid"], text=movie["title"], image=movie["art"]["poster"])

        # Fill with random movies
        if len(self.answers) < 4:
            theRest = (
                library.getMovies(["title", "art"])
                .withFilters(defaultFilters)
                .excludeTitles(self.getAnswerTexts())
                .limitTo(4 - len(self.answers))
                .asList()
            )
            for movie in theRest:
                self.addAnswer(id=movie["movieid"], text=movie["title"], image=movie["art"]["poster"])

        random.shuffle(self.answers)
        self.text = strings(Q_WHAT_MOVIE_IS_THIS)
        videoDisplayType.setVideoFile(correctAnswer["file"], correctAnswer["resume"]["position"])