bugfixes, features, documentation, examples, new tool
[hband-tools.git] / user-tools / 2opml
blob89fb133d27ce7f365c2c0dec2ed5180efe79fe89
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 2opml - Convert list of URLs to OPML.
10 =head1 SYNOPSIS
12 2opml [--add-attributes <ATTRIBUTES>] < urls.txt
14 =head1 DESCRIPTION
16 Convert text file, containing "<TITLE> <URL>" looking lines, to OPML.
18 =cut
20 EOF
23 xmlquote()
25 local s=$1
26 s=${s//&/&amp;}
27 s=${s//</&lt;}
28 s=${s//>/&gt;}
29 s=${s//\"/&quot;}
30 echo "$s"
33 add_attributes=''
35 while [ $# != 0 ]
37 case "$1" in
38 --help)
39 echo "Usage: 2opml [--add-attributes <ATTRIBUTES>] < urls.txt"
40 echo "Convert text file, containing \"<TITLE> <URL>\" looking lines, to OPML."
41 exit;;
42 --add-attributes)
43 shift
44 add_attributes=$1;;
45 --)
46 shift
47 break;;
48 -*)
49 break;;
50 esac
51 shift
52 done
54 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
55 <opml version=\"1.0\"><body>"
57 while read -r title url
59 title=`xmlquote "$title"`
60 url=`xmlquote "$url"`
62 echo "<outline type=\"rss\" title=\"$title\" text=\"$title\" xmlUrl=\"$url\" $add_attributes />"
63 done
65 echo "</body></opml>"