get key from site again
This commit is contained in:
parent
141294fee0
commit
bf1967e6ea
1 changed files with 7 additions and 0 deletions
|
@ -11,12 +11,17 @@ from oxlib import findString, findRe
|
||||||
|
|
||||||
|
|
||||||
def getVideoKey(youtubeId):
|
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:
|
try:
|
||||||
conn = httplib.HTTPConnection ("www.youtube.com")
|
conn = httplib.HTTPConnection ("www.youtube.com")
|
||||||
conn.request ("HEAD", '/v/' + youtubeId)
|
conn.request ("HEAD", '/v/' + youtubeId)
|
||||||
response = conn.getresponse ()
|
response = conn.getresponse ()
|
||||||
conn.close ()
|
conn.close ()
|
||||||
except:
|
except:
|
||||||
|
print "failed to make connection"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if response.status >= 300 and response.status < 400:
|
if response.status >= 300 and response.status < 400:
|
||||||
|
@ -24,6 +29,8 @@ def getVideoKey(youtubeId):
|
||||||
match = re.match(".*[?&]t=([^&]+)", location)
|
match = re.match(".*[?&]t=([^&]+)", location)
|
||||||
if match:
|
if match:
|
||||||
return match.groups()[0]
|
return match.groups()[0]
|
||||||
|
print response.status
|
||||||
|
print "no match"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getVideoUrl(youtubeId, format='mp4'):
|
def getVideoUrl(youtubeId, format='mp4'):
|
||||||
|
|
Loading…
Reference in a new issue