Tracking YouTube watch history
Asked Answered
H

1

14

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.

While I managed to add Google Calendar events, I couldn't get my YouTube watch history.

So I was wondering if the v3 API offers something like that, or is there some kind of trick creating a playlist?

Hartle answered 28/10, 2017 at 8:21 Comment(2)
Have you looked at https://mcmap.net/q/540409/-how-to-get-watched-history-of-youtube-user-using-youtube-javascript-api ?Ceramic
I did, thanks. It returns "HL" which is not goodHartle
B
33

It unfortunately seems like this feature has been put to sleep by the YouTube API team.

In August 11, 2016, 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.

On September 15, 2016, they announced they had removed this information from the APIs: (emphasis mine)

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.

On November 2, 2016, they even 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.

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.

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.

Bendix answered 5/11, 2017 at 1:22 Comment(3)
PS: I wrote this all in an iPad (yes, format and everything) so you've got to give me some credit. :PBendix
Thanks alpha, have you found another way to get watch history for your own account?Pastoral
@AkinHwan I just did another review and test of their APIs and it seems it is not possible still. :(Bendix

© 2022 - 2024 — McMap. All rights reserved.