【问题标题】:Retriving Youtube playlist information trough You Tube API (python)通过 Youtube API (python) 检索 Youtube 播放列表信息
【发布时间】:2011-12-11 08:55:31
【问题描述】:

我在使用 Python YouTube API 获取播放列表中视频的标题时遇到了一点问题。我已经正确配置了环境,当我从 API 文档中复制示例时,它也适用于添加的播放列表 ID,但是当我尝试使用其他播放列表中的一个时,出现错误。

这是我写的一些代码:(在这个例子中,我尝试获取视频的标题from here

import gdata.youtube
import gdata.youtube.service

yt_service = gdata.youtube.service.YouTubeService()
yt_service.ssl = True

# a typical playlist URI
playlist_uri = "http://gdata.youtube.com/feeds/api/playlists/PLCD939C4D974A5815"

playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(playlist_uri)

# iterate through the feed as you would with any other
for playlist_video_entry in playlist_video_feed.entry:
    print playlist_video_entry.title.text

这是我得到的错误:

RequestError: {'status': 400, 'body': 'Invalid playlist id', 'reason': 'Bad Request'}

我对此感到非常沮丧,希望能得到一些帮助。谢谢!

【问题讨论】:

    标签: python api youtube-api


    【解决方案1】:

    在您的请求 URI 中删除 PL

    playlist_uri = "http://gdata.youtube.com/feeds/api/playlists/CD939C4D974A5815"
    

    我不确定为什么YouTube 需要它采用这种格式,但它确实需要。

    你也可以在你的字符串上做一个.replace('playlists/PL', 'playlists/')

    【讨论】:

    • 你先生是个天才!谢谢。
    • 我猜我运气不错。我什至从未使用过 YouTube API ;)
    猜你喜欢
    • 1970-01-01
    • 2012-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 2016-12-07
    相关资源
    最近更新 更多