radio: don't get stuck on mpd http streams
Merge pull request #285 from mweinelt/mpd-radio-stream
This commit is contained in:
		@@ -22,8 +22,10 @@ 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:
 | 
				
			||||||
        r = requests.get(url_shoutcast, timeout=10)
 | 
					        response = requests.head(url_shoutcast, timeout=3)
 | 
				
			||||||
        data = r.json()
 | 
					        if not response.headers.get('content-type', '').startswith(("audio/", "video/")):
 | 
				
			||||||
 | 
					            response = requests.get(url_shoutcast, timeout=10)
 | 
				
			||||||
 | 
					            data = response.json()
 | 
				
			||||||
            title_server = data['servertitle']
 | 
					            title_server = data['servertitle']
 | 
				
			||||||
            return title_server
 | 
					            return title_server
 | 
				
			||||||
            # logging.info("TITLE FOUND SHOUTCAST: " + title_server)
 | 
					            # logging.info("TITLE FOUND SHOUTCAST: " + title_server)
 | 
				
			||||||
@@ -38,8 +40,10 @@ def get_radio_server_description(url):
 | 
				
			|||||||
        return url
 | 
					        return url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        r = requests.get(url_icecast, timeout=10)
 | 
					        response = requests.head(url_shoutcast, timeout=3)
 | 
				
			||||||
        data = r.json()
 | 
					        if not response.headers.get('content-type', '').startswith(("audio/", "video/")):
 | 
				
			||||||
 | 
					            response = requests.get(url_icecast, timeout=10)
 | 
				
			||||||
 | 
					            data = response.json()
 | 
				
			||||||
            source = data['icestats']['source']
 | 
					            source = data['icestats']['source']
 | 
				
			||||||
            if type(source) is list:
 | 
					            if type(source) is list:
 | 
				
			||||||
                source = source[0]
 | 
					                source = source[0]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user