示例#1
0
    def __init__(self, defaultFilters):
        photoDisplayType = PhotoDisplayType()
        super(WhoMadeThisAlbumQuestion, self).__init__(photoDisplayType)

        correctAnswer = library.getArtists().withFilters(
            defaultFilters).limitTo(1).asItem()
        artist = library.getArtistDetails(correctAnswer['artistid'],
                                          ['thumbnail']).asItem()
        album = library.getAlbums(
            ['title', 'fanart',
             'thumbnail']).withFilters(defaultFilters).withArtist(
                 correctAnswer['artist']).limitTo(1).asItem()
        if not correctAnswer or not album:
            raise QuestionException('No artist or album found')

        self.addCorrectAnswer(id=correctAnswer['artistid'],
                              text=correctAnswer['artist'],
                              image=artist['thumbnail'])

        # Fill with random artists
        theRest = library.getArtists().withFilters(
            defaultFilters).withoutArtist(
                correctAnswer['artist']).limitTo(4 -
                                                 len(self.answers)).asList()
        for item in theRest:
            artist = library.getArtistDetails(item['artistid'],
                                              ['thumbnail']).asItem()
            self.addAnswer(id=item['artist'],
                           text=item['artist'],
                           image=artist['thumbnail'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_MADE_THE_ALBUM, album['title'])
        photoDisplayType.setPhotoFile(album['thumbnail'])
        self.setFanartFile(album['fanart'])
示例#2
0
    def __init__(self, defaultFilters):
        audioDisplayType = AudioDisplayType()
        super(WhoMadeThisSongQuestion, self).__init__(audioDisplayType)

        correctAnswer = library.getArtists().withFilters(
            defaultFilters).limitTo(1).asItem()
        artist = library.getArtistDetails(correctAnswer['artistid'],
                                          ['thumbnail']).asItem()
        song = library.getSongs(
            ['title', 'file']).withFilters(defaultFilters).withArtist(
                correctAnswer['artist']).limitTo(1).asItem()
        if not correctAnswer or not song:
            raise QuestionException('No artist or song found')

        self.addCorrectAnswer(id=correctAnswer['artistid'],
                              text=correctAnswer['artist'],
                              image=artist['thumbnail'])

        # Fill with random artists
        theRest = library.getArtists().withFilters(
            defaultFilters).withoutArtist(
                correctAnswer['artist']).limitTo(4 -
                                                 len(self.answers)).asList()
        for item in theRest:
            artist = library.getArtistDetails(item['artistid'],
                                              ['thumbnail']).asItem()
            self.addAnswer(id=item['artist'],
                           text=item['artist'],
                           image=artist['thumbnail'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_MADE_THE_SONG, song['title'])
        audioDisplayType.setAudioFile(song['file'])
示例#3
0
    def __init__(self, defaultFilters):
        audioDisplayType = AudioDisplayType()
        super(WhoMadeThisSongQuestion, self).__init__(audioDisplayType)

        correctAnswer = library.getArtists().withFilters(defaultFilters).limitTo(1).asItem()
        artist = library.getArtistDetails(correctAnswer['artistid'], ['thumbnail']).asItem()
        song = library.getSongs(['title', 'file']).withFilters(defaultFilters).withArtist(correctAnswer['artist']).limitTo(1).asItem()
        if not correctAnswer or not song:
            raise QuestionException('No artist or song found')

        self.addCorrectAnswer(id=correctAnswer['artistid'], text=correctAnswer['artist'], image=artist['thumbnail'])

        # Fill with random artists
        theRest = library.getArtists().withFilters(defaultFilters).withoutArtist(correctAnswer['artist']).limitTo(4 - len(self.answers)).asList()
        for item in theRest:
            artist = library.getArtistDetails(item['artistid'], ['thumbnail']).asItem()
            self.addAnswer(id=item['artist'], text=item['artist'], image=artist['thumbnail'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_MADE_THE_SONG, song['title'])
        audioDisplayType.setAudioFile(song['file'])
示例#4
0
    def __init__(self, defaultFilters):
        photoDisplayType = PhotoDisplayType()
        super(WhoMadeThisAlbumQuestion, self).__init__(photoDisplayType)

        correctAnswer = library.getArtists().withFilters(defaultFilters).limitTo(1).asItem()
        artist = library.getArtistDetails(correctAnswer['artistid'], ['thumbnail']).asItem()
        album = library.getAlbums(['title', 'fanart', 'thumbnail']).withFilters(defaultFilters).withArtist(correctAnswer['artist']).limitTo(1).asItem()
        if not correctAnswer or not album:
            raise QuestionException('No artist or album found')

        self.addCorrectAnswer(id=correctAnswer['artistid'], text=correctAnswer['artist'], image=artist['thumbnail'])

        # Fill with random artists
        theRest = library.getArtists().withFilters(defaultFilters).withoutArtist(correctAnswer['artist']).limitTo(4 - len(self.answers)).asList()
        for item in theRest:
            artist = library.getArtistDetails(item['artistid'], ['thumbnail']).asItem()
            self.addAnswer(id=item['artist'], text=item['artist'], image=artist['thumbnail'])

        random.shuffle(self.answers)
        self.text = strings(Q_WHO_MADE_THE_ALBUM, album['title'])
        photoDisplayType.setPhotoFile(album['thumbnail'])
        self.setFanartFile(album['fanart'])