问题描述
为了自动跟踪我的时间,我想获取我的观看历史记录(最佳情况:每天一次,最坏情况每分钟一次),并将其添加为 Google 日历事件.
In an effort to automate tracking my time, I would like to get my watch history (best case: once a day, worst case once a minute), and to add it as Google Calendar events.
虽然我设法添加了 Google 日历活动,但无法获取我的 YouTube 观看记录.
While I managed to add Google Calendar events, I couldn't get my YouTube watch history.
所以我想知道 v3 API 是否提供类似的功能,或者是否有某种创建播放列表的技巧?
So I was wondering if the v3 API offers something like that, or is there some kind of trick creating a playlist?
推荐答案
很遗憾,YouTube API 团队似乎已停止使用此功能.
It unfortunately seems like this feature has been put to sleep by the YouTube API team.
2016 年 8 月 11 日,他们宣布将弃用用于稍后观看和观看历史播放列表的 API:
In August 11, 2016, they announced that they would be deprecating the APIs for watch later and watch history playlists:
频道资源的 contentDetails.relatedPlaylists.watchHistory
和 contentDetails.relatedPlaylists.watchLater
属性仅对检索有关用户自己频道的数据的授权用户可见.2016 年 9 月 12 日之后,contentDetails.relatedPlaylists.watchHistory
将返回 HL
的值,contentDetails.relatedPlaylists.watchLater
属性将返回一个所有通道的 WL
值.
检索频道观看历史或稍后观看播放列表的播放列表详细信息 (playlists.list
) 的请求将在 2016 年 9 月 12 日之后返回一个空列表.检索播放列表项目的请求 (playlistItems.list
) 在这些播放列表中的任何一个中也将在该时间之后返回一个空列表.这适用于新值 HL
和 WL
,以及您的 API 客户端可能已存储的任何观看历史记录或稍后观看播放列表 ID.
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 日,他们宣布已从API:(强调我的)
On September 15, 2016, they announced they had removed this information from the APIs: (emphasis mine)
频道资源的 contentDetails.relatedPlaylists.watchHistory
和 contentDetails.relatedPlaylists.watchLater
属性现在包含 HL
和 WL
,分别用于所有频道.
需要明确的是,这些属性仅对检索有关用户自己频道的数据的授权用户可见.这些属性始终包含值 HL
和 WL
,即使对于检索有关用户自己频道的数据的授权用户也是如此.因此,无法通过 API 检索观看历史记录和稍后观看播放列表 ID.
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.
此外,检索频道观看历史记录或稍后观看播放列表的播放列表详细信息 (playlists.list
) 或播放列表项 (playlistItems.list
) 的请求现在返回空列表.此行为适用于新值 HL
和 WL
,以及您的 API 客户端可能已存储的任何观看历史记录或稍后观看播放列表 ID.>
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 日,他们甚至宣布了新的错误,表明此类无法从 API 检索内容:
On November 2, 2016, they even announced new errors indicating that such contents cannot be retrieved from the API:
playlistItems.list
方法返回此错误以指示请求尝试检索观看历史记录"播放列表项,但无法使用 API 检索这些项.
另一方面,有诸如概述页面和从 v2 指南迁移 仍然表明获取 ID 的旧方法通过播放列表 API.我个人认为这些文档已经过时了.
On the other hand, there are documentation like the overview page and the migration from v2 guide that still indicate the old method of getting the IDs through the playlist API. I personally think these docs are just outdated.
如果我处于你的位置,我只会围绕它来满足我的要求,避免这种情况.您可以返回 v2 或执行其他一些操作,例如抓取网站,但如果 YouTube API 明确禁止第三方使用这些内容,您可能会遇到法律问题.
If I was in your position, I'd just work my requirement around it, avoiding this. You can go back to v2 or do some other stuff like scraping the website, but if the YouTube API is explicitly preventing these to be available to third parties, it might seem you could get into legal trouble.
这篇关于跟踪 YouTube 观看记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!