def episode(request):
""" Get all the information and the video links from a given episode.
How: use youtube-dl to get the information
"""
episode_url = request.matchdict['episode_url']
url = EITB_VIDEO_BASE_URL + episode_url
try:
playlist_title, playlist_id, video_title, video_id = episode_url.split('/')
except ValueError:
return {}
result = {
'@context': 'http://www.w3.org/ns/hydra/context.jsonld',
'@id': request.route_url('episode', episode_url=episode_url),
'@type': 'Episode',
'parent': request.route_url('playlist', playlist_id=playlist_id),
}
try:
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'})
video_data = ydl.extract_info(url, download=False)
except youtube_dl.DownloadError:
return result
result.update(video_data)
return result
评论列表
文章目录