javascript - 跟踪 YouTube 观看历史

标签 javascript youtube youtube-api

为了自动跟踪我的时间,我想获取我的观看历史记录(最好的情况:一天一次,最坏的情况是一分钟一次),并将其添加为 Google 日历事件。

虽然我设法添加了 Google 日历事件,但无法获取我的 YouTube 观看历史记录。

所以我想知道 v3 API 是否提供类似的东西,或者是否有某种创建播放列表的技巧?

最佳答案

不幸的是,YouTube API 团队似乎已停止使用此功能。

2016 年 8 月 11 日,they announced that they would be deprecating the APIs for watch later and watch history playlists :

The channel resource's contentDetails.relatedPlaylists.watchHistory and contentDetails.relatedPlaylists.watchLater properties are only visible to an authorized user retrieving data about the user's own channel. After September 12, 2016, the contentDetails.relatedPlaylists.watchHistory will return a value of HL and the contentDetails.relatedPlaylists.watchLater property will return a value of WL for all channels.

Requests to retrieve playlist details (playlists.list) for a channel's watch history or watch later playlist will return an empty list after September 12, 2016. Requests to retrieve playlist items (playlistItems.list) in either of those playlists will also return an empty list after that time. This is true for the new values, HL and WL, as well as for any watch history or watch later playlist IDs that your API Client may have already stored.

2016 年 9 月 15 日,they announced they had removed this information from the APIs : (强调我的)

The channel resource's contentDetails.relatedPlaylists.watchHistory and contentDetails.relatedPlaylists.watchLater properties now contain values of HL and WL, respectively, for all channels.

To be clear, these properties are only visible to an authorized user retrieving data about the user's own channel. The properties always contain the values HL and WL, even for an authorized user retrieving data about the user's own channel. Thus, the watch history and watch later playlist IDs cannot be retrieved via the API.

In addition, requests to retrieve playlist details (playlists.list) or playlist items (playlistItems.list) for a channel's watch history or watch later playlist now return empty lists. This behavior is true for the new values, HL and WL, as well as for any watch history or watch later playlist IDs that your API Client may have already stored.

2016 年 11 月 2 日,他们甚至 announced new errors indicating that such contents cannot be retrieved from the API :

The playlistItems.list method returns this error to indicate that the request tried to retrieve "watch history" playlist items, but those cannot be retrieved using the API.

另一方面,有像 overview page 这样的文档和 migration from v2 guide仍然表示通过播放列表 API 获取 ID 的旧方法。我个人认为这些文档已经过时了。

如果我处于您的位置,我会围绕它解决我的要求,避免这种情况。您可以返回到 v2 或做一些其他事情,例如抓取网站,但如果 YouTube API 明确阻止这些内容提供给第三方,您可能会遇到法律问题。

关于javascript - 跟踪 YouTube 观看历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46987690/

相关文章:

javascript - jQuery - 变量增量+1

javascript - 使用 lodash 合并两个对象时如何过滤属性名称

javascript - 在 Meteor 中加载 YouTube 播放器 API

coldfusion - Youtube API V3 无法识别 playlistID 过滤器

xml - 从 YouTube 评论提要中获取用户拇指?

javascript - 获取数组的每四分之一并检查

javascript - 选择包含 Youtube 嵌入内容的 HTML 类时,JQuery 选择器不起作用

html - 从嵌入的 YouTube 视频中删除相关视频

youtube - 如何从YouTube数据API搜索结果中删除 `limitedSyndication`

javascript - CKEDITOR:文本未突出显示时禁用插件按钮