Retour au sujet

Avatar de Mythopisse Mythopisse
Je vous copie-colle mon projet et la réponse de Grok

How would you go to :
Collect ALL the comments on a youtube channel
Browse ALL the accounts who made those comments
Check how many have zero (0) videos, and how many have only or mostly videogames gameplay videos
?



Official YouTube Data API v3 is the proper, supported way. Scraping (browser automation, reverse-engineering Innertube endpoints, etc.) violates YouTube’s Terms of Service, is fragile (YouTube changes endpoints frequently), can get your IPs/accounts blocked, and is not recommended for anything serious or large-scale.1. Collect (as many as possible of) the comments on a channelBest single call for “comments associated with the channel”:Use commentThreads.list with the parameter allThreadsRelatedToChannelId=CHANNEL_ID (instead of videoId).This returns comment threads on the channel itself and on the channel’s videos.
Include part=snippet,replies.
Paginate with pageToken / nextPageToken (max 100 results per page).
Each call costs 1 quota unit. Default daily quota is 10,000 units per Google Cloud project (resets midnight Pacific time). You can request a higher quota, but approval is not guaranteed and still limited.
Replies: the replies part only returns a small subset (usually up to 5). For full reply trees you must follow up with comments.list using parentId for each top-level comment that has more replies. That multiplies the quota cost significantly.

More complete (but far more expensive) approach:Get the channel’s uploads playlist ID via channels.list (part=contentDetails).
List all video IDs with playlistItems.list (or search.list with channelId + type=video).
For every video ID, call commentThreads.list + handle replies as above.

For a large channel this quickly exhausts the daily quota and becomes impractical (many channels have hundreds of thousands or millions of comments).You will get, for every comment:authorDisplayName
authorChannelId.value (the important unique channel ID of the commenter)
text, likes, timestamps, etc.

Store the unique authorChannelIds (a set/dictionary) so you don’t process the same commenter repeatedly.2. Browse / inspect all the accounts that commentedOnce you have the unique list of authorChannelIds:Call channels.list with id=comma-separated-list-of-up-to-50-IDs and part=statistics,contentDetails,snippet.This gives you statistics.videoCount (number of public videos) and the uploads playlist ID.
Cost is low (1 unit for up to 50 channels).

This tells you immediately how many have zero videos.3. Check how many have 0 videos, and how many have only/mostly video-game gameplayZero videos: simply look at statistics.videoCount == 0. Done.
Mostly/only gameplay:For each channel that has videos, get the uploads playlist ID.
Use playlistItems.list (or search.list) to fetch recent / all video titles, descriptions, and (if available) category IDs.
Heuristics that work reasonably well:Video category = Gaming (category ID 20).
Titles/descriptions containing common signals: “gameplay”, “let’s play”, specific game names, “walkthrough”, “playthrough”, “stream”, etc.
You can also pull a sample of thumbnails or use the video’s tags if present.

Define your own threshold (e.g., ≥70–80 % of the last N videos match the gameplay criteria).

Quota note: fetching video lists for thousands of channels is expensive. You will almost certainly need to sample (e.g., check only the 20–50 most recent videos per channel, or only channels that commented more than X times) rather than inspect every single video of every commenter.Practical reality check“ALL” comments on a moderately popular or larger channel is usually impossible under normal free quotas and time constraints.
Even with elevated quota, the volume of unique commenters can be huge; inspecting every one thoroughly is slow and costly.
Many commenters have private/unlisted videos, deleted channels, or no channel at all (some comments come from Google accounts without a public YouTube channel).
Rate limits and daily quota make this a multi-day (or multi-week) project for anything non-trivial unless you have many projects / paid higher quota / commercial data providers.

Recommended workflow summaryGet a Google Cloud project + YouTube Data API v3 key (or OAuth if you need private data).
Use commentThreads.list + allThreadsRelatedToChannelId (or the per-video route) and paginate while respecting quota.
Extract unique authorChannelIds.
Batch channels.list to get videoCount.
For channels with videos > 0, sample their uploads playlist and classify titles/categories with simple keyword or category rules (or more advanced NLP if you want).
Aggregate the counts.

Libraries that help: the official Google API client libraries (Python, Node, etc.), or wrappers. For pure analysis you can store everything in a database/CSV and process offline.If the channel is small (few videos, few thousand comments total), this is perfectly doable. For anything bigger, expect to sample heavily or use commercial YouTube analytics / data providers that already have this data.