diff options
author | John Ankarström <john@ankarstrom.se> | 2020-11-21 17:21:45 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2020-11-21 17:21:45 +0100 |
commit | 0ac76332d39b0e40aea16f0ba22886a014bab373 (patch) | |
tree | e9ec9481ea0181de74394c7d11f531b4c1d0cb22 /blm | |
parent | ae40d5204ae0d751d17497cba532e5f428aa5747 (diff) | |
download | web-0ac76332d39b0e40aea16f0ba22886a014bab373.tar.gz |
Add 'blm' tool (converts search results to mbox)
Diffstat (limited to 'blm')
-rwxr-xr-x | blm | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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 |