DEV Community

Hugh Wells
Hugh Wells

Posted on

Using YouTube Subtitles for a drinking game

YouTube Subtitles

A friend suggested this concept, and I was sufficiently bored of revision to make a quick MVP.

The idea is that you take a selection of videos from your favourite YouTuber and analyse their most used phrases; which you must drink on, each time someone says them.

Link to Code

youtube-subtitles

A Python CLI application which will extract the most common phrases from video subtitles, and present them to you.

Probably most useful as an amusing game.

Installation

Requires:

  • Python3

Try running it, if you're missing any packages then just install them with pip. Apologies for no pipenv.

Setup:

Create a .env in the repository root with the following values:

YOUTUBE_KEY={Your YouTube API key}
CLIENT_ID={Your YouTube OAuth2 Client ID}
CLIENT_SECRET={Your YouTube OAuth2 Client Secret}

You'll need to go to cloud.google.com and enable the YouTube Data API where you can then generate these values.

Note: the permissions scope required is https://www.googleapis.com/auth/youtube.force-ssl

Useage

Run with python3 main.py.

Copy and paste URLs to YouTube videos. Supply a null value to perform the analysis.

Try to include as many of the outputted phrases as possible, in normal conversation.

Future

This was a Sunday afternoon project - don't expect miracles.

I might:

  • …

How I built it

This is a simple Python 3 application you can run at home. I might make it into an actual website at some point.

Issues:

  • It uses up a stonking great chunk of YouTube "quota". There are some small tweaks I could make to improve this: better filtering the subtitle tracks before downloading them etc.
  • The text analysis is a very basic moving window frequency analysis. It is not clever and contains no AI or ML! Room for improvement.

Top comments (0)