Are you trying to check if a streaming URL exists?
If so, it will be exactly the same as checking any other URL if one exists.
One way is to try to get the URL using urllib, and check the received status code.
200 - exists
Everything else (for example, 404) - does not exist or you cannot access it.
For instance:
import urllib
url = 'http://aska.ru-hoster.com:8053/autodj'
code = urllib.urlopen(url).getcode()
if str(code).startswith('2') or str(code).startswith('3') :
print 'Stream is working'
else:
print 'Stream is dead'
EDIT-1
So far, the URL will be detected or not. It will not catch if the URL exists and the media link is broken.
vlc URL-, . , , .
URL-
url = 'http://aska.ru-hoster.com:8053/autodj'
>>>
Stream is working. Current state = State.Playing
URL-
url = 'http://aska.ru-hoster.com:8053/autodj12345'
>>>
Stream is dead. Current state = State.Error
. VLC, .
import vlc
import time
url = 'http://aska.ru-hoster.com:8053/autodj'
instance = vlc.Instance('--input-repeat=-1', '--fullscreen')
player=instance.media_player_new()
media=instance.media_new(url)
player.set_media(media)
player.play()
time.sleep(5)
state = str(player.get_state())
if state == "vlc.State.Error" or state == "State.Error":
print 'Stream is dead. Current state = {}'.format(state)
player.stop()
else:
print 'Stream is working. Current state = {}'.format(state)
player.stop()