summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-12-03 03:50:22 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-12-03 03:51:23 +0100
commit4d61b23877af9cd5c302a1e4423b2399601dad43 (patch)
treed457338d71bd71ba4ed499bdf4505c1335c7ea0f
parent46bf011613eda177e7ce666646417711c167de33 (diff)
downloadpc-4d61b23877af9cd5c302a1e4423b2399601dad43.tar.gz
pc: Use fixed output order, handle summary/description better
-rwxr-xr-xpc33
1 files changed, 25 insertions, 8 deletions
diff --git a/pc b/pc
index a891740..31c7fe2 100755
--- a/pc
+++ b/pc
@@ -3,12 +3,29 @@
curl -Ls "$@" |
sed -n '/<item>/,$p' |
sed -e '/^$/d' -e 's/^[ ]*//' |
-awk -vFS='[<>]' '
- /<pubDate>/ { print "Date: " $3; }
- /<title>/ { print "Subject: " $3; }
- /<itunes:summary>/ { print "Summary: " $3; }
- /<enclosure[^>]*>/ { print "Link: " $0; }
- /<itunes:duration>/ { print "Duration: " $3; }
- /<\/item>/ { print ""; }
+awk -vFS='[<>]' -vOFS=' ' '
+ /<pubDate>/ { date = $3 }
+ /<itunes:duration>/ { duration = $3 }
+ /<enclosure[^>]*>/ { file = $0 }
+ /<description>$/ { getline; summary = $0 }
+ /<description>..*/ { summary = $3 }
+ /<itunes:summary>$/ { getline; summary = $0 }
+ /<itunes:summary>..*/ { summary = $3 }
+ /<title>/ { title = $3 }
+ /<\/item>/ {
+ print "Title: " title
+ print "Duration: " duration
+ print "Date: " date
+ print "File: " file
+ print "Summary: " summary
+ print ""
+ date = "?"
+ duration = "?"
+ file = "?"
+ summary = "?"
+ title = "?"
+ }
' |
-sed 's,<enclosure[^>]* url="\([^"]*\)".*,\1,'
+sed -e 's,<description>,,' \
+ -e 's,<enclosure[^>]* url="\([^"]*\)".*,\1,' \
+ -e 's,<!\[CDATA\[\(.*\)\]\]>,\1,'