Skip to content

Time To Watch Later (TTWL) calculates the total viewing time for all videos within any YouTube playlist.

License

Notifications You must be signed in to change notification settings

Edchja/time-to-watch-later

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕔 Time to Watch Later

🕔 Time To Watch Later (TTWL) calculates the amount of time needed to watch all videos in the "Watch Later" playlist on YouTube.

Table of Contents

🤔 Why?

My "Watch Later" playlist had grown to over 250 videos and I was curious how long it would take to watch them all. Since I'm a fan of Go, I thought about doing that programmatically.

📉 My First Approach

I thought that it wouldn't be that deep. In my head, it was:

  1. Get all playlists a user has.
  2. Find the "Watch Later" playlist.
  3. Use the ID of the "Watch Later" playlist to get all video IDs.
  4. Calculate the duration of all videos with the videos endpoint.

So, I started reading the API documentation to find out which endpoints I would have to use. To get familiar with them, I used an API Client, Bruno, to play a bit with the endpoints.

I tried to get the Watch Later playlist — with no luck.

So I did what every developer does: I googled it. I found this Reddit post explaining that Google had removed the ability to get information about the "Watch Later" playlist from the YouTube API. I double checked this by searching the official revision history.

At that point, I thought that it was impossible to get the Watch Later playlist. However, in the same Reddit thread, a solution was hidden in the comment.

📈 Second Approach

The Reddit comment I found described a way to get my hands on the video IDs of the "Watch Later" playlist, though the process is a bit cumbersome. You have to download the playlist data from Google Takeout.

How to do that, you might ask?

  1. Go to Google Takeout and create a new export.
  2. Click Deselect all.

google takeout overview

  1. Scroll down to YouTube and select it.

google takeout youtube section

  1. Click on the chip All YouTube data included.
  2. Deselect everything except playlists.

google takeout image

  1. Finish the export. You will be notified via email when the download is ready.

Do you remember the steps of the first approach? The process stays the same, except that the first two steps are skipped.

🔧 How it Works

TTWL utilizes the YouTube Data API v3 to calculate the total duration.

It reads the csv file from your Google Takeout export to get all video IDs. Those are passed to the YouTube Data API, and then the duration of all videos is calculated.

🏃 How to Get TTWL Running

  1. Enable the YouTube Data API v3.
  2. Click on Manage.

YouTube Data API v3

  1. Then, navigate to the Credentials tab.

Google Cloud side bar

  1. Click on + Create credentials and select API Key.

API Credential Creation

  1. Set a name for the key. Ensure all other settings are identical to those shown in the screenshot. For security reasons, restrict the API key to the YouTube Data API v3.

API Key Creation

  1. Clone this repository:
  git clone https://github.com/Edchja/time-to-watch-later.git

🐳 With Docker

  1. Ensure Docker is installed.
  2. Change your directory to the cloned repository.
  3. Build the image:
docker build -t ttwl .
  1. Run the container, replacing your-key and the path to your CSV file:
docker run --rm -e API_KEY=your-key -v path/to/watch-later.csv:/wl.csv ttwl -file=wl.csv

💻 With Go in a Terminal

  1. Ensure Go is installed.
  2. Change your directory to the cloned repository.
  3. Create a .env file in the project's root directory. Inside this file, add the line API_KEY=your_api_key, replacing your_api_key with the key you created.
  4. Follow the steps in the second approach to download your Watch Later Playlist CSV file.
  5. Now, you can run TTWL 🚀
go run . -file='path/to/Watch later-videos.csv'

📋 Example Output

2025/09/29 00:15:57 playlist video count: 447
2025/09/29 00:15:59 available video count: 440

The duration to get through the Watch Later playlist is:
6 days
5 hours
15 minutes
36 seconds