I'm trying to get a full list of watched videos for a given user in my YouTube API application. I want to add up total duration of all videos.
When I get the list of videos from history playlist, the API caps it at 50 items. There's pagination but total amount of items is 50 (not just per page); I can't access more data with the API it appears.
Is there any way I can get this playlist without the data cap? I'm hoping for another method (of using the API) or a way to do it without the API. I know YouTube stores this data because I can view my entire history (far more that 50 videos).
I'm using this code:
var requestOptions = { playlistId: playlistId, part: 'snippet', maxResults: 50 }; gapi.client.youtube.playlistItems.list(requestOptions);
where playlistId
is the id of the history playlist I got from a gapi.client.youtube.channels.list
request.
Edit (2017): I want to clarify that it was always my intention to download my own history, just out of interest to see how much time I have spent watching videos. I still have not been able to do this.
Sign in and go to myactivity.google.com to find videos that you've viewed on the YouTube app or website while signed in. It also includes videos you've watched in a YouTube player on other websites while signed in to Google Chrome.
YouTube's options allow users to set their account to keep history data for 3 months, 18 months, or until they choose to manually delete it.
The API currently only retrieves the last two weeks of Watch History. For more information refer to the Bug Issue reported: https://code.google.com/p/gdata-issues/issues/detail?id=4642
Note: There is a similar question on SO asked here: YouTube API v3 returns truncated watch history
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With