使用Python GData API,无法获取可编辑的视频条目
我在获取包含 rel="edit" 链接的视频条目时遇到问题。我需要这样的条目以便能够对其调用 DeleteVideoEntry(...)
。
我正在使用 GetYouTubeVideoEntry(youtube_id=XXXXXXX)
检索视频。我的 yt_service 使用用户名、密码和开发人员密钥进行初始化。我使用编程登录。这部分似乎工作得很好。我之前使用相同的 yt_service 上传所述视频。另外,如果我将开发人员密钥更改为伪造的密钥(在调试期间)并尝试进行身份验证,则会收到 403 错误。这让我相信身份验证工作正常。
不用说,使用 GetYouTubeVideoEntry(youtube_id=XXXXXXX)
检索的视频条目不包含编辑链接,我无法在 DeleteVideoEntry(...)
调用中使用该条目。
是否有一些特殊的方法来获取包含带有 rel="edit" 的链接元素的视频条目?谁能建议一些方法来解决我的问题?这可能是一个错误吗?
更新:
根据记录,当我尝试获取所有上传的提要,然后循环浏览视频条目时,视频条目确实有一个编辑链接。所以使用这个有效:
uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads' % username
feed = yt_service.GetYouTubeVideoFeed(uri)
for entry in feed.entry:
yt_service.DeleteVideoEntry(entry)
但这不行:
entry = yt_service.GetYouTubeVideoEntry(video_id = video.youtube_id)
yt_service.DeleteVideoEntry(entry)
使用相同的 yt_service。
I am having trouble getting a video entry which includes a link rel="edit". I need such an entry in order to be able to call DeleteVideoEntry(...)
on it.
I am retrieving the video using GetYouTubeVideoEntry(youtube_id=XXXXXXX)
. My yt_service is initialized with a username, password, and a developer key. I use ProgrammaticLogin. This part seems to work fine. I use the same yt_service to upload said video earlier. Also, if I change the developer key to something bogus (during debugging) and try to authenticate, I get a 403 error. This leads me to believe that authentication works OK.
Needsless to say, the video entry retrieved with GetYouTubeVideoEntry(youtube_id=XXXXXXX)
does not contain the edit link and I cannot use the entry in a DeleteVideoEntry(...)
call.
Is there some special way to get a video entry which will contain a link element with a rel="edit"? Can anyone suggest some way to resolve my issue? Could this possibly be a bug?
Update:
For the records, when I tried getting the feed of all my uploads, and then looping through the video entries, the video entries do have an edit link. So using this works:
uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads' % username
feed = yt_service.GetYouTubeVideoFeed(uri)
for entry in feed.entry:
yt_service.DeleteVideoEntry(entry)
But this does not:
entry = yt_service.GetYouTubeVideoEntry(video_id = video.youtube_id)
yt_service.DeleteVideoEntry(entry)
Using the same yt_service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚使用 gdata 和 ProgrammaticLogin() 删除了 YouTube 视频,
以下是一些重现步骤:
yt_service.GetYouTubeVideoFeed(uri)
有效,因为GetYouTubeVideoFeed
不检查 uri,只是调用self.Get(uri, ...)
但最初,我认为它期望'https://gdata.youtube.com/feeds/api/videos'
乌里。反之亦然
yt_service.GetYouTubeVideoEntry()
使用YOUTUBE_VIDEO_URI = 'https://gdata.youtube.com/feeds/api/videos'
但此条目不包含rel="edit"
希望对您有帮助
I've just deleted youtube video using gdata and ProgrammaticLogin()
Here is some steps to reproduce:
yt_service.GetYouTubeVideoFeed(uri)
works becauseGetYouTubeVideoFeed
doesn't check uri and just callsself.Get(uri, ...)
but originaly, I think, it expected'https://gdata.youtube.com/feeds/api/videos'
uri.vice versa
yt_service.GetYouTubeVideoEntry()
useYOUTUBE_VIDEO_URI = 'https://gdata.youtube.com/feeds/api/videos'
but this entry doesn't containsrel="edit"
Hope that helps you out
您可以通过将调试标志设置为 true 来查看生成的请求的 HTTP 标头。这很简单:
您可以在此处的文档中阅读相关内容。< /a>
You can view the HTTP headers of the generated requests by setting the debug flag to true. This is as simple as:
You can read about this in the documentation here.