diff --git a/mopidy_beets/browsers/albums.py b/mopidy_beets/browsers/albums.py index 9db1494..ebffde0 100644 --- a/mopidy_beets/browsers/albums.py +++ b/mopidy_beets/browsers/albums.py @@ -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 ] diff --git a/mopidy_beets/client.py b/mopidy_beets/client.py index dfc652d..2bf79e5 100644 --- a/mopidy_beets/client.py +++ b/mopidy_beets/client.py @@ -52,17 +52,12 @@ def _memoized(*args): class BeetsRemoteClient: - def __init__(self, endpoint, proxy_config): + def __init__(self, endpoint, proxy_config, request_timeout=4): super().__init__() + self._request_timeout = request_timeout 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) def _get_session(self, proxy_config): proxy = httpclient.format_proxy(proxy_config) @@ -273,7 +268,7 @@ def _get(self, url, raise_not_found=False): 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) except RequestException as e: logger.error("Beets - Request %s, failed with error %s", url, e) return None diff --git a/mopidy_beets/library.py b/mopidy_beets/library.py index 810057a..f20a056 100644 --- a/mopidy_beets/library.py +++ b/mopidy_beets/library.py @@ -89,9 +89,6 @@ def search(self, query=None, uris=None, exact=False): 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(): @@ -178,10 +175,7 @@ def lookup(self, uri=None, uris=None): 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) def _validate_query(self, query): for values in query.values():