I am running a query on my own youtube channel to retrieve all the video titles. I have 680 videos but can only get about half of them. What I have done is create a code that iterates all the years since creation of the channel and within a year uses the pageTokens to go through the packs of 50 videos.
So a query would look like this:
https://www.googleapis.com/youtube/v3/search?key={XXXXX}&channelId={XXXXX}&part=snippet,id&order=date&type=video&maxResults=50&publishedAfter=2018-01-01T00:00:00Z&publishedBefore=2019-01-01T00:00:00Z&pageToken=CDIQAA
In the results for these queries, I get the indication that there are the following contents:
array (
'totalResults' => 321,
'resultsPerPage' => 50,
),
Iterating through the pages, I get 2 pages filled with 50 items, then another one where the results show as well 'resultsPerPage' => 50,
but contains only 35 videos, the rest for that year have 0 "items" in the JSON data. So the pages in question only give 135 results back instead of the 321. Once I switch to the next year, I get again 2 pages of full results, then one with some missing and then empty ones.
Any idea what could be wrong?
here is an excerpt of the last JSON data set:
array (
'kind' => 'youtube#searchListResponse',
'etag' => '"XpPGQXPnxQJhLgs6enD_n8JR4Qk/IsJyhRyDQ6qMmAHldktSRzEN2qs"',
'nextPageToken' => 'CJYBEAA',
'prevPageToken' => 'CGQQAQ',
'regionCode' => 'DE',
'pageInfo' =>
array (
'totalResults' => 321,
'resultsPerPage' => 50,
),
'items' =>
array (
0 =>
[..contents..]
35 =>
[..last content and closing brackets..]