Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a user's entire YouTube watch history?

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.

like image 558
Fsmv Avatar asked May 15 '13 04:05

Fsmv


People also ask

Can you view full YouTube history?

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.

How far back does YouTube watch history go?

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.


1 Answers

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

like image 67
vol7ron Avatar answered Sep 20 '22 07:09

vol7ron