include h264 links

This commit is contained in:
j 2008-04-30 16:20:29 +02:00
parent ab67ab9500
commit 7b22d50d82

View file

@ -11,11 +11,15 @@ import feedparser
from oxutils.cache import getUrl from oxutils.cache import getUrl
from oxutils import findString from oxutils import findString
def getVideoUrl(youtubeId): def getVideoUrl(youtubeId, format='mp4'):
url = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=' + youtubeId url = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=' + youtubeId
data = getUrl(url) data = getUrl(url)
xml = ET.fromstring(data) xml = ET.fromstring(data)
youtubeKey = xml.find('t').text youtubeKey = xml.find('t').text
if format == 'mp4':
fmt=18
url = "http://youtube.com/get_video.php?video_id=%s&t=%s&fmt=%s"%(youtubeId, youtubeKey, fmt)
else:
url = "http://youtube.com/get_video.php?video_id=%s&t=%s"%(youtubeId, youtubeKey) url = "http://youtube.com/get_video.php?video_id=%s&t=%s"%(youtubeId, youtubeKey)
return url return url
@ -35,7 +39,8 @@ def getInfoFromAtom(entry):
info['url'] = entry['links'][0]['href'] info['url'] = entry['links'][0]['href']
info['id'] = findString(info['url'], "/watch?v=") info['id'] = findString(info['url'], "/watch?v=")
info['thumbnail'] = "http://img.youtube.com/vi/%s/0.jpg" % info['id'] info['thumbnail'] = "http://img.youtube.com/vi/%s/0.jpg" % info['id']
info['flv'] = getVideoUrl(info['id']) info['flv'] = getVideoUrl(info['id'], 'flv')
info['mp4'] = getVideoUrl(info['id'], 'mp4')
info['embed'] = '''<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/%s&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/%s&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>''' % (info['id'], info['id']) info['embed'] = '''<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/%s&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/%s&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>''' % (info['id'], info['id'])
return info return info