async def get_album(self, album_id: typing.Union[int, str]) -> api.Album: resp = await self.get_album_raw(album_id) try: _songs = resp['songs'] except KeyError: raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self._patch_song_url(*_songs) await self._patch_song_lyric(*_songs) songs = _resolve(*_songs) return api.Album( name=resp['album']['name'].strip(), pic_url=resp['album']['picUrl'], count=len(songs), songs=songs, )
async def get_album(self, album_mid: str) -> api.Album: resp = await self.get_album_raw(album_mid) try: album = resp['data']['getAlbumInfo'] _songs = resp['data']['getSongInfo'] except KeyError: raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self._patch_song_url(*_songs) await self._patch_song_lyric(*_songs) songs = _resolve(*_songs) return api.Album( name=album['Falbum_name'].strip(), pic_url=_ALBUM_PIC_URL.format(album_mid=album['Falbum_mid']), count=len(songs), songs=songs)
async def get_album(self, album_id: typing.Union[int, str]) -> api.Album: resp = await self.get_album_raw(album_id) try: album = resp['data'] _songs = album['musicList'] except KeyError: raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self._patch_song_url(*_songs) await self._patch_song_lyric(*_songs) songs = _resolve(*_songs) return api.Album(name=album['album'].strip(), pic_url=album.get('pic', ''), count=len(songs), songs=songs)
async def get_album(self, album_id: typing.Union[int, str]) -> api.Album: resp = await self.get_album_raw(album_id) try: album = resp['resource'][0] _songs = album['songItems'] except (KeyError, IndexError): raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self._patch_song_lyric(*_songs) _patch_song_url(*_songs) _patch_song_info(*_songs) songs = _resolve(*_songs) return api.Album(name=album['title'].strip(), pic_url=_get_pic_url(album['imgItems']), count=len(songs), songs=songs)
async def get_album(self, album_id: typing.Union[int, str]) -> api.Album: album_info = await self.get_album_info_raw(album_id) album_song = await self.get_album_song_raw(album_id) try: _songs = album_song['data']['info'] except KeyError: raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self.patch_song_info(*_songs) await self.patch_album_info(*_songs) await self.patch_song_lyric(*_songs) songs = _resolve(*_songs) return api.Album(name=album_info['data']['albumname'].strip(), pic_url=album_info['data']['imgurl'].replace( '{size}', '480'), count=len(songs), songs=songs)
async def get_album(self, album_id: typing.Union[int, str]) -> api.Album: resp = await self.get_album_raw(album_id) try: album = resp['albumInfo'] _songs = resp['songlist'] except KeyError: raise exceptions.DataError('get album: no data') if not _songs: raise exceptions.DataError('get album: no data') await self._patch_song_url(*_songs) await self._patch_song_lyric(*_songs) songs = _resolve(*_songs) return api.Album( album_id=album['album_id'], name=album['title'].strip(), pic_url=album.get('pic_big', '').split('@', 1)[0], count=len(songs), songs=songs, )