summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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