예제 #1
0
파일: dmap.py 프로젝트: rbergstrom/euphony
    def get(self, db):
        filter_string = self.get_argument("filter")
        include_headers = bool(int(self.get_argument("include-sort-headers", 0)))

        artists = util.sort_by_initial(mpd.artists.query(filter_string), key=operator.attrgetter("name"))

        name_nodes = [("mlit", a.name) for a in artists]

        node_list = [("mstt", 200), ("muty", 0), ("mtco", len(artists)), ("mrco", len(artists)), ("abar", name_nodes)]

        if include_headers:
            header_data = util.build_sort_headers([a.name for a in artists])
            header_nodes = []
            for (char, index, num) in header_data:
                header_nodes.append(("mlit", [("mshc", char), ("mshi", index), ("mshn", num)]))
            node_list.append(("mshl", header_nodes))

        node = dacpy.types.build_node(("abro", node_list))
        self.write(node.serialize())
예제 #2
0
파일: dmap.py 프로젝트: rbergstrom/euphony
    def get(self, db):
        query_string = self.get_argument("query")
        query_type = self.get_argument("type")
        group_type = self.get_argument("group-type")
        sort_type = self.get_argument("sort")
        include_headers = bool(int(self.get_argument("include-sort-headers", 0)))
        properties = self.get_argument("meta").split(",")

        albums = util.sort_by_initial(mpd.albums.query(query_string), key=operator.attrgetter("name"))

        properties.append("dmap.itemcount")
        name_nodes = [("mlit", fetch_properties(properties, a)) for a in albums]

        node_list = [("mstt", 200), ("muty", 0), ("mtco", len(albums)), ("mrco", len(albums)), ("mlcl", name_nodes)]

        if include_headers:
            header_data = util.build_sort_headers([a.name for a in albums])
            header_nodes = []
            for (char, index, num) in header_data:
                header_nodes.append(("mlit", [("mshc", char), ("mshi", index), ("mshn", num)]))
            node_list.append(("mshl", header_nodes))

        node = dacpy.types.build_node(("agal", node_list))
        self.write(node.serialize())
예제 #3
0
 def _update_artists(self):
     self.artists = IndexedCollection(Artist)
     for n in (x for x in util.sort_by_initial(self.execute('list', 'artist')) if x):
         self.artists.add_new(name=n)