class ArtistDetialResult(RemoteResult): artist = model.RequireModel('ArtistInfo') class hotSongs(model.List): Element = model.RequireModel('SongInfo') more = model.Boolean
class SongInfo(model.NamedObject): mp3Url = model.String class artists(model.List): Element = model.RequireModel('Artist') hMusic = model.RequireModel('Mp3Info') mMusic = model.RequireModel('Mp3Info') lMusic = model.RequireModel('Mp3Info') def __getitem__(self, quality): if quality == "high" and self.hMusic: return self.hMusic.geturl() if (quality == "high" or quality == "medium") and self.mMusic: return self.mMusic.geturl() if self.lMusic: return self.lMusic.geturl() return self.mp3Url
class Album(model.NamedObject): artist = model.RequireModel('Artist') company = model.String @RPCMethod("GET", "api/album/", AlbumDetailResult) def details(self): return {"__suffix__": self.id} def get_songs(self): details = self.details() if details.code != 200: raise HTTPStatusError(details.code) for song in details.album.songs: yield song
class Song(model.NamedObject): class artists(model.List): Element = model.RequireModel('Artist') album = model.RequireModel('Album') duration = model.Integer @RPCMethod("GET", "api/song/detail", SongDetialResult) def details(self): return {'id': self.id, 'ids': [self.id]} def info(self): details = self.details() if details.code != 200: raise HTTPStatusError(details.code) return details.songs[0]
class artists(model.List): Element = model.RequireModel('Artist')
class hotSongs(model.List): Element = model.RequireModel('SongInfo')
class albums(model.List): Element = model.RequireModel('Album')
class songs(model.List): Element = model.RequireModel('Song')