mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
Add a timeout when fetching remote resources
This commit is contained in:
parent
370b5bae77
commit
306fc202bd
@ -201,7 +201,7 @@ def lyrics():
|
||||
|
||||
try:
|
||||
r = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect",
|
||||
params = { 'artist': artist, 'song': title })
|
||||
params = { 'artist': artist, 'song': title }, timeout = 5)
|
||||
root = ElementTree.fromstring(r.content)
|
||||
|
||||
ns = { 'cl': 'http://api.chartlyrics.com/' }
|
||||
|
@ -77,9 +77,9 @@ class LastFm:
|
||||
|
||||
try:
|
||||
if write:
|
||||
r = requests.post('http://ws.audioscrobbler.com/2.0/', data = kwargs)
|
||||
r = requests.post('http://ws.audioscrobbler.com/2.0/', data = kwargs, timeout = 5)
|
||||
else:
|
||||
r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs)
|
||||
r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs, timeout = 5)
|
||||
except requests.exceptions.RequestException as e:
|
||||
self.__logger.warning('Error while connecting to LastFM: ' + str(e))
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user