summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-21 17:21:45 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-21 17:21:45 +0100
commit0ac76332d39b0e40aea16f0ba22886a014bab373 (patch)
treee9ec9481ea0181de74394c7d11f531b4c1d0cb22
parentae40d5204ae0d751d17497cba532e5f428aa5747 (diff)
downloadweb-0ac76332d39b0e40aea16f0ba22886a014bab373.tar.gz
Add 'blm' tool (converts search results to mbox)
-rwxr-xr-xblm27
1 files changed, 27 insertions, 0 deletions
diff --git a/blm b/blm
new file mode 100755
index 0000000..2736377
--- /dev/null
+++ b/blm
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Format Blocket.se search results
+
+# Convert json to mbox
+jq -r '.data[] |
+ "From BLOCKET " + (.list_time | sub("\\+[0-9][0-9]:00$"; "Z") | fromdate | strftime("%a %b %e %T %Y")) + "\n" +
+ "From: " + .advertiser.name + ", " + .location[0].name + " (" + .advertiser.type + ")\n" +
+ "Subject: " + "(" + (.price.value | tostring) + ") " + .subject + "\n" +
+ # (.images[] | "X-Image: " + .url + "\n") +
+ ([.images[].url] | map("X-Image: " + .) | join("\n")) + "\n" +
+ "\n" + .body + "\n" +
+ "\n"
+'
+
+exit
+# Download and convert images to attachments
+while read line
+do
+ case "$line" in
+ "X-Image: "*)
+ ;;
+ *)
+ printf '%s\n' "$line"
+ ;;
+ esac
+done