1
0
mirror of https://github.com/azlux/botamusique synced 2024-11-23 22:06:09 +00:00

Compare commits

..

No commits in common. "ba02cdebf2e175dc371995361eafcb88ad2c1b52" and "6faadd6669aa27f1c65bf7327f2b2eccf6b15255" have entirely different histories.

View File

@ -22,13 +22,11 @@ def get_radio_server_description(url):
url_icecast = base_url + '/status-json.xsl' url_icecast = base_url + '/status-json.xsl'
url_shoutcast = base_url + '/stats?json=1' url_shoutcast = base_url + '/stats?json=1'
try: try:
response = requests.head(url_shoutcast, timeout=3) r = requests.get(url_shoutcast, timeout=10)
if not response.headers.get('content-type', '').startswith(("audio/", "video/")): data = r.json()
response = requests.get(url_shoutcast, timeout=10) title_server = data['servertitle']
data = response.json() return title_server
title_server = data['servertitle'] # logging.info("TITLE FOUND SHOUTCAST: " + title_server)
return title_server
# logging.info("TITLE FOUND SHOUTCAST: " + title_server)
except (requests.exceptions.ConnectionError, except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError, requests.exceptions.HTTPError,
requests.exceptions.ReadTimeout, requests.exceptions.ReadTimeout,
@ -40,18 +38,16 @@ def get_radio_server_description(url):
return url return url
try: try:
response = requests.head(url_shoutcast, timeout=3) r = requests.get(url_icecast, timeout=10)
if not response.headers.get('content-type', '').startswith(("audio/", "video/")): data = r.json()
response = requests.get(url_icecast, timeout=10) source = data['icestats']['source']
data = response.json() if type(source) is list:
source = data['icestats']['source'] source = source[0]
if type(source) is list: title_server = source['server_name']
source = source[0] if 'server_description' in source:
title_server = source['server_name'] title_server += ' - ' + source['server_description']
if 'server_description' in source: # logging.info("TITLE FOUND ICECAST: " + title_server)
title_server += ' - ' + source['server_description'] return title_server
# logging.info("TITLE FOUND ICECAST: " + title_server)
return title_server
except (requests.exceptions.ConnectionError, except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError, requests.exceptions.HTTPError,
requests.exceptions.ReadTimeout, requests.exceptions.ReadTimeout,