This is a Google Apps Script that automatically adds new Youtube videos to playlists (a replacement for Youtube Collections feature).
This is done using Google Sheets for interface, Google Script + Youtube API v3 for executing and scheduling.
- Adds all new videos to Youtube playlists (uploaded later than some date)
1.1. From ALL subscribed channels
1.2. From any list of channels (by username or channel ID)
1.3. From any other playlist (by playlist ID)
-
Optional - ability to set automatic interval for updates
-
Optional - ability to deploy as a web app to update or show playlist.
-
Copy the Sheet to your Google Drive.
-
Allow the Sheets to access Youtube:
- Open the
Script Editor
(in menu:Tools
/Script Editor...
) of the Sheet- In menu:
Resources
/Advanced Google Services
- Scroll down and make sure
YouTube Data API
is enabled - Then,
Google Developers Console
/Youtube Data API
/Enable API
, close the tab, go back to Script Editor and clickOK
- Continue only after the yellow
Updating Google Services
box disappears in the top of the Script Editor
- In menu:
- Close the Developers Console and Script Editor, open the Sheet again
- In menu:
Functions
/Update Playlists
- Grant access in the dialog
- In menu:
- Setup your playlists and channels (white cells in the Sheet):
- Clear all existing white rows, they are just examples (i.e. delete the 3 rows).
- For each new playlist you want to use:
- In a new row:
- Add your Playlist ID in the first white column (you can find it in the URLs of your playlists, after
?list=
) - Add your Channels (in other white columns of the same row) (Example of a successful set-up, from user
topdogmsn
)- Any of the following:
- User ID (last part (after last
/
) inhttps://www.youtube.com/user/someusername
) - Channel ID (last part (after last
/
) inhttps://www.youtube.com/channel/UCzMVH2jEyEwXPBvyht8xQNw
) - Playlist ID (last part (after
?list=
inhttps://www.youtube.com/playlist?list=PLd0LhgZxFkVKh_JNXcdHoPYo832Wu9fub
) ALL
, to add all new videos from all of your subscriptions
- Open the Google Sheet, then in menu:
Functions
/Update Playlists
. (Notice: when used first time, only a timestamp will be added (prevents overflow with old videos)).
- In menu (of the Sheet):
Tools
/Script Editor...
- In menu:
Resources
/Current project triggers
updatePlaylists
->Time driven
->Hour timer
->Every hour
Save
- In menu (of the Sheet):
Tools
/Script Editor...
- Update the SheetID in the very begining of the file. It's the random long string found in the URL of the SpreadSheet. The highlighted part of the URL in the image below.
- In menu:
Publish
/Deploy as a web app
Publish
(you will get a special link to use)- Optional - create a tiny.cc redirect link for easy acess (tiny.cc is recommended as it allows you to pass parameters to the url)
- Usage: append
/?pl=N
to select the Nth playlist in the spreadsheed.
- append
/?update=True
to force update the playlists. - e.g.
tiny.cc/myplaylist/?update=True&pl=3
will force update and open the third playlist.
To remove all playlist items, bookmark the link below and click on it while having the youtube playlist page open.
javascript:(function() { if (confirm('Remove all?')) {var i = window.setInterval(function() {var closeButton = document.querySelector('.pl-video-edit-remove'); if (closeButton) { closeButton.click(); } else { window.clearInterval(i); }}, 500);}})();
(source)
(Extra) Link to remove watched items from a youtube playlist (thanks to saso5tr):
Same as above.
javascript:(function() { if (confirm('Remove all?')) {var i = window.setInterval(function() {var closeButton = document.querySelector('.watched-badge'); if (closeButton) { closeButton.parentElement.parentElement.parentElement.parentElement.querySelector('.pl-video-edit-remove').click(); } else { window.clearInterval(i); }}, 500);}})();
A: Only videos that are uploaded after the first run of the script are added (i.e. the timestamp is set to current date). New videos should be up. Alternatively, you can modify the timestamp yourself.
A: Cut (or delete) the contents of the playlist ID cell in the row you want to pause.
A: Let me devote more time and resources to this project here: . You can also use your GitHub account to suggest the changes directly. Thanks for all the help!
A: See Feedback
section below.
A: A known fix is to use an account with Gmail, YouTube accounts are known to have this issue. Notice that you will only be able to use the playlists accessible by the authorized account (i.e. your 'Gmail' account in YouTube site).
Q: I get this error: TypeError: Second argument to Function.prototype.apply must be an array. (line 27, file "")
A: Do the step laid out in the instructions above: go to Resources > Developers Console Project > Click the link to your API console project > On the left, APIs & Auth > APIs > YouTube Data API > Enable API
. (thanks to josn0w and theit8514, also nmgoh and saso5tr)
A: Copy-paste the contents of the debug.gs file into your Script Editor
A: See Feedback
section below.