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.
Add all new videos to Youtube playlists (uploaded later than some date);
from all subscribed channels;
from any list of channels (by channel ID);
from any other playlist (by playlist ID);
Set automatic interval for updates (optional);
Deploy as a web app to update or show playlist (optional);
Remove videos in the playlists that are older than a certain number of days before the execution of the script (optional).
If you ran into problems, here are some of the possible sources for solutions:
Copy the Sheet to your Google Drive. Afterwards you might want to update the script to the latest version of sheetScript.gs
Setup your playlists and channels (white cells in the Sheet):
ALL, to add all new videos from all of your subscriptions
Run the script:
(Optional) Adjust Timezone:
Update Playlists. (Notice: when used first time, only a timestamp will be added (prevents overflow with old videos)).
Current project triggers
Select type. Ensure
web appis selected.
Publish(you will get a special link to use)
?pl=Nto select the Nth playlist in the spreadsheet.
?update=Trueto force update all the playlists.
tiny.cc/myplaylist?update=True&pl=3will force update and open the third playlist.
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.
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).
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)
TypeError: Cannot read property "items" from undefined. (line 169, file "Code")
A: If it only happens sometimes, it can be safely ignored, the next round will work normal again. If it happens on every execution, check your playlist and channel IDs. The script stops working if any of your playlists or channels doesn't exist, for example because it was deleted.
Cannot (Search) YouTubeerrors
A: Make sure the sheet can access YouTube's API:
Script Editor(in menu:
Script Editor...) of the Sheet
Advanced Google Services
YouTube Data APIis enabled
Cannot query for user <USERNAME>where
<USERNAME>is the channel's username found in the channel's shortened URL (i.e.
In the sheet, channel usernames cannot be used, only channel ids. To get a channel id for a specific channel, follow these steps:
A: Copy-paste the contents of the debug.gs file into your Script Editor
Feedback section below.