blob: 2736377104857ec31ff96b96949f1f809cded1e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|