get key from site again

This commit is contained in:
j 2008-12-09 19:25:35 +01:00
parent 141294fee0
commit bf1967e6ea

View file

@ -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'):