0

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?

  • Unfortunately, the answer to your question is: *no, there no other way*, if using the YouTube Data API. – stvar Feb 03 '21 at 20:54
  • @stvar That is really sad! Is there a reference explaining why they limited to 20,000? – anton-sturluson Feb 04 '21 at 03:48
  • No, they never give such kind of explanations for any of their *undocumented* but *acknowledged* limits imposed. You may well browse the company's [issue tracker](https://issuetracker.google.com/issues?q=componentid:186600) to experience yourself the kind of raw answers they're used to provide. (Just one [example](https://issuetracker.google.com/issues/166292064#comment2).) – stvar Feb 04 '21 at 08:25

1 Answers1

0

Well, the best way to do this (at least in my knowledge) is to use Selenium to collect video ids from Youtube. One would have to find the Videos section of the channel of interest and collect video is while scrolling down.