sfeed_opml_export - sfeed - RSS and Atom parser | |
git clone git://git.codemadness.org/sfeed | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
sfeed_opml_export (1357B) | |
--- | |
1 #!/bin/sh | |
2 | |
3 # load config (evaluate shellscript). | |
4 # loadconfig(configfile) | |
5 loadconfig() { | |
6 # allow to specify config via argv[1]. | |
7 if [ "$1" != "" ]; then | |
8 # get absolute path of config file required for includin… | |
9 config="$1" | |
10 configpath=$(readlink -f "${config}" 2>/dev/null) | |
11 else | |
12 # default config location. | |
13 config="$HOME/.sfeed/sfeedrc" | |
14 configpath="${config}" | |
15 fi | |
16 | |
17 # config is loaded here to be able to override $sfeedpath or fun… | |
18 if [ -r "${configpath}" ] && [ -f "${configpath}" ]; then | |
19 . "${configpath}" | |
20 else | |
21 printf "Configuration file \"%s\" cannot be read.\n" "${… | |
22 echo "See the sfeedrc.example file or the sfeedrc(5) man… | |
23 exit 1 | |
24 fi | |
25 } | |
26 | |
27 # override feed function to output OPML XML. | |
28 # feed(name, feedurl, [basesiteurl], [encoding]) | |
29 feed() { | |
30 # uses the characters 0x1f and 0x1e as a separator. | |
31 printf '%s\037%s\036' "$1" "$2" | |
32 } | |
33 | |
34 # load config file. | |
35 loadconfig "$1" | |
36 | |
37 cat <<! | |
38 <?xml version="1.0" encoding="UTF-8"?> | |
39 <opml version="1.0"> | |
40 <head> | |
41 <title>OPML export</title> | |
42 </head> | |
43 <body> | |
44 ! | |
45 | |
46 feeds | LC_ALL=C awk ' | |
47 BEGIN { | |
48 FS = "\x1f"; RS = "\x1e"; | |
49 } | |
50 { | |
51 gsub("&", "\\&"); | |
52 gsub("\"", "\\""); | |
53 gsub("'"'"'", "\\'"); | |
54 gsub("<", "\\<"); | |
55 gsub(">", "\\>"); | |
56 | |
57 print "\t<outline type=\"rss\" title=\"" $1 "\" text=\"" $1 "\" … | |
58 }' | |
59 | |
60 cat <<! | |
61 </body> | |
62 </opml> | |
63 ! |