Page 1 of 1

How to detect the url's availablility automatic?

Posted: 02 Apr 2013 11:32
by jackhuang
As subject. I have a long url list in a text file, I need verify the availability of the network url automatic. It should verify the network url and return the status of the url's availablility.
Does any solution can be provided?

Re: How to detect the url's availablility automatic?

Posted: 02 Apr 2013 17:07
by RĂ©mi Denis-Courmont
In general, the only way to check that an URL works is to try to play it...

Re: How to detect the url's availablility automatic?

Posted: 03 Apr 2013 07:10
by jackhuang
yes, I know the command for VLC to play a url, but not found which cmd can check the playback is ok.
Dose any api can help this?

Re: How to detect the url's availablility automatic?

Posted: 03 Apr 2013 12:29
by Jean-Baptiste Kempf
Depends on the interface you use.

Re: How to detect the url's availablility automatic?

Posted: 08 Apr 2013 08:23
by jackhuang
Bingo. I use the Python to finish the function. Python binding the libvlc.dll. I would improve the component and package it executable.
Actually, My initial purpose is automatic check the network channels and get available channels. Because I have a Android TV, it can play the
network channel stream, I get a channel list about 10000 channels url. So I could use the tool to get useful channel import my TV.
Dose anyone how to add it as a VLC extensions?

Code: Select all

import os import time import string import vlc ########################################################## #network channel source url source_url="c:\\tmp\\channel_source.txt" #processed channel url channel_url="c:\\tmp\\channel_result.txt" #interval time for channel checking check_time=10 ######################################################### #create vlc instance and media_player #ins=vlc.Instance() #mplay=ins.media_player_new() #Get result file file_obj=open(source_url,'r') channel_result=open(channel_url,'w') channel_num=0 ######################################################## print "Process steps: " print " 1.Open a channel url" print " 2.Wait 10 seconds for buffering" print " 3.Check playback status" print " 4.Release the media and go on next" print "Start process channel url..." try: for line_url in file_obj: #process network stream mplay=vlc.MediaPlayer(line_url.strip()) mplay.play() time.sleep(check_time) #check channel availability video_width=mplay.video_get_width() print "==================================================" channel_num=channel_num+1 print "Channel Num=" + str(channel_num) if(video_width>0): print "The available channel video width= " + str(video_width) print "channel_url= " + line_url #write available url to channel_result good_result="YES " + line_url channel_result.writelines(good_result) else: print "The channel is unavailablity!" print "channel_url= " + line_url #write unavailable url to channel_result bad_result="BAD " + line_url channel_result.writelines(bad_result) channel_result.flush() mplay.release() finally: file_obj.close() channel_result.close()