diff --git a/headphones/searcher.py b/headphones/searcher.py index 11f07718..6dfe0640 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1070,11 +1070,11 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): bitrate = None bitrate_string = bitrate - if headphones.PREFERRED_QUALITY == 2 or losslessOnly: # Lossless Only mode + if headphones.PREFERRED_QUALITY == 3 or losslessOnly: # Lossless Only mode search_formats = [gazelleformat.FLAC] maxsize = 10000000000 - elif headphones.PREFERRED_QUALITY == 3: # Preferred quality mode - search_formats=[None] # should return all + elif headphones.PREFERRED_QUALITY == 2: # Preferred quality mode + search_formats = [None] # should return all bitrate = headphones.PREFERRED_BITRATE if bitrate: for encoding_string in gazelleencoding.ALL_ENCODINGS: diff --git a/lib/pygazelle/api.py b/lib/pygazelle/api.py index 75272cd5..4e93b47d 100644 --- a/lib/pygazelle/api.py +++ b/lib/pygazelle/api.py @@ -51,6 +51,7 @@ class GazelleAPI(object): self.passkey = None self.userid = None self.logged_in_user = None + self.default_timeout = 30 self.cached_users = {} self.cached_artists = {} self.cached_tags = {} @@ -97,7 +98,8 @@ class GazelleAPI(object): loginpage = 'https://what.cd/login.php' data = {'username': self.username, 'password': self.password} - r = self.session.post(loginpage, data=data) + r = self.session.post(loginpage, data=data, timeout=self.default_timeout) + self.past_request_timestamps.append(time.time()) if r.status_code != 200: raise LoginException("Login returned status code %s" % r.status_code) @@ -112,7 +114,6 @@ class GazelleAPI(object): self.passkey = accountinfo['passkey'] self.logged_in_user = User(self.userid, self) self.logged_in_user.set_index_data(accountinfo) - self.past_request_timestamps.append(time.time()) def request(self, action, autologin=True, **kwargs): """ @@ -153,7 +154,7 @@ class GazelleAPI(object): if self.authkey: params['auth'] = self.authkey params.update(kwargs) - r = self.session.get(url, params=params, allow_redirects=False) + r = self.session.get(url, params=params, allow_redirects=False, timeout=self.default_timeout) self.past_request_timestamps.append(time.time()) return r.content