tv.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:eitbapi 作者: erral 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号