使用Python GData API,无法获取可编辑的视频条目

发布于 2024-12-20 13:47:58 字数 985 浏览 2 评论 0原文

我在获取包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事还在继续 2024-12-27 13:47:58

我刚刚使用 gdata 和 ProgrammaticLogin() 删除了 YouTube 视频,

以下是一些重现步骤:

import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()

yt_service.developer_key = 'developer_key'
yt_service.email = 'email'
yt_service.password = 'password'
yt_service.ProgrammaticLogin()


# video_id should looks like 'iu6Gq-tUsTc'
uri = 'https://gdata.youtube.com/feeds/api/users/%s/uploads/%s' % (username, video_id)  
entry = yt_service.GetYouTubeUserEntry(uri=uri)
response = yt_service.DeleteVideoEntry(entry)
print response  # True

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:

import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()

yt_service.developer_key = 'developer_key'
yt_service.email = 'email'
yt_service.password = 'password'
yt_service.ProgrammaticLogin()


# video_id should looks like 'iu6Gq-tUsTc'
uri = 'https://gdata.youtube.com/feeds/api/users/%s/uploads/%s' % (username, video_id)  
entry = yt_service.GetYouTubeUserEntry(uri=uri)
response = yt_service.DeleteVideoEntry(entry)
print response  # True

yt_service.GetYouTubeVideoFeed(uri) works because GetYouTubeVideoFeed doesn't check uri and just calls self.Get(uri, ...) but originaly, I think, it expected 'https://gdata.youtube.com/feeds/api/videos' uri.

vice versa yt_service.GetYouTubeVideoEntry() use YOUTUBE_VIDEO_URI = 'https://gdata.youtube.com/feeds/api/videos' but this entry doesn't contains rel="edit"

Hope that helps you out

泅渡 2024-12-27 13:47:58

您可以通过将调试标志设置为 true 来查看生成的请求的 HTTP 标头。这很简单:

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

您可以在此处的文档中阅读相关内容。< /a>

You can view the HTTP headers of the generated requests by setting the debug flag to true. This is as simple as:

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

You can read about this in the documentation here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文