#!/usr/bin/env python

import urllib, re, os, sys

link0 = "http://www.nasa.gov/55644main_NASATV_Windows.asx"
tx = urllib.urlopen(link0).read()
link1 = re.search(r'<ref href="([^"]*)"\s*/>', tx).group(1)
print link1
tx = urllib.urlopen(link1).read()
try:
	link2 = re.search(r'<[Rr]ef href\s*=\s*"([^"]*)"\s*/>', tx).group(1)
except AttributeError:
	print tx
	sys.exit(1)
print link2
os.execl("/usr/bin/mplayer", "mplayer", "-cache", "100", "-fps", "27",
	"-vf", "crop=316:200:2:20", 
	link2)
#os.execl("/usr/bin/vlc", "vlc", link2)

