A Google Sheets and Google Apps Script tool that transforms how you manage your YouTube subscriptions.
Instead of relying on YouTube's default subscription feed, this tool pulls your new videos into a dedicated "Inbox" spreadsheet using RSS (saving API quota). It then uses a lightweight, built-in prediction model to automatically suggest which playlist each video belongs in based on your past viewing habits.
- 📬 The "Inbox" Workflow: Review all new videos from your subscriptions in a clean, spreadsheet-based inbox.
- 🧠 Smart AI Suggestions: The script learns from your history. It analyzes the Channel, Video Duration, and Title Keywords to predict your preferred playlist (or if you usually skip that type of content).
- ⌨️ Keyboard Optimized: Designed for rapid processing. Use Sheets' built-in autocomplete to assign playlists without ever touching your mouse.
- 🛡️ Quota Protection: Moving videos via the YouTube API is expensive. This script includes a "Quota Brake" that automatically stops processing at 190 videos to prevent 24-hour API bans.
- 🧹 Self-Cleaning: Automatically trims your processing history to the most recent 2,000 rows to ensure the prediction model stays fast and relevant to your current tastes.
- 🆓 100% Free & Private: Runs entirely inside your personal Google Drive. No external servers, no third-party machine learning APIs, and no subscription fees.
Because this tool relies on a specific spreadsheet structure, the easiest way to install it is to copy the template.
To use the YouTube Data API to manage playlists and subscriptions, your Google Account must have an active YouTube channel linked to it. If you only have a standard Gmail account and have never created a channel, the API will fail to fetch your data.
- Go to YouTube.com.
- Click your profile picture in the top right.
- Click Create a channel and follow the prompts. (You do not need to upload any videos).
- Open the Template Google Sheet
- Accept the prompts and save it to whatever location you desire on your Google Drive.
- In your new spreadsheet, click Extensions > Apps Script.
- Open the following files and paste the code from this repository into them:
Main.gsWorkflow_Fetch.gsWorkflow_Process.gsWorkflow_Predict.gsWorkflow_Deduplicate.gsLibrary.gs
(Note: The source files in this repository end in .js, but within the Google Apps Script web editor, they must be created with .gs extensions. Just copy the contents of the corresponding .js files.)
-
Important for UI: You must also create an HTML file for the deduplication dialog:
- Click the + icon in the Apps Script editor and select HTML.
- Name it
Dialog_Deduplicate. - Paste the contents of
Dialog_Deduplicate.htmlfrom this repository into it.
-
Important: Click the Save icon (disk) at the top.
- Still in the Apps Script editor, look at the left sidebar and click the + next to Services.
- Scroll down and select YouTube Data API v3.
- Click Add.
Open the Settings tab in your spreadsheet:
- Playlists: In Column A (starting at Row 3), type the exact names of the YouTube playlists you want to use (e.g., "Watch Later", "Podcasts", "To Sort"). The script will automatically find their hidden IDs the first time it runs.
- Last Run Time: In cell B1, you can specify a date to fetch videos from (format:
YYYY-MM-DD HH:MM:SS). If left blank, the script will automatically default to fetching videos from exactly one week ago.
Click the custom menu at the top of the sheet: YouTube Tools > 1. Check New Videos.
- Note on First Run: Google will show a warning saying "Google hasn’t verified this app." This is normal for personal scripts. Click Advanced > Go to [Project Name] (unsafe) to grant your script permission to manage your YouTube account.
Go to the Videos tab. The script will highlight its AI suggestions in yellow. Initially, nothing will be suggested, but this will improve over time.
- Press
Enterto accept a suggestion. - Type a new playlist name to override it.
- Leave the cell blank if you don't want to watch the video. (The script will learn that you "Discard" this type of content).
Click YouTube Tools > 2. Process Selected. The script will move the videos to your YouTube playlists, log your choices to the History tab (to train the AI for next time), and clear your inbox.
Over time, you might accidentally add the same video to a playlist more than once. Click YouTube Tools > Remove Duplicates. Select a playlist from the dropdown, and the script will find and remove any duplicate videos from that playlist.
The YouTube Data API provides a free quota of 10,000 units per day.
- Fetching your subscriptions via RSS costs 0 units.
- Fetching video durations costs 1 unit per 50 videos.
- Adding a video to a playlist costs 50 units.
Because adding videos is so "expensive," you can only process approximately 200 videos per day. To protect your account from being locked out, this script has a built-in safety brake that will stop processing at 190 videos. If you hit this limit, simply wait until the quota resets the next day to process the rest of your inbox.
This project is open-source and available under the MIT License. Feel free to fork, modify, and improve it!
For developers who want to contribute to the codebase or run it locally:
- Clone the repository and install the Node.js dependencies:
npm install
- Linting: We enforce strict code quality using ESLint. Before submitting a pull request, ensure your code passes the linter:
npm run lint
- Deployment: Code is managed using
clasp. Changes pushed to themainbranch are automatically deployed via a GitHub Action. Make sure to set up the appropriate secrets for tokens, etc in the GitHub repo.