为了自动跟踪我的时间,我想获取我的观看历史记录(最好的情况:一天一次,最坏的情况是一分钟一次),并将其添加为 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
andcontentDetails.relatedPlaylists.watchLater
properties are only visible to an authorized user retrieving data about the user's own channel. After September 12, 2016, thecontentDetails.relatedPlaylists.watchHistory
will return a value ofHL
and thecontentDetails.relatedPlaylists.watchLater
property will return a value ofWL
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
andWL
, 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
andcontentDetails.relatedPlaylists.watchLater
properties now contain values ofHL
andWL
, 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
andWL
, 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
andWL
, 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/