Example #1
0
 def filter_random(self, key):
     if key == "album" and self.can_filter_albums():
         albums = self.list_albums()
         if albums:
             self.filter_albums([random.choice(albums)])
     elif self.can_filter_tag(key):
         values = self.list(key)
         if values:
             value = random.choice(values)
             self.filter(key, [value])
     elif self.can_filter_text():
         values = self.list(key)
         if values:
             value = random.choice(values)
             query = util.build_filter_query(key, [value])
             self.filter_text(query)
Example #2
0
    def plugin_songs(self, songs):
        browser = self.plugin_window.browser
        if not browser.can_filter_text():
            return

        keys = {key for song in songs
                for key in song.realkeys()}
        keys.difference_update(MACHINE_TAGS)

        filters = {}
        for key in keys:
            values = set()
            for song in songs:
                values.update(song.list(key))
            filters[key] = build_filter_query(key, values)

        SelectionWindow(filters, browser, parent=self.plugin_window)
Example #3
0
    def filter_on(self, songs, key):
        if key == "album" and self.can_filter_albums():
            values = set()
            values.update([s.album_key for s in songs])
            self.filter_albums(values)
        elif self.can_filter_tag(key) or self.can_filter_text():
            values = set()
            if key.startswith("~#"):
                values.update([song(key, 0) for song in songs])
            else:
                for song in songs:
                    values.update(song.list(key))

            if self.can_filter_tag(key):
                self.filter(key, values)
            else:
                query = util.build_filter_query(key, values)
                self.filter_text(query)
Example #4
0
    def filter_on(self, songs, key):
        """Do filtering in the best way the browser can handle"""
        if key == "album" and self.can_filter_albums():
            values = {s.album_key for s in songs}
            self.filter_albums(values)
        elif self.can_filter_tag(key) or self.can_filter_text():
            values = set()
            if key.startswith("~#"):
                values.update([song(key, 0) for song in songs])
            else:
                for song in songs:
                    values.update(song.list(key))

            if self.can_filter_tag(key):
                self.filter(key, values)
            else:
                query = util.build_filter_query(key, values)
                self.filter_text(query)
Example #5
0
 def filter(self, key, values):
     # for backward compatibility
     if self.can_filter_text():
         self.filter_text(util.build_filter_query(key, values))
Example #6
0
 def filter(self, key, values):
     """Actually do the filtering (with a union of values)."""
     # for backward compatibility
     if self.can_filter_text():
         self.filter_text(util.build_filter_query(key, values))