示例#1
0
    async def get_artist(self, singer_id: typing.Union[int,
                                                       str]) -> api.Artist:
        artist_info = await self.get_artist_info_raw(singer_id)
        artist_song = await self.get_artist_songs_raw(singer_id)

        try:
            artist = artist_info['resource'][0]
            item_list = artist_song['data']['contentItemList'][0]['itemList']
        except (KeyError, IndexError):
            raise exceptions.DataError('get artist: no data')

        if not item_list:
            raise exceptions.DataError('get artist: no data')

        _songs = [v['song'] for i, v in enumerate(item_list) if i % 2 == 0]
        await self._patch_song_lyric(*_songs)
        _patch_song_url(*_songs)
        _patch_song_info(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(
            artist_id=artist['singerId'],
            name=artist['singer'].strip(),
            pic_url=_get_pic_url(artist['imgs']),
            count=len(songs),
            songs=songs,
        )
示例#2
0
    async def get_artist(self, artist_id: typing.Union[int, str]) -> api.Artist:
        resp = await self.get_artist_raw(artist_id)
        try:
            _songs = resp['hotSongs']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not _songs:
            raise exceptions.DataError('get artist: no data')

        await self._patch_song_url(*_songs)
        await self._patch_song_lyric(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(
            name=resp['artist']['name'].strip(),
            pic_url=resp['artist']['picUrl'],
            count=len(songs),
            songs=songs,
        )
示例#3
0
文件: baidu.py 项目: owlwang/pymxget
    async def get_artist(self, ting_uid: typing.Union[int, str]) -> api.Artist:
        resp = await self.get_artist_raw(ting_uid)

        try:
            artist = resp['artistinfo']
            _songs = resp['songlist']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not _songs:
            raise exceptions.DataError('get artist: no data')

        await self._patch_song_url(*_songs)
        await self._patch_song_lyric(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(name=artist['name'].strip(),
                          pic_url=artist.get('avatar_big', '').split('@')[0],
                          count=len(songs),
                          songs=songs)
示例#4
0
    async def get_artist(self, singer_mid: str) -> api.Artist:
        resp = await self.get_artist_raw(singer_mid)
        try:
            artist = resp['data']
            items = artist['list']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not items:
            raise exceptions.DataError('get artist: no data')

        _songs = [i['musicData'] for i in items]
        await self._patch_song_url(*_songs)
        await self._patch_song_lyric(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(
            name=artist['singer_name'].strip(),
            pic_url=_ARTIST_PIC_URL.format(singer_mid=artist['singer_mid']),
            count=len(songs),
            songs=songs)
示例#5
0
    async def get_artist(self, singer_id: typing.Union[int,
                                                       str]) -> api.Artist:
        artist_info = await self.get_artist_info_raw(singer_id)
        artist_song = await self.get_artist_songs_raw(singer_id)

        try:
            artist = artist_info['data']
            _songs = artist_song['data']['list']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not _songs:
            raise exceptions.DataError('get artist: no data')

        await self._patch_song_url(*_songs)
        await self._patch_song_lyric(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(name=artist['name'].strip(),
                          pic_url=artist.get('pic300', ''),
                          count=len(songs),
                          songs=songs)
示例#6
0
文件: kugou.py 项目: vra/pymxget
    async def get_artist(self, singer_id: typing.Union[int, str]) -> api.Artist:
        artist_info = await self.get_artist__info_raw(singer_id)
        artist_song = await self.get_artist__song_raw(singer_id)

        try:
            _songs = artist_song['data']['info']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not _songs:
            raise exceptions.DataError('get artist: 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.Artist(
            name=artist_info['data']['singername'].strip(),
            pic_url=artist_info['data']['imgurl'].replace('{size}', '480'),
            count=len(songs),
            songs=songs
        )
示例#7
0
    async def get_artist(self, artist_id: typing.Union[int,
                                                       str]) -> api.Artist:
        artist_info = await self.get_artist_info_raw(artist_id)
        artist_song = await self.get_artist_songs_raw(artist_id)

        try:
            artist = artist_info['data']['data']['artistDetailVO']
            _songs = artist_song['data']['data']['songs']
        except KeyError:
            raise exceptions.DataError('get artist: no data')

        if not _songs:
            raise exceptions.DataError('get artist: no data')

        await self._patch_song_lyric(*_songs)
        songs = _resolve(*_songs)
        return api.Artist(
            artist_id=artist['artistId'],
            name=artist['artistName'].strip(),
            pic_url=artist.get('artistLogo', ''),
            count=len(songs),
            songs=songs,
        )