Skip to content

Commit 3051ccb

Browse files
committed
Update spotify.py
1 parent 62dd99c commit 3051ccb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

beetsplug/spotify.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ def track_for_id(self, track_id=None, track_data=None):
381381
track.index = i
382382
track.medium_total = medium_total
383383
return track
384-
384+
385385
@staticmethod
386386
def _list_limit(str_input, max_length=50, delim=","):
387387
"""Return a list of strings from the input string that can be joined into
388388
a single string with a length less than or equal to max_length.
389-
389+
390390
:param str_input: String to split and join.
391391
:type str_input: str
392392
:param max_length: Maximum length of the resulting string.
@@ -410,9 +410,9 @@ def _list_limit(str_input, max_length=50, delim=","):
410410
result.append(item)
411411
current_length += item_length
412412
return result
413-
413+
414414
@staticmethod
415-
def _construct_search_query(filters=None, keywords=""):
415+
def _construct_search_query(self, filters=None, keywords=""):
416416
"""Construct a query string with the specified filters and keywords to
417417
be provided to the Spotify Search API
418418
(https://developer.spotify.com/documentation/web-api/reference/search/search/#writing-a-query---guidelines).
@@ -432,15 +432,19 @@ def _construct_search_query(filters=None, keywords=""):
432432

433433
# Limit each component to 50 characters max, so, for example the artist field doesn't take up all 100 characters
434434
for component in query_components:
435-
if component
435+
if component:
436436
if not isinstance(component, str):
437437
component = component.decode("utf8")
438-
limited_list = self._list_limit(component, max_length=50, delim=',')
438+
limited_list = self._list_limit(
439+
component, max_length=50, delim=","
440+
)
439441
# Each component is split by a comma but queries are joined by a space
440442
query.append(",".join(limited_list))
441443

442444
# Make sure it's less than 100 characters
443-
return unidecode.unidecode(self._list_limit(" ".join(query), max_length=100, delim=' '))
445+
return unidecode.unidecode(
446+
self._list_limit(" ".join(query), max_length=100, delim=" ")
447+
)
444448

445449
def _search_api(self, query_type, filters=None, keywords=""):
446450
"""Query the Spotify Search API for the specified ``keywords``,

0 commit comments

Comments
 (0)