mental32 / spotify.py

🌐 API wrapper for Spotify 🎶
https://spotifypy.readthedocs.io/en/latest/
MIT License
150 stars 38 forks source link

Update http.py #71

Closed owlwang closed 3 years ago

owlwang commented 3 years ago

No need for quote, It will lead to incorrect results.

The params will be quoted in aiohttp

mental32 commented 3 years ago

It will lead to incorrect results.

I haven't noticed it producing any incorrect results or errors, @owlwang do you have an example I can sanity check?

owlwang commented 3 years ago

Spotify support search param like "isrc:GBAYE0000267" you can try

async def main():
    spotify_client = spotify.Client(client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET)
    async with spotify_client:
        keywords = 'isrc:GBAYE0000267'
        search_result = await spotify_client.search(q=keywords, types=['track'])
        print(search_result)
if __name__ == '__main__':
    asyncio.run(main())

The colon will be quoted twice.

Also, you can try:

async def main():
    spotify_client = spotify.Client(client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET)
    async with spotify_client:
        keywords = 'Yellow Coldplay'
        search_result = await spotify_client.search(q=keywords, types=['track'])
        print(search_result)
if __name__ == '__main__':
    asyncio.run(main())

The space will be quoted twice.

Both tests show no results.

SearchResults(artists=None, playlists=None, albums=None, tracks=[])
SearchResults(artists=None, playlists=None, albums=None, tracks=[])

After removing the quote, the results will be displayed.

SearchResults(artists=None, playlists=None, albums=None, tracks=[<spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>])
SearchResults(artists=None, playlists=None, albums=None, tracks=[<spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow - Live from Spotify London'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow - Live in Buenos Aires'>, <spotify.Track: 'Yellow - Live'>, <spotify.Track: 'Yellow (Coldplay Cover)'>, <spotify.Track: 'Yellow (Coldplay) [Fingerstyle]'>, <spotify.Track: 'Yellow - Live in Sydney'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Help Is Round the Corner'>, <spotify.Track: 'Yellow - Acoustic Cover'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'No More Keeping My Feet on the Ground'>, <spotify.Track: 'Yellow - Lullaby Version'>, <spotify.Track: 'Yellow - Instrumental'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>, <spotify.Track: 'Yellow'>])
mental32 commented 3 years ago

Yup that's all I wanted to check, merging now.