diff options
-rwxr-xr-x | blm | 18 | ||||
-rw-r--r-- | blm.1 | 9 | ||||
-rwxr-xr-x | blq | 10 | ||||
-rw-r--r-- | blq.1 | 10 | ||||
-rwxr-xr-x | xii | 4 | ||||
-rw-r--r-- | xii.1 | 10 |
6 files changed, 47 insertions, 14 deletions
@@ -4,9 +4,21 @@ 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 + ")\" <noreply@localhost>\n" + - "Subject: " + "(" + (.price.value | tostring) + ") " + .subject + "\n" + - ([.images[].url] | map("X-Image: " + . + "?type=original") | join("\n")) + "\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" ' @@ -11,6 +11,7 @@ translator for . .Sh SYNOPSIS .Nm +.Op Fl d . .Sh DESCIPTION .Pp @@ -21,6 +22,14 @@ received on standard input, into .Xr mboxu 5 . The results can be saved in a file and opened successfully with most mail readers. + +If the +.Fl d +(dumb) flag is present, then the location and price associated with each ad are added to the +.Ql From +and +.Ql Subject +headers, respectively. . .Sh AUTHORS .Pp @@ -1,6 +1,6 @@ #!/bin/sh -# Perform a search on Blocket.se (API v6, Nov 2020) +# Perform a search on Blocket.se (Nov 2020) usage() { echo usage: $0 query 1>&2; exit 1; } @@ -11,10 +11,12 @@ fi # Parse options r= -while getopts rc o +d= +while getopts dr o do case $o in - r) r=1 ;; # process with blm and read in MAILER + d) d=-d ;; # send -d (dumb) option to blm + r) r=-r ;; # process with blm and read in MAILER ?) usage ;; esac done @@ -32,7 +34,7 @@ curl -s -H "authorization: Bearer $tok" "https://api.blocket.se/search_bff/v1/co { test ! -z "$r" && { f=/tmp/blq.$RANDOM - blm > $f + blm $d > $f eval $MAILER -f $f < /dev/tty rm $f } || cat @@ -9,6 +9,7 @@ .Sh SYNOPSIS .Nm .Op Fl r +.Op Fl d .Ar query . .Sh DESCIPTION @@ -39,6 +40,15 @@ and opens the resulting mbox file in or the value of .Ev MAILER . The temporary mbox file is automatically deleted. + +If +.Fl r +is present together with +.Fl d , +.Xr blm 1 +is called with the +.Fl d +flag. . .Sh AUTHORS .Pp @@ -1,6 +1,6 @@ #!/bin/sh -# Download and display X-Image images +# Download and display images referenced in Image headers : ${VIEWER:=fbi} @@ -8,7 +8,7 @@ dir=/tmp/$RANDOM mkdir $dir -sed -n 's/^X-Image: //p' | +sed -n 's/^Image: //p' | while read url do curl "$url" > $dir/$RANDOM @@ -4,7 +4,7 @@ . .Sh NAME .Nm xii -.Nd X-Image viewer +.Nd download and view images in Image headers . .Sh SYNOPSIS .Nm @@ -13,10 +13,10 @@ .Pp .Nm downloads and views images specified in any number of -.Ql X-Image -headers contained in any number of e-mail messages given on standard input. +.Ql Image +headers contained in any number of mail messages given on standard input. Any line not containing an -.Ql X-Image +.Ql Image header is ignored. This means that you can conveniently pipe messages from @@ -25,7 +25,7 @@ into .Nm to display any referenced remote images. -.Ql X-Image +.Ql Image headers serve as a way of referencing (remote) images in an e-mail message without MIME. They are used in the output of .Xr blm 1 . |