This commit is contained in:
j 2010-03-09 19:22:49 +05:30
parent b643997518
commit ef49aae822

View file

@ -19,12 +19,18 @@ def getVideoKey(youtubeId):
def getVideoUrl(youtubeId, format='mp4'):
youtubeKey = getVideoKey(youtubeId)
if format == '1080p':
fmt=37
url = "http://youtube.com/get_video.php?video_id=%s&t=%s&fmt=%s" % (youtubeId, youtubeKey, fmt)
if format == '720p':
fmt=22
url = "http://youtube.com/get_video.php?video_id=%s&t=%s&fmt=%s" % (youtubeId, youtubeKey, fmt)
elif format == 'mp4':
fmt=18
url = "http://youtube.com/get_video.php?video_id=%s&t=%s&fmt=%s" % (youtubeId, youtubeKey, fmt)
elif format == 'high':
fmt=35
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)
return url
@ -51,8 +57,10 @@ def getInfoFromAtom(entry, video_url_base=None):
info['mp4'] = "%s/%s.%s" % (video_url_base, info['id'], 'mp4')
else:
info['flv'] = getVideoUrl(info['id'], 'flv')
info['flv_high'] = getVideoUrl(info['id'], 'high')
info['mp4'] = getVideoUrl(info['id'], 'mp4')
info['720p'] = getVideoUrl(info['id'], '720p')
info['1080p'] = getVideoUrl(info['id'], '1080p')
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