Closed qo4on closed 1 year ago
Hi @qo4on, I've just taken a quick look into this and can't seem to find a way to get the full like count. I'll keep fiddling and will let you know my findings
It looks like this is possible using the official YouTube Data API - https://developers.google.com/youtube/v3/ There's a community provided API that'll provide the full value as well, which looks like it might be scraping the YouTube Data API behind the scenes - https://returnyoutubedislikeapi.com/votes?videoId=zL3wWykAKfs
Success!
from innertube import InnerTube
video_id = "zL3wWykAKfs"
client = InnerTube("WEB")
data = client.next(video_id)
like_count = data["contents"]["twoColumnWatchNextResults"]["results"]["results"]["contents"][0]["videoPrimaryInfoRenderer"]["videoActions"]["menuRenderer"]["topLevelButtons"][0]["segmentedLikeDislikeButtonRenderer"]["likeButton"]["toggleButtonRenderer"]["defaultText"]["accessibility"]["accessibilityData"]["label"].split(" ")[0]
print(f"Total likes: {like_count}")
Total likes: 262,031
In case it's helpful, the NewPipe repository can be handy as a reference for how they scrape data out of the InnerTube API :slightly_smiling_face: - https://github.com/TeamNewPipe/NewPipeExtractor/blob/6bdd698c259c4301d8ee6cb9ef226b5d35f49ca8/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java#L415
Thank you, that's very interesting! But how do they connect to YouTube itself, what is the first request they make?
Unfortunately I'm not familiar with their specific implementation, however I imagine they're doing something very similar
Is it even possible to do this through the api without loading the page itself? I mean the full number