diff --git a/applemusicpy/client.py b/applemusicpy/client.py index 2af38f9..cddbcee 100644 --- a/applemusicpy/client.py +++ b/applemusicpy/client.py @@ -813,7 +813,7 @@ def storefronts_all(self, l=None, limit=None, offset=None): return self._get(url, l=l, limit=limit, offset=offset) # Search - def search(self, term, storefront='us', l=None, limit=None, offset=None, types=None, hints=False, os='linux'): + def search(self, term, storefront='us', l=None, limit=None, offset=None, types=None, hints=False, os=None): """ Query the Apple Music API based on a search term @@ -824,7 +824,6 @@ def search(self, term, storefront='us', l=None, limit=None, offset=None, types=N :param offset: The index of the first item returned :param types: A list of resource types to return (e.g. songs, artists, etc.) :param hints: Include search hints - :param os: Operating System being used. If search isn't working on Windows, try os='windows'. :return: The search results in JSON format """ @@ -837,28 +836,23 @@ def search(self, term, storefront='us', l=None, limit=None, offset=None, types=N else: type_str = None - if os == 'linux': - return self._get(url, term=term, l=l, limit=limit, offset=offset, types=type_str) - elif os == 'windows': - params = { - 'term': term, - 'limit': limit, - 'offset': offset, - 'types': type_str - } + params = { + 'term': term, + 'limit': limit, + 'offset': offset, + 'types': type_str + } - # The params parameter in requests converts '+' to '%2b' - # On some Windows computers, this breaks the API request, so generate full URL instead - param_string = '?' - for param, value in params.items(): - if value is None: - continue - param_string = param_string + str(param) + '=' + str(value) + '&' - param_string = param_string[:len(param_string) - 1] # This removes the last trailing '&' + # The params parameter in requests converts '+' to '%2b' + # On some Windows computers, this breaks the API request, so generate full URL instead + param_string = '?' + for param, value in params.items(): + if value is None: + continue + param_string = param_string + str(param) + '=' + str(value) + '&' + param_string = param_string[:len(param_string) - 1] # This removes the last trailing '&' - return self._get(url + param_string) - else: - return None + return self._get(url + param_string) # Charts def charts(self, storefront='us', chart=None, types=None, l=None, genre=None, limit=None, offset=None): diff --git a/tests.py b/tests.py index a7901a4..38ae77b 100644 --- a/tests.py +++ b/tests.py @@ -317,12 +317,6 @@ def test_search(self): actual_name = results['results']['songs']['data'][0]['attributes']['name'] self.assertTrue(expected_name == actual_name, f"Expected: {expected_name}, Actual: {actual_name}") - def test_search_windows(self): - results = am.search(self.search_term, types=['songs'], os='windows') - expected_name = 'Nice For What' - actual_name = results['results']['songs']['data'][0]['attributes']['name'] - self.assertTrue(expected_name == actual_name, f"Expected: {expected_name}, Actual: {actual_name}") - def test_charts(self): results = am.charts(types=['songs'], genre=self.pop) expected_name = 'Top Songs'