#!/usr/bin/env python
#
# Use this to detect if somsone's trying to rickroll you.
# it fetches and parses the <title> element from the
# requested youtube URL to at least give you an idea.
import re,urllib2,sys
__author__ = "Nick Guy"
__license__ = "GPL"
# some CLI processing BS here
if ( len( sys.argv ) == 2):
youtube_url = sys.argv[1];
else:
print "Usage: " + sys.argv[0] + " "
sys.exit(1)
test = urllib2.urlopen(youtube_url)
data = test.read(1000)
title_regex = re.compile("<title>(.+)</title>")
title_text = title_regex.search(data).group(1)
print title_text