summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-12-03 15:47:31 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-12-03 15:47:31 +0100
commit091b91811202902dce64666c29fdc2a77bc2c7d9 (patch)
tree8b651ed0e9822232f813156444b7c237ae89c73e
parentb62fc8acc683aaaa7ae24552ed5b5129378318ad (diff)
downloadpc-091b91811202902dce64666c29fdc2a77bc2c7d9.tar.gz
Rename File to Link, move filename generation from pd to pc
-rwxr-xr-xpc17
-rwxr-xr-xpd11
2 files changed, 15 insertions, 13 deletions
diff --git a/pc b/pc
index 31c7fe2..e5b28f6 100755
--- a/pc
+++ b/pc
@@ -6,7 +6,7 @@ sed -e '/^$/d' -e 's/^[ ]*//' |
awk -vFS='[<>]' -vOFS=' ' '
/<pubDate>/ { date = $3 }
/<itunes:duration>/ { duration = $3 }
- /<enclosure[^>]*>/ { file = $0 }
+ /<enclosure[^>]*>/ { link = $0 }
/<description>$/ { getline; summary = $0 }
/<description>..*/ { summary = $3 }
/<itunes:summary>$/ { getline; summary = $0 }
@@ -16,7 +16,15 @@ awk -vFS='[<>]' -vOFS=' ' '
print "Title: " title
print "Duration: " duration
print "Date: " date
- print "File: " file
+ gsub(/^<enclosure[^>]* url="/, "", link)
+ gsub(/".*/, "", link)
+ print "Link: " link
+ gsub(/\\\\/, ".", title)
+ gsub(/[\/:*<>|]/, ".", title)
+ gsub(/.*\./, ".", link)
+ print "File: " title link
+ gsub(/<!\[CDATA\[/, "", summary)
+ gsub(/\]\]>/, "", summary)
print "Summary: " summary
print ""
date = "?"
@@ -25,7 +33,4 @@ awk -vFS='[<>]' -vOFS=' ' '
summary = "?"
title = "?"
}
-' |
-sed -e 's,<description>,,' \
- -e 's,<enclosure[^>]* url="\([^"]*\)".*,\1,' \
- -e 's,<!\[CDATA\[\(.*\)\]\]>,\1,'
+'
diff --git a/pd b/pd
index 354991b..d5782c2 100755
--- a/pd
+++ b/pd
@@ -2,13 +2,10 @@
# pd -- download podcast episode(s)
-u=
-test "$1" = -u && u=1 # unix mode
-
-eval curl -ZL "$(sed -n 's/^Title: \|File: //p' |
+eval curl -ZL "$(sed -n 's/^Link: \|File: //p' |
sed 's/ / /g; s/\\/\\\\/g; '"s/'/'\"'\"'/g" |
paste - - |
-while IFS=' ' read title file; do
- test -z "$u" && title=`printf '%s\n' "$title" | sed 's/\\\\/./g; s,[/:*<>|],.,g; s/?//g; '"s/\"/'\"'\"'/g"` # dos/windows (default)
- printf "-o '%s' '%s' " "$title.${file##*.}" "$file"
+while IFS=' ' read link file; do
+ file=`printf '%s\n' "$file" | sed "s/\"/'\"'\"'/g"`
+ printf "-o '%s' '%s' " "$file" "$link"
done)"