YouTube no longer offers version 2 of their API, which included feeds for the uploads of channels to which you were subscribed. In addition, this API version also provided feeds for individual playlists, which was very useful for the case in which you were interested in watching new videos on a particular topic, but not for the channel in general. In addition, YouTube has an incentive to subtly modify the content returned in your home feed.
ytdl
replaces your YouTube subscription management. You no longer
manage your YouTube channel subscriptions on youtube.com, and instead
manage them through this tool. In addition, you can manage playlist
subscriptions directly in the same manner as channel subscriptions.
In general, ytdl
enables you to download your latest subscriptions.
ytdl
makes use of the excellent program youtube-dl
to do the
actual heavy lifting of downloading YouTube videos. It's launched as a
subprocess, and needs to be in your path.
Simply run make && sudo make install
. The Makefile
takes advantage
of GNU extensions; therefore, you will want to use gmake
on FreeBSD.
The Makefile
supports DESTDIR
.
ytdl
downloads the most-recent unseen video subscription uploads to a
specified directory. This is ideal for cron
.
Place a file ytdl.conf
in $HOME/etc
. Its contents should look
something like the following.
[auth]
key = AIzaSyAujM2qD38VDMpfQHXQv3XjJx-Mjzb5Xs4
The key should be an application server key, created on the Google developers console. It will be used when making calls to the YouTube Data API (v3).
Next, import your current YouTube subscriptions. First, if you don't have it, get the channel ID for your user.
ytdl id getuser <yourusername>
Then, import the subscriptions for that channel ID.
ytdl subs import <channelid>
Just the IDs of the channels to which this channel is subscribed will be imported. Now you can run the following command to fetch and download the latest subscriptions that you haven't yet seen.
ytdl cron dlsubs --save <where/to/save/the/videos>
Note that in the first run through, ytdl
will not actually download
anything. Instead, it will just store the most-recent video IDs in each
channel. Future invocations will continue to update this "seen state",
so ytdl
won't download the same videos multiple times.
ytdl
has a number of commands. In fact, the commands themselves are
subdivided into command groups, with commands underneath each group.
All levels of invocation are well-documented with support for a --help
option. Run ytdl --help
to get started.
In addition, most of the classes and methods have Pydoc documentation.
/usr/local/bin/ytdl
(viamake install
)$HOME/etc/ytdl.conf
$HOME/var/db/ytdl/*
(created at runtime)$HOME/var/log/ytdl/cron_dlsubs.log
(created bycron dlsubs
)
ytdl.conf
will be pulled from the XDG config home instead, if
available.
If the environment variable XDG_DATA_DIR
is set to
$HOME/foo/bar/share
, for example, then the local DB and logs will be
stored in $HOME/foo/bar/var/db/...
and $HOME/foo/bar/var/log/...
instead of directly under the home directory.