Youtube: Automatically Add New Videos to Playlist

I wanted to share a handy Google Script which I came across initially in this older and now locked Reddit thread.

I have updated the script which you can find here, this script will automatically add videos from your subscribed channels to a specified YouTube playlist. You need to new email notifications turned on for the channel subscriptions you want to add to the playlist first.

The script searches Gmail for new video notifications, adds them to a specified playlist, then logs this action in a Google Drive sheet (can turn this logging off if you don’t want it).

I’ve tweaked the original slightly and added a little bit of commenting to try to make the script a bit clearer. It took me a couple of hours of googling and tweaking to understand how it worked and to get it working properly for me. But it works great now and it will save me significant time in future.

This should be useful for people given the number of requests I’ve seen while searching for a solution to this problem. And many thanks to /u/DiRaven for the original script.

Couple of notes on use…

  • First take a copy of the script and save in your Google Drive.
  • Create an error logging Sheet and an activity logging Sheet in Google Drive if you want to log these activities, then add their sheet IDs to the script in the right places. Or remove/comment-out that part of the code if you don’t want this.
  • From the menu bar at the top of the scripting interface, run the script ‘AddAddNewVideosToWatchLaterTrigger’, this will add a trigger to run the main script which searches Gmail for new notifications every 15 min.
  • From the top menu bar, select ‘Resources’ -> ‘Advanced Google Services’ and make sure that the YouTube Data API is enabled. Then click on the link in this box for the ‘Google Developers Console’ and make sure the Youtube Data API is enabled here too.
  • You can manually run the script from the menu bar too to test it.
  • If you have different requirements for which channel subscriptions you want added, e.g. you don’t want all notification emails processed, you only want the excellent videos from the channels of /u/MindOfMetalAndWheels (CPG Grey), /u/JeffDujon (Periodic Videos, Numberphile, etc.), or /u/MrPennywhistle(SmarterEveryDay), you can tweak the search criteria in line 23 to only return those results you want to work with.

P.S. Totally don’t apologise for the name dropping since they are truly excellent channels and more people need to be watching them!

Hope this helps. If you’ve any questions just ask but, while I have some coding and dev background, I’m no expert and can only do my best to help.


I’ve also shared this on Reddit here (


  1. Hello.

    I'm that DiRaven guy that made the very first version of the script.

    That's an advanced version you've got here… Awesome work!

    I just wanted to drop the note and invite everyone interested to participate on GitHub where I offloaded initial version of my script, so that we can share the ideas and improve it further.


  2. Is there any way to do this without using the email notifications? I feel like they always lag behind (in terms of hours after posting), and I subscribe to so many channels that they didn't (email) notify me of every single upload — granted this was before they added the bell feature. Do email notifications work better with the bell, now? I disabled them and switched to push notifications for channels I really love, and I usually try to stay on top of them and add to watch later from my phone, but that's starting to get too noisy which is why I was searching and found this.

Leave a Reply

(email optional)