【问题标题】:Remove video from youtube watch later by python gdata library稍后通过 python gdata 库从 youtube 中删除视频
【发布时间】:2013-10-29 21:45:24
【问题描述】:

以后如何通过 python gdata 库从 youtube watch 中删除视频? 我检查 API:https://developers.google.com/youtube/2.0/developers_guide_protocol?hl=en#Retrieving_watch_later_playlist, 并尝试它的方法: 从播放列表中删除视频: https://gdata.youtube.com/feeds/api/users/default/watch_later/VIDEO_ID.

通过python gdata库

playlist_uri = u"https://gdata.youtube.com/feeds/api/users/default/watch_later"
playlist_entry_id = videoID .............(Does watch later have playlist_entry_id??)
response = yt_service.DeletePlaylistVideoEntry(playlist_uri,
                                               playlist_entry_id)
=>Error: Bad request

playlist_uri = u"https://gdata.youtube.com/feeds/api/users/default/watch_later/%s" % videoID
response = yt_service.Delete("playlist_uri)
=>Error: Bad request

都失败了!

还有其他方法可以获取吗?非常感谢。

【问题讨论】:

  • DeletePlaylistVideoEntry(playlist_uri, playlist_entry_id 是要走的路,你的错误信息是什么或会发生什么?为什么这不起作用?请给我们线索和代码。另请注意,https://gdata.youtube.com/feeds/api/users/default/watch_later/ 似乎是一个无效的 URI
  • 亲爱的 Torxed,我按照“稍后观看”进行编码,但我不知道如何使用 API 定义的 uri“gdata.youtube.com/feeds/api/users/default/watch_later/…>”。此外,如果使用 DeletePlaylistVideoEntry(playlist_uri, playlist_entry_id) 工作,playlist_uri, playlist_entry_id 在稍后观看是什么?非常感谢。
  • 首先你需要比这两行更多的代码,你需要初始化YouTubeService,然后你需要找到播放列表和它的实际名称(不确定watch_later是否正确,可能是只是实际播放列表的别名.. 但无论如何)查看这个参考库,看看它是否有帮助(你可以形成自己的请求):developers.google.com/youtube/2.0/…

标签: python youtube


【解决方案1】:

经过一次又一次的测试和尝试,在我的开发环境中可以成功执行的代码与Youtube文档:https://developers.google.com/youtube/2.0/developers_guide_protocol?hl=en#Retrieving_watch_later_playlist非常不同。

仅供参考。
1. 使用 playlist_entry_id 代替 VIDEO_ID:
- 如何获取稍后观看的每个视频的 playlist_entry_id?
.通用播放列表:entry.id.text.split('/')[-1]
.稍后观看播放列表:entry.id.text.split('watch_later:')[-1]
2. API URL需要添加'?v=2'

我的答案:
playlist_uri = https://gdata.youtube.com/feeds/api/users/default/watch_later/playlist_entry_id?v=2
self.__ytService.Delete(playlist_uri)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-31
    • 2017-02-27
    • 2012-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-21
    相关资源
    最近更新 更多