summaryrefslogtreecommitdiff
path: root/blm
blob: 51bd0e5733bcdd741d8133d2c51ea000ec244eae (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
#!/bin/sh

# Format Blocket.se search results as mboxu

jq -r '.data[] |
	"From BLOCKET " + (.list_time | sub("\\+[0-9][0-9]:00$"; "Z") | fromdate | strftime("%a %b %e %T %Y")) + "\n" +
'"$(test "$1" = -d && printf '%s\n' '
	"From: \"" + .advertiser.name + ", " + .location[0].name + "\" <noreply@localhost>\n" +
	"Subject: (" + (.price.value | tostring) + ") " + .subject + "\n" +
' || printf '%s\n' '
	"From: \"" + .advertiser.name + "\" <noreply@localhost>\n" +
	"Subject: " + .subject + "\n" +
')"'
	"ID: " + .ad_id + "\n" +
	"Link: " + .share_url + "\n" +
	"Price: " + (.price.value | tostring) + " " + .price.suffix + "\n" +
	"Type: " + .advertiser.type + "\n" +
	([.category[].name] | map("Category: " + . ) | join("\n")) + "\n" +
	([.location[].name] | map("Location: " + . ) | join("\n")) + "\n" +
	"Map: " + .map_url + "\n" +
	([.images[].url] | map("Image: " + . + "?type=original") | join("\n")) + "\n" +
	"\n" + .body + "\n" +
	"\n"
'