From 0ac76332d39b0e40aea16f0ba22886a014bab373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 21 Nov 2020 17:21:45 +0100 Subject: Add 'blm' tool (converts search results to mbox) --- blm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 blm (limited to 'blm') 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 -- cgit v1.2.3