youtube-feed-improved.md - www.codemadness.org - www.codemadness.org saait content files
(HTM) git clone git://git.codemadness.org/www.codemadness.org
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
youtube-feed-improved.md (3457B)
---
1 ... improved at least for my preferences ;)
2
3
4 ## Features
5
6 * Add the video duration to the title to quickly see how long the video is.
7 * Filter away Youtube shorts and upcoming videos / announcements: only videos are shown.
8 * Support more output formats: Atom, [JSON Feed](https://www.jsonfeed.org/version/1.1/) or
9 [sfeed](sfeed.1.txt) Tab-Separated-Value format.
10 * Easy to build and deploy: can be run as a CGI program as a static-linked binary in a chroot.
11 * Secure: additionally to running in a chroot it can use pledge(2) and unveil(2)
12 on OpenBSD to restrict system calls and access to the filesystem.
13
14
15 ## How to use
16
17 There is an option to run directly from the command-line or in CGI-mode. When
18 the environment variable $REQUEST_URI is set it is automatically run in CGI
19 mode.
20
21
22 Command-line usage:
23
24 youtube_feed channelid atom
25 youtube_feed channelid json
26 youtube_feed channelid tsv
27
28
29 CGI program usage:
30
31 The last basename part of the URL should be the channelid + the output format
32 extension. It defaults to TSV if there is no extension.
33
34 For example:
35
36 Atom XML: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.xml
37 JSON: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.json
38 TSV: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.tsv
39 TSV, default: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw
40
41
42 An OpenBSD httpd.conf using slowcgi as an example:
43
44 server "codemadness.org" {
45 location "/yt-chan/*" {
46 request strip 1
47 root "/cgi-bin/yt-chan"
48 fastcgi socket "/run/slowcgi.sock"
49 }
50 }
51
52
53 ## Using it with [sfeed](sfeed.html)
54
55 sfeedrc example of an existing Youtube RSS/Atom feed:
56
57 # list of feeds to fetch:
58 feeds() {
59 # feed <name> <feedurl> [basesiteurl] [encoding]
60 # normal Youtube Atom feed.
61 feed "yt IM" "https://www.youtube.com/feeds/videos.xml?channel_id=UCrbvoMC0zUvPL8vjswhLOSw"
62 }
63
64
65 Use the new Atom feed directly using the CGI-mode and Atom output format:
66
67 # list of feeds to fetch:
68 feeds() {
69 # feed <name> <feedurl> [basesiteurl] [encoding]
70 # new Youtube Atom feed.
71 feed "idiotbox IM" "https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.xml"
72 }
73
74 ... or convert directly using a custom connector program on the local system via the command-line:
75
76 # fetch(name, url, feedfile)
77 fetch() {
78 case "$1" in
79 "connector example")
80 youtube_feed "$2";;
81 *)
82 curl -L --max-redirs 0 -H "User-Agent:" -f -s -m 15 \
83 "$2" 2>/dev/null;;
84 esac
85 }
86
87 # parse and convert input, by default XML to the sfeed(5) TSV format.
88 # parse(name, feedurl, basesiteurl)
89 parse() {
90 case "$1" in
91 "connector example")
92 cat;;
93 *)
94 sfeed "$3";;
95 esac
96 }
97
98 # list of feeds to fetch:
99 feeds() {
100 # feed <name> <feedurl> [basesiteurl] [encoding]
101 feed "connector example" "UCrbvoMC0zUvPL8vjswhLOSw"
102 }
103
104
105 ## Screenshot using sfeed_curses
106
107 [](downloads/screenshots/sfeed_curses_youtube.png)
108
109
110 ## Clone
111
112 git clone git://git.codemadness.org/frontends
113
114
115 ## Browse
116
117 You can browse the source-code at:
118
119 * <https://git.codemadness.org/frontends/file/youtube/feed.c.html>
120 * <gopher://codemadness.org/1/git/frontends/file/youtube/feed.c.gph>
121
122 The program is: youtube/feed
123
124
125 ## Dependencies
126
127 * C compiler.
128 * LibreSSL + libtls.
129
130
131 ## Build and install
132
133 $ make
134 # make install
135
136
137 # That's all
138
139 I hope by sharing this it is useful to someone other than me as well.