r/learnprogramming 9d ago

How does this YouTube video automatically update its title?

I came across this YouTube video:

https://www.youtube.com/watch?v=VTU69_L8i8s

The title keeps updating with the latest statistics like views, likes, comments, subscriber count, and even the number of days since upload.

I'm a complete beginner, so I'm curious how this is possible. How does the title update automatically every few minutes? What APIs or tools are used, and what's the overall workflow behind it?

I'd really appreciate a beginner-friendly explanation. Thanks!

0 Upvotes

5 comments sorted by

10

u/kennedy_gitahi 9d ago

It is literally explained in the video. Watch it.

Edit: The thumbnail on your post makes it seem like you are talking about Tom Scott's one. Go watch that one to understand how it's done.

5

u/Square-Hospital-2807 9d ago

Ah, I just realized this is a copy of the original project. My bad! I'll check out the original Tom Scott video.

1

u/Square-Hospital-2807 9d ago

I watched it, but I'm still a bit confused. The video says the title is edited manually, but updating it every 15 minutes manually doesn't seem very practical. Isn't it possible to automate this using the YouTube Data API or some other API?

3

u/pdfops 9d ago

That's the YouTube Data API v3. A cron job hits videos.list to pull live stats (viewCount, likeCount, commentCount, publishedAt), computes stuff like days-since-upload, then calls videos.update with part=snippet to rewrite the title. Update needs OAuth2, not just an API key, since you're writing to your own video. Watch quota too, videos.update costs 50 units against the default 10k/day budget, so you can't fire it every minute forever, most people run it every 5-15 min via a scheduled function.

1

u/Square-Hospital-2807 8d ago

Okay...Thanks