ytdlwatch
A long-running Go program that watches a Youtube playlist for new videos, and downloads them using yt-dlp
or other preferred tool.
install
The Go Toolchain is required.
The following will install ytdlwatch
to $GOPATH/bin
:
go install github.com/raine/ytdlwatch
To build for another platform, clone the repository and run go build like so:
env GOOS=target-OS GOARCH=target-architecture go build .
how to use
-
Create a project and an API key for accessing the Youtube API: https://console.cloud.google.com/apis/credentials
-
Create a new playlist on Youtube. The playlist can be public or unlisted, but not private. In Playlist Settings, enable the setting "Add new videos to top of playlist" (screenshot). Needed so that the program only ever has to read the first page of playlist's items, and API quota does not have to be used for deleting videos.
Could the personal "Watch later" playlist be used? Unfortunately not, since it's not available through the official API.
-
Run
ytdlwatch
with the environment variables listed below set up.
See also the example systemd service: ytdlwatch.service.example
env vars
YOUTUBE_API_KEY
: Youtube API key. Needed for accessing the given Youtube playlist. Create one here (and a new project, if necessary): https://console.cloud.google.com/apis/credentials requiredYOUTUBE_PLAYLIST_ID
: An ID for the Youtube playlist that is monitored by the program. You can see this in browser's page URL when viewing a playlist on Youtube. A long string that begins with charactersPL
. requiredOUTPUT_PATH
: A path to a directory where videos should be downloaded to. requiredYOUTUBE_DL_PATH
: Path to executable that is used to download videos from Youtube. Defaults toyt-dlp
, which is a fork ofyoutube-dl
.LOG_LEVEL
: Log level of the program. Defaults toinfo
. Set todebug
to see all output from whatever program is used to download videos.
development
The project uses just
as a command runner (or make alternative).
See just -l
for recipes.