From 4d61b23877af9cd5c302a1e4423b2399601dad43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 3 Dec 2020 03:50:22 +0100 Subject: pc: Use fixed output order, handle summary/description better --- pc | 33 +++++++++++++++++++++++++-------- 1 file 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 '//,$p' | sed -e '/^$/d' -e 's/^[ ]*//' | -awk -vFS='[<>]' ' - // { print "Date: " $3; } - // { 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,' -- cgit v1.2.3