unquote youtube key

This commit is contained in:
j 2009-07-24 12:46:59 +02:00
parent 7274f400ad
commit e11f98b676
1 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from urllib import quote
from urllib import quote, unquote
import httplib
import xml.etree.ElementTree as ET
import re
@ -14,7 +14,7 @@ def getVideoKey(youtubeId):
data = getUrl("http://www.youtube.com/watch?v=%s" % youtubeId)
match = re.compile(".*[?&]t=([^&]+).*").findall(data)
if match:
return match[0]
return unquote(match[0])
try:
conn = httplib.HTTPConnection ("www.youtube.com")
conn.request ("HEAD", '/v/' + youtubeId)
@ -27,7 +27,7 @@ def getVideoKey(youtubeId):
location = response.getheader("location")
match = re.match(".*[?&]t=([^&]+)", location)
if match:
return match.groups()[0]
return unquote(match.groups()[0])
return False
def getVideoUrl(youtubeId, format='mp4'):