mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-12 21:22:17 +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:
|
try:
|
||||||
r = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect",
|
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)
|
root = ElementTree.fromstring(r.content)
|
||||||
|
|
||||||
ns = { 'cl': 'http://api.chartlyrics.com/' }
|
ns = { 'cl': 'http://api.chartlyrics.com/' }
|
||||||
|
@ -77,9 +77,9 @@ class LastFm:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if write:
|
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:
|
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:
|
except requests.exceptions.RequestException as e:
|
||||||
self.__logger.warning('Error while connecting to LastFM: ' + str(e))
|
self.__logger.warning('Error while connecting to LastFM: ' + str(e))
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user