예제 #1
0
파일: api.py 프로젝트: dpedu/pysonic
    def getMusicDirectory_view(self, id, **kwargs):
        """
        List an artist dir
        """
        dir_id = int(id)
        dirtype, dirinfo, entity = self.library.db.get_subsonic_musicdir(dirid=dir_id)

        response = ApiResponse()
        response.add_child("directory")
        response.set_attrs(_path="directory", name=entity['name'], id=entity['id'],
                           parent=dirinfo['parent'], playCount=420)

        for childtype, child in entity["children"]:
            # omit not dirs and media in browser
            # if not item["isdir"] and item["type"] not in MUSIC_TYPES:
            #     continue
            # item_meta = item['metadata']
            moreargs = {}
            if childtype == "album":
                moreargs.update(name=child["name"],
                                isDir="true",  # TODO song files in artist dir
                                parent=entity["id"],
                                id=child["dir"])
                if child["coverid"]:
                    moreargs.update(coverArt=child["coverid"])
                # album=item["name"],
                #                title=item["name"],  # TODO dupe?
                #                artist=artist["name"],
                #                coverArt=item["coverid"],
            elif childtype == "song":
                moreargs.update(name=child["title"],
                                artist=child["_artist"]["name"],
                                contentType=child["format"],
                                id=child["id"],
                                duration=child["length"],
                                isDir="false",
                                parent=entity["dir"],
                                # title=xxx
                                )
                if entity["coverid"]:
                    moreargs.update(coverArt=entity["coverid"])
                # duration="230" size="8409237" suffix="mp3" track="2"  year="2005"/>
            response.add_child("child", _parent="directory",
                               size="4096",
                               type="music",
                               **moreargs)

        cherrypy.response.headers['Content-Type'] = 'text/xml; charset=utf-8'
        return response
예제 #2
0
파일: api.py 프로젝트: dpedu/pysonic
 def getArtistInfo_view(self, id, includeNotPresent="true", **kwargs):
     info = self.library.get_artist_info(id)
     response = ApiResponse()
     response.add_child("artistInfo")
     response.set_attrs("artistInfo", **info)
     return response