diff --git a/oxweb/youtube.py b/oxweb/youtube.py index a7c44f4..d00ce91 100644 --- a/oxweb/youtube.py +++ b/oxweb/youtube.py @@ -11,12 +11,17 @@ from oxlib import findString, findRe def getVideoKey(youtubeId): + data = getUrl("http://www.youtube.com/watch?v=%s" % youtubeId) + match = re.compile(".*[?&]t=([^&]+).*").findall(data) + if match: + return match[0] try: conn = httplib.HTTPConnection ("www.youtube.com") conn.request ("HEAD", '/v/' + youtubeId) response = conn.getresponse () conn.close () except: + print "failed to make connection" return False if response.status >= 300 and response.status < 400: @@ -24,6 +29,8 @@ def getVideoKey(youtubeId): match = re.match(".*[?&]t=([^&]+)", location) if match: return match.groups()[0] + print response.status + print "no match" return False def getVideoUrl(youtubeId, format='mp4'):