Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #45

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mopidy_beets/browsers/albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_toplevel(self):
keys = self.api.get_sorted_unique_album_attributes(self.field)
return [
models.Ref.directory(
name=key, uri=assemble_uri(self.ref.uri, id_value=key)
name=str(key), uri=assemble_uri(self.ref.uri, id_value=key)
)
for key in keys
]
Expand Down
13 changes: 4 additions & 9 deletions mopidy_beets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,12 @@


class BeetsRemoteClient:
def __init__(self, endpoint, proxy_config):
def __init__(self, endpoint, proxy_config, request_timeout=4):

Check warning on line 55 in mopidy_beets/client.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/client.py#L55

Added line #L55 was not covered by tests
super().__init__()
self._request_timeout = request_timeout

Check warning on line 57 in mopidy_beets/client.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/client.py#L57

Added line #L57 was not covered by tests
self.api = self._get_session(proxy_config)
self.api_endpoint = endpoint
logger.info("Connecting to Beets remote library %s", endpoint)
try:
self.api.get(self.api_endpoint)
self.has_connection = True
except RequestException as e:
logger.error("Beets error - connection failed: %s", e)
self.has_connection = False
logger.info("Configured for Beets remote library %s", endpoint)

Check warning on line 60 in mopidy_beets/client.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/client.py#L60

Added line #L60 was not covered by tests

def _get_session(self, proxy_config):
proxy = httpclient.format_proxy(proxy_config)
Expand Down Expand Up @@ -273,7 +268,7 @@
url = self.api_endpoint + url
logger.debug("Beets - requesting %s" % url)
try:
req = self.api.get(url)
req = self.api.get(url, timeout=self._request_timeout)

Check warning on line 271 in mopidy_beets/client.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/client.py#L271

Added line #L271 was not covered by tests
except RequestException as e:
logger.error("Beets - Request %s, failed with error %s", url, e)
return None
Expand Down
8 changes: 1 addition & 7 deletions mopidy_beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@
logger.debug(
'Beets Query (exact=%s) within "%s": %s', exact, uris, query
)
if not self.remote.has_connection:
return SearchResult(uri="beets:search-disconnected", tracks=[])

self._validate_query(query)
search_list = []
for field, values in query.items():
Expand Down Expand Up @@ -178,10 +175,7 @@

def get_distinct(self, field, query=None):
logger.debug("Beets distinct query: %s (uri=%s)", field, query)
if not self.remote.has_connection:
return []
else:
return self.remote.get_sorted_unique_track_attributes(field)
return self.remote.get_sorted_unique_track_attributes(field)

Check warning on line 178 in mopidy_beets/library.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/library.py#L178

Added line #L178 was not covered by tests

def _validate_query(self, query):
for values in query.values():
Expand Down