It seems like the cheapest way to get all video information from a given channel is to use "uploads" found from the channel's "contentDetails" as mentioned here. But this returns only the most recent 20,000 video information. (in Python)
CNN_ID = "UCupvZG-5ko_eiXAupbDfxWw" # CNN channel ID
search_kwargs = {
"part": "contentDetails",
"id": CNN_ID,
}
results = youtube.channels().list(**search_kwargs).execute()
playlist_id = results["items"][0]["contentDetails"]["relatedPlaylists"]["uploads"]
search_kwargs = {
"part": "snippet",
"playlistId": CNN_ID,
}
results = youtube.playlistItems().list(**search_kwargs).execute()
n_total = results["pageInfo"]["totalResults"] # 20000
It seems like all the videos that are included in one of the playlists (e.g. CNN), I could get their information using Playlists, e.g.
search_kwargs = {
"part": "snippet",
"channelId": CNN_ID,
}
results = []
while True:
results.extend(youtube.playlists().list(**search_kwargs).execute()["items"])
if "nextPageToken" not in results[-1]:
break
search_kwargs["pageToken"] = results[-1]["nextPageToken"]
pids = [item["id"] for item in results]
n_total = 0
for pid in pids:
search_kwargs = {
"part": "snippet",
"playlistId": pid,
}
results = youtube.playlistItems().list(**search_kwargs).execute()
n_total += results["pageInfo"]["totalResults"]
# n_total == 42579
and these videos include older ones. But I still cannot get information of old videos that are not included in any playlist. Is there a way I can get them without using Search?