Improved Youtube RSS/Atom feed

Last modification on

... improved at least for my preferences ;)

It scrapes the channel data from Youtube and combines it with the parsed Atom feed from the channel on Youtube.

The Atom parser is based on sfeed, with some of the code removed because it is not needed by this program. It scrapes the metadata of the videos from the channel its HTML page and uses my custom JSON parser to convert the Javascript/JSON structure.

This parser is also used by the json2tsv tool. It has few dependencies.


  • Add the video duration to the title to quickly see how long the video is.
  • Filter away Youtube shorts and upcoming videos / announcements: only videos are shown.
  • Supports more output formats: Atom, JSON Feed or sfeed Tab-Separated-Value format.
  • Easy to build and deploy: can be run as a CGI program as a static-linked binary in a chroot.
  • Secure: additionally to running in a chroot it can use pledge(2) and unveil(2) on OpenBSD to restrict system calls and access to the filesystem.

How to use

There is an option to run directly from the command-line or in CGI-mode. When the environment variable $REQUEST_URI is set then it is automatically run in CGI mode.

Command-line usage:

youtube_feed channelid atom
youtube_feed channelid gph
youtube_feed channelid html
youtube_feed channelid json
youtube_feed channelid tsv
youtube_feed channelid txt

CGI program usage:

The last basename part of the URL should be the channelid + the output format extension. It defaults to TSV if there is no extension. The CGI program can be used with a HTTPd or a Gopher daemon such as geomyidae.

For example:

Atom XML:
TSV, default:

Gopher dir:   gopher://
Gopher TSV:   gopher://

An OpenBSD httpd.conf using slowcgi as an example:

server "" {
	location "/yt-chan/*" {
		request strip 1
		root "/cgi-bin/yt-chan"
		fastcgi socket "/run/slowcgi.sock"

Using it with sfeed

sfeedrc example of an existing Youtube RSS/Atom feed:

# list of feeds to fetch:
feeds() {
	# feed <name> <feedurl> [basesiteurl] [encoding]
	# normal Youtube Atom feed.
	feed "yt IM" ""

Use the new Atom feed directly using the CGI-mode and Atom output format:

# list of feeds to fetch:
feeds() {
	# feed <name> <feedurl> [basesiteurl] [encoding]
	# new Youtube Atom feed.
	feed "idiotbox IM" ""

... or convert directly using a custom connector program on the local system via the command-line:

# fetch(name, url, feedfile)
fetch() {
	case "$1" in
	"connector example")
		youtube_feed "$2";;
		curl -L --max-redirs 0 -H "User-Agent:" -f -s -m 15 \
			"$2" 2>/dev/null;;

# parse and convert input, by default XML to the sfeed(5) TSV format.
# parse(name, feedurl, basesiteurl)
parse() {
	case "$1" in
	"connector example")
		sfeed "$3";;

# list of feeds to fetch:
feeds() {
	# feed <name> <feedurl> [basesiteurl] [encoding]
	feed "connector example" "UCrbvoMC0zUvPL8vjswhLOSw"

Screenshot using sfeed_curses

Screenshot showing the improved Youtube feed


git clone git://


You can browse the source-code at:

The program is: youtube/feed


  • C compiler.
  • LibreSSL + libtls.

Build and install

$ make
# make install

That's all

I hope by sharing this it is useful to someone other than me as well.