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):
|
||||
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'):
|
||||
|
|
Loading…
Reference in a new issue