Ejemplo n.º 1
0
Archivo: migu.py Proyecto: vra/pymxget
    async def search_song(self, keyword: str) -> api.SearchResult:
        resp = await self.search_song_raw(keyword)
        try:
            _songs = resp['songResultData']['result']
        except KeyError:
            raise exceptions.DataError('search song: no data')

        if not _songs:
            raise exceptions.DataError('search song: no data')

        songs = [
            api.SearchSongData(
                song_id=_song['copyrightId'],
                name=_song['name'].strip(),
                artist='/'.join([s['name'].strip() for s in _song['singers']]),
                album='/'.join([a['name'].strip() for a in _song['albums']])
            ) for _song in _songs
        ]
        return api.SearchResult(keyword=keyword, count=len(songs), songs=songs)
Ejemplo n.º 2
0
    async def search_song(self, keyword: str) -> api.SearchResult:
        resp = await self.search_song_raw(keyword)
        try:
            songs = resp['result']['songs']
        except KeyError:
            raise exceptions.DataError('search song: no data')

        if not songs:
            raise exceptions.DataError('search song: no data')

        songs = [
            api.SearchSongData(
                song_id=song['id'],
                name=song['name'].strip(),
                artist='/'.join([a['name'].strip() for a in song['artists']]),
                album=song['album']['name'].strip(),
            ) for song in songs
        ]
        return api.SearchResult(keyword=keyword, count=len(songs), songs=songs)
Ejemplo n.º 3
0
Archivo: kugou.py Proyecto: vra/pymxget
    async def search_song(self, keyword: str) -> api.SearchResult:
        resp = await self.search_song_raw(keyword)
        try:
            _songs = resp['data']['info']
        except KeyError:
            raise exceptions.DataError('search song: no data')

        if not _songs:
            raise exceptions.DataError('search song: no data')

        songs = [
            api.SearchSongData(
                song_id=_song['hash'],
                name=_song['songname'].strip(),
                artist=_song['singername'].replace('、', '/').strip(),
                album=_song['album_name'].strip(),
            ) for _song in _songs
        ]
        return api.SearchResult(keyword=keyword, count=len(songs), songs=songs)