I work on collecting internet radio stream files such as m3u with a link to stream inside (for example http://aska.ru-hoster.com:8053/autodj).
I didn`t find example on how it is possible to check if the link is avaliable/live.
Any help is appreciated!
UPD:
Maybe the main question should sound like:
Could be a stream broken? If yes, will the link for that stream be still available or there will be simply 404 error in browser? If link still available to open even stream is dead, what are other methods to check the stream?
Are you trying to check if the streaming URL exists?
If yes, it will be just like checking any other url if it exists.
One way will be to try getting url using
urllib
and check for returned status code.For example:
EDIT-1
While above will catch if a URL exists or not. It will not catch if URL exists and media link is broken.
One possible solution using
vlc
is to get the media from url, try to play it and get its status while playing. If media doesnt exists, we will get error which can be used to determine link status.With working URL we get
With broken URL we get,
Below is basic logic to achieve above. You may want to check VLC site to catch other error types and better methods.