diff options
author | John Ankarström <john@ankarstrom.se> | 2020-12-03 03:50:22 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2020-12-03 03:51:23 +0100 |
commit | 4d61b23877af9cd5c302a1e4423b2399601dad43 (patch) | |
tree | d457338d71bd71ba4ed499bdf4505c1335c7ea0f | |
parent | 46bf011613eda177e7ce666646417711c167de33 (diff) | |
download | pc-4d61b23877af9cd5c302a1e4423b2399601dad43.tar.gz |
pc: Use fixed output order, handle summary/description better
-rwxr-xr-x | pc | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -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,' |