Keeping track of which YouTube videos you have watched can be tricky, especially because the "WATCHED" indicator seems to be ephemeral. This script allows you to add all videos from a YouTube channel to a playlist that you control so you can order them as you please and remove them once they've been watched.
Requirements: Python 3.12 or later.
Install this application with pip:
python3 -m pip install git+https://github.com/RobbieClarken/youtube-channel-to-playlist
Create a project through the Google Cloud Console.
Enable your project to use the YouTube Data API v3 via the APIs & Services Dashboard.
Configure an OAuth consent screen:
https://www.googleapis.com/auth/youtube
scope.Create an OAuth Client ID through the Credentials page under APIs & Services, selecting:
Download the OAuth client secrets JSON file from the
Credentials page and
rename it to client_secrets.json
.
channel_to_playlist --secrets client_secrets.json source-channel-id target-playlist-id
where source-channel-id
and target-playlist-id
can be found from the URLs of
the YouTube channel and playlist. To find the channel id of a YouTube account
like https://www.youtube.com/@AntsCanada
:
For example, to copy videos from the PyCon 2015 Channel to this playlist you would run:
channel_to_playlist --secrets client_secrets.json UCgxzjK6GuOHVKR_08TT4hJQ PLlgnub_DBR_CszAWpJypwst0OFDxW6jOJ
If you only want to add videos published after or before a certain date, you can use the --after
and --before
options:
channel_to_playlist --after 2018-05-21 --before 2018-06-30 UCgxzjK6GuOHVKR_08TT4hJQ PLlgnub_DBR_CszAWpJypwst0OFDxW6jOJ
The script will store the video IDs that are added to the playlist in a file and skip these videos if it is run again. This allows you to re-run the script when new videos are uploaded to the channel.
To add videos which already exist in the playlist, use the --allow-duplicates
switch, as shown in the following example:
channel_to_playlist --secrets client_secrets.json UCgxzjK6GuOHVKR_08TT4hJQ PLlgnub_DBR_CszAWpJypwst0OFDxW6jOJ --allow-duplicates