shazamio / ShazamIO

🎵 Is a free asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp.
MIT License
519 stars 75 forks source link

Added Proxy option #88

Closed Lautarotetamusa closed 9 months ago

Lautarotetamusa commented 9 months ago

Related to this issue: https://github.com/dotX12/ShazamIO/issues/65

I recently started experiencing issues using the library in a project because I consistently reached the Shazam API call limit. That's why I decided to implement the option to use proxies.

I added the 'proxy' parameter to the Shazam class; hence, all requests will use this proxy. I believe that if someone wants to use proxies, they would prefer using the same proxy for all requests. If you think the proxy should be in the 'recognize_song' call, let me know, and I can make the change.

class Shazam(Converter, Geo, Request):
    """Is asynchronous framework for reverse engineered Shazam API written in Python 3.7 with
    asyncio and aiohttp."""

    def __init__(self, language: str = "en-US", endpoint_country: str = "GB", proxy: str = ""):
        super().__init__(language=language)
        self.language = language
        self.endpoint_country = endpoint_country
        self.proxy = proxy
dotX12 commented 9 months ago

@Lautarotetamusa hello! Thanks for your input, but the HTTPClient has been greatly changed, the proxyhas been added here and will soon fall into main branch. https://github.com/shazamio/ShazamIO/pull/91

dotX12 commented 9 months ago

I also don’t see the point of a permanent proxy, when a person needs it, he will pass it to the required method, otherwise he will have to recreate the Shazamio object / remove self.proxy value / set self.proxy value, etc..

asapsmc commented 2 months ago

Could anyone give an example of how to use a proxy? I'm getting too many 429 errors.