Introduction
Introduction Statistics Contact Development Disclaimer Help
potcasse - potcasse - Podcast publication made easy
git clone git://bitreich.org/potcasse git://hg6vgqziawt5s4dj.onion/potcasse
Log
Files
Refs
Tags
README
LICENSE
---
potcasse (3743B)
---
1 #!/bin/sh
2
3 exitp() {
4 echo "$1"
5 exit 1
6 }
7
8 usage() {
9 name=$(basename $0)
10 printf '%s\n' \
11 "$name init | gen | episode TITLE FILE [ID]" \
12 "$name init" \
13 ': initialize the potcasse structure' \
14 "$name gen" \
15 ': generate the RSS file' \
16 "$name episode TITLE FILE [ID]" \
17 ': create the structure for a new episode and eventually copy fi…
18 exit 0
19 }
20
21 init() {
22 test -f metadata.sh && exitp "You seem in a directory managed by pot…
23 mkdir -p episodes
24 cat << EOF > metadata.sh
25 # title of your podcst
26 TITLE=
27
28 # base URL of your website
29 # must end with a /
30 SITE=
31
32 # filename of the RSS file
33 RSSLINK=feed.xml
34
35 # language for the podcast/index.html file
36 LANGUAGE=en-us
37
38 #uncomment to use logo.png as a logo
39 #IMAGE=YES
40 EOF
41 exit 0
42 }
43
44 episode() {
45 test -f metadata.sh || exitp "The directory isn't managed by potcass…
46 TITLE="$1"
47
48 test -f "$2" || exitp "File $2 doesn't exist"
49 AUDIOFILE="$2"
50 EXT=${AUDIOFILE##*.}
51
52 if [ -n "$3" ]
53 then
54 ID="$3"
55 else
56 ID="$(date +%Y%m%d%H)"
57 fi
58
59 DEST="episodes/${ID}"
60 mkdir -p "$DEST"
61 cat << EOF > ${DEST}/metadata.sh
62 TITLE="$TITLE"
63 PUBDATE="$(date "+%a, %d %b %Y 00:00:00 GMT")"
64 AUDIOFILE="${ID}.${EXT}"
65 EOF
66 cp "$AUDIOFILE" "${DEST}/${ID}.${EXT}"
67 }
68
69 gen() {
70 test -d episodes || exitp "You need to import episodes before genera…
71 TMPRSS=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
72 TMPHTML=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
73 . ./metadata.sh
74 mkdir -p output_html/episodes
75
76 if [ -n "$IMAGE" ]
77 then
78 test -f logo.png || exitp "You defined an IMAGE, move it to $PWD…
79 cp logo.png output_html/logo.png
80 fi
81
82 cat <<EOF >> $TMPRSS
83 <?xml version="1.0" encoding="UTF-8"?>
84 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
85 <channel>
86 <title>${TITLE}</title>
87 <description>${DESCRIPTION}</description>
88 <atom:link href="${SITE}${RSSLINK}" rel="self" type="application…
89 <link>${SITE}</link>
90 <image>
91 <url>${SITE}/logo.png</url>
92 <title>${TITLE}</title>
93 <link>${SITE}</link>
94 </image>
95 <language>${LANGUAGE}</language>
96 EOF
97
98 cat <<EOF >> $TMPHTML
99 <!DOCTYPE html>
100 <html lang="${LANGUAGE}">
101 <head>
102 <title>${TITLE}</title>
103 <meta charset="utf-8" />
104 </head>
105 <body>
106 <h1>Podcast episodes- ${TITLE}</h1>
107 <div>
108 <img src="logo.png" width=200 height=200 alt="logo" />
109 </div>
110 <ul>
111 <li><a href="${RSSLINK}">RSS feed</a> (for podcast players).</li>
112 </ul>
113 <ul>
114 EOF
115
116 for episode in episodes/*
117 do
118 echo "Scanning $episode"
119 . ${episode}/metadata.sh
120 SIZE=$(stat -f "%z" "${episode}/${AUDIOFILE}")
121 EXT=${AUDIOFILE##*.}
122 rsync -a "${episode}/${AUDIOFILE}" output_html/episodes/
123 cat <<EOF >> $TMPRSS
124 <item>
125 <title>$TITLE</title>
126 <description></description>
127 <pubDate>${PUBDATE}</pubDate>
128 <guid>${SITE}/episodes/${AUDIOFILE}</guid>
129 <enclosure url="${SITE}/episodes/${AUDIOFILE}" length="${SIZ…
130 </item>
131 EOF
132 cat <<EOF >> $TMPHTML
133 <li>${PUBDATE} - <a href="episodes/${AUDIOFILE}">${TITLE}</a></li>
134 EOF
135 done
136
137 cat <<EOF >> $TMPRSS
138 </channel>
139 </rss>
140 EOF
141
142 cat <<EOF >> $TMPHTML
143 </ul>
144 </body>
145 </html>
146 EOF
147
148 install -m 644 "$TMPRSS" output_html/${RSSLINK}
149 install -m 644 "$TMPHTML" output_html/index.html
150 rm "$TMPRSS" "$TMPHTML"
151 }
152
153
154 case "$1" in
155 '') usage;;
156 help) usage;;
157 init) init ;;
158 gen) gen ;;
159 episode) [ -n "$2" ] && episode "$2" "$3" "$4" ;;
160 esac
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.