mental32 / spotify.py

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

No search results for "Adventure Club" #12

Closed ymyke closed 4 years ago

ymyke commented 4 years ago

Hi @mental32 -- thanks for the great module.

Stumbled upon this by accident:

1. Search for "Adventure Club" via search method yields empty list:

client.search("Adventure Club", types=["artist"])
{'artists': []}

2. Whereas search for "Adventure" yields "Adventure Club" in top spot:

client.search("Adventure", types=["artist"])

{'artists': [<spotify.Artist: "Adventure Club">,
  <spotify.Artist: "Adventure Time">,
  <spotify.Artist: "A Space Love Adventure">,
  <spotify.Artist: "Leaf Adventure">,
  <spotify.Artist: "Sonic Adventure Music Experience">,
  <spotify.Artist: "Cast - Olaf's Frozen Adventure">,
  <spotify.Artist: "Adventure Galley">,
  <spotify.Artist: "Action/Adventure">,
  <spotify.Artist: "Adventure Tiger">,
  <spotify.Artist: "A Great Adventure or Nothing">,
  <spotify.Artist: "Adventure Violence">,
  <spotify.Artist: "Sonic Adventure Project">,
  <spotify.Artist: "Techno Kitten Adventure">,
  <spotify.Artist: "Grand Space Adventure">,
  <spotify.Artist: "Adventure">,
  <spotify.Artist: "Inner Adventure">,
  <spotify.Artist: "Adventure Time">,
  <spotify.Artist: "New Street Adventure">,
  <spotify.Artist: "Mr. Bacon's Big Adventure">,
  <spotify.Artist: "Hand-Me-Down Adventure">]}

3. And: Using Spotify's API sandbox to issue the query in 1 also yields the correct results:

https://developer.spotify.com/console/get-search-item/?q=Adventure%20Club&type=artist&market=&limit=&offset=

yields:

{
  "artists": {
    "href": "https://api.spotify.com/v1/search?query=Adventure+Club&type=artist&market=CH&offset=0&limit=20",
    "items": [
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/5CdJjUi9f0cVgo9nFuJrFa"
        },
        "followers": {
          "href": null,
          "total": 228604
        },
        "genres": [
          "big room",
          "brostep",
          "canadian electronic",
          "chillstep",
          "complextro",
          "edm",
          "electro house",
          "electronic trap",
          "filthstep",
          "pop edm"
        ],
        "href": "https://api.spotify.com/v1/artists/5CdJjUi9f0cVgo9nFuJrFa",
        "id": "5CdJjUi9f0cVgo9nFuJrFa",
        "images": [
          {
            "height": 640,
            "url": "https://i.scdn.co/image/3b0069fe11e50bba1b737a3189f10a78ef3bf8ce",
            "width": 640
          },
          {
            "height": 320,
            "url": "https://i.scdn.co/image/866b5d49f54160f76d3da80d790b5c5f420996af",
            "width": 320
          },
          {
            "height": 160,
            "url": "https://i.scdn.co/image/c3299135895611be2fdb223d844b6e720cd8dd44",
            "width": 160
          }
        ],
        "name": "Adventure Club",
        "popularity": 61,
        "type": "artist",
        "uri": "spotify:artist:5CdJjUi9f0cVgo9nFuJrFa"
      },
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/4vIDWbhxIjNMXQ18tfmLxS"
        },
        "followers": {
          "href": null,
          "total": 1071
        },
        "genres": [],
        "href": "https://api.spotify.com/v1/artists/4vIDWbhxIjNMXQ18tfmLxS",
        "id": "4vIDWbhxIjNMXQ18tfmLxS",
        "images": [
          {
            "height": 640,
            "url": 
[...]

Do you have an idea what is going on here?

Thanks!

mental32 commented 4 years ago

Thanks for reporting this :)

ymyke commented 4 years ago

Got it. According to https://spotifypy.readthedocs.io/en/latest/quickstart.html: "Encode spaces with the hex code %20 or +."

So this works as expected:

client.search("Adventure%20Club", types=["artist"])

{'artists': [<spotify.Artist: "Adventure Club">,
  <spotify.Artist: "Adventure Club">,
  <spotify.Artist: "Ragtime Adventure Club">,
  <spotify.Artist: "Super Adventure Club">,
  <spotify.Artist: "Adventure Bathtub Club">,
  <spotify.Artist: "Super Adventure Club">,
  <spotify.Artist: "Admiral Spooks Aerial Adventure Club">]}

So my original issue is resolved.

Still, I'd suggest to mention this -- as well as the link to the readthedocs -- more prominently. The projects readme has very minimal info only and does not link to the readthedocs.

ymyke commented 4 years ago

(I'm using v0.4.8, async.)

ymyke commented 4 years ago

Adding to the above, encoding space with + did not work:

client.search("Adventure+Club", types=["artist"])

{'artists': []}
mental32 commented 4 years ago

Got it. According to https://spotifypy.readthedocs.io/en/latest/quickstart.html: "Encode spaces with the hex code %20 or +."

The library handles encoding the search query for you.

Still, I'd suggest to mention this -- as well as the link to the readthedocs -- more prominently. The projects readme has very minimal info only and does not link to the readthedocs.

I agree the readme is a little bare, I'll work on making it more informative.

I am unable to reproduce the issue testing with sync on v0.5.0

In [1]: from spotify import sync, __version__                                                                                                                                                                                                                                  

In [2]: print(__version__)                                                                                                                                                                                                                                                     
0.5.0

In [3]: client = sync.Client('foo', 'bar')

In [4]: client.search('Adventure Club', types=['artist'])        

Out[4]: 
{'artists': [<spotify.Artist: 'Adventure Club'>,
  <spotify.Artist: 'Adventure Club'>,
  <spotify.Artist: 'Ragtime Adventure Club'>,
  <spotify.Artist: 'Super Adventure Club'>,
  <spotify.Artist: 'Adventure Bathtub Club'>,
  <spotify.Artist: 'Super Adventure Club'>,
  <spotify.Artist: 'Admiral Spooks Aerial Adventure Club'>]}

I suggest updating the library to resolve your issue.

ymyke commented 4 years ago

Yep, that did the job. Thanks for helping!

mental32 commented 4 years ago

No problem!