[PR #526] [MERGED] Add support to search multiple markets at once. #924

Closed
opened 2026-02-28 00:02:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/spotipy-dev/spotipy/pull/526
Author: @nleroy917
Created: 7/2/2020
Status: Merged
Merged: 7/3/2020
Merged by: @stephanebruckert

Base: masterHead: market-search


📝 Commits (7)

  • e67c409 Add support to search multiple markets. Pass in a list or ALL to search all markets.
  • e1532a6 pep8 formatting and verification with flake8
  • 2517947 work on comments from stephanebruckert
  • bd7ddc3 pep8 formatting
  • 908150a run autopep8 formatting
  • f87e009 fix typo
  • d5932e3 allow tuple of markets to be passed. Add unit tests for this case

📊 Changes

4 files changed (+150 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+4 -1)
📝 spotipy/client.py (+110 -6)
📝 spotipy/oauth2.py (+2 -0)
📝 tests/integration/test_non_user_endpoints.py (+34 -0)

📄 Description

Resolve issue #525

Overview

  • Support to search multiple markets at once by passing in a list.
  • Support to search all available Spotify markets.
  • Added two unit tests to test the new feature.

Detailed

I reformatted the API interface search method. I did notice that all but one method directly returned the result that comes from the self._get call, and I wanted to keep this to retain any abstraction, but I couldn't think of a way around it. The new search method on the Spotify client keeps all original functionality, but I added in some logic to handle if a user passes in a list of markets to search through. In addition, as referenced in #525, I added in the ability to search ALL markets as well as another available parameter n that will stop the searching once a given number of results are found.

I really tried to keep the object structure returned from Spotify... So, the final object returned from search when multiple markets are passed in will be almost identical to the object returned if one market or no markets are passed in.

To the best of my knowledge, it is the same, except href now results in a list of hrefs used for searching.

Performance Issues

As mentioned by @stephanebruckert, this code performs poorly due to looping through http requests, but I can not think of a way around it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/spotipy-dev/spotipy/pull/526 **Author:** [@nleroy917](https://github.com/nleroy917) **Created:** 7/2/2020 **Status:** ✅ Merged **Merged:** 7/3/2020 **Merged by:** [@stephanebruckert](https://github.com/stephanebruckert) **Base:** `master` ← **Head:** `market-search` --- ### 📝 Commits (7) - [`e67c409`](https://github.com/spotipy-dev/spotipy/commit/e67c4093f88bef9d7388581a46bcf78f58c36f6e) Add support to search multiple markets. Pass in a list or ALL to search all markets. - [`e1532a6`](https://github.com/spotipy-dev/spotipy/commit/e1532a64081a2bf8106a2024c99da76cf8efd78e) pep8 formatting and verification with flake8 - [`2517947`](https://github.com/spotipy-dev/spotipy/commit/2517947338279d5df03189cad33cd8a696d04cb7) work on comments from stephanebruckert - [`bd7ddc3`](https://github.com/spotipy-dev/spotipy/commit/bd7ddc3b4e9d04e4830c9ff957fd4bd474424c39) pep8 formatting - [`908150a`](https://github.com/spotipy-dev/spotipy/commit/908150affadf475b540260a3e951cfe36f0209e8) run autopep8 formatting - [`f87e009`](https://github.com/spotipy-dev/spotipy/commit/f87e009b2716d808d3c5568769ca9f4a77791b19) fix typo - [`d5932e3`](https://github.com/spotipy-dev/spotipy/commit/d5932e3767095f6f0625a4de83f62a7b7dac1265) allow tuple of markets to be passed. Add unit tests for this case ### 📊 Changes **4 files changed** (+150 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -1) 📝 `spotipy/client.py` (+110 -6) 📝 `spotipy/oauth2.py` (+2 -0) 📝 `tests/integration/test_non_user_endpoints.py` (+34 -0) </details> ### 📄 Description Resolve issue #525 ## Overview - Support to search multiple markets at once by passing in a list. - Support to search all available Spotify markets. - Added two unit tests to test the new feature. ## Detailed I reformatted the API interface `search` method. I did notice that all but one method directly returned the result that comes from the `self._get` call, and I wanted to keep this to retain any abstraction, but I couldn't think of a way around it. The new `search` method on the Spotify client keeps all original functionality, but I added in some logic to handle if a user passes in a list of markets to search through. In addition, as referenced in #525, I added in the ability to search **ALL** markets as well as another available parameter `n` that will stop the searching once a given number of results are found. I really tried to keep the object structure returned from Spotify... So, the final object returned from `search` when multiple markets are passed in will be almost identical to the object returned if one market or no markets are passed in. To the best of my knowledge, it is the same, except `href` now results in a list of `href`s used for searching. ## Performance Issues As mentioned by @stephanebruckert, this code performs poorly due to looping through http requests, but I can not think of a way around it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:02:39 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#924
No description provided.