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?
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()
Return to “General VLC media player Troubleshooting”
Users browsing this forum: No registered users and 58 guests