imdb2gopherbay - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
imdb2gopherbay (1421B)
---
1 #!/bin/sh
2
3 set -x
4
5 export PATH="/home/annna/bin:$PATH"
6
7 if [ $# -lt 1 ];
8 then
9 printf "usage: %s imdburi\n" "$(basename "$0")" >&2
10 exit 1
11 fi
12
13 imdburi="$1"
14
15 # Josuah Ver0:
16 #extractjson() {
17 #awk '
18 #/<script id="__NEXT_DATA__"/ {
19 # match($0, "<script id=\"__NEXT_DATA__\"[^>]*>");
20 # s = substr($0, RSTART + RLENGTH);OB
21 # match(s, "</script>");
22 # s = substr(s, 1, RSTART - 1);
23 # print s;
24 #}'
25 #}
26
27 # Raw Ver1:
28 #title="$(curl -H 'Accept-Language: en' -s "${imdburi}" \
29 # | grabtitle \
30 # | sed 's, - IMDb,,')"
31
32 # Ver1:
33 #title="$(curl -H 'Accept-Language: en' -s "${imdburi}" \
34 # | extractjson \
35 # | json2tsv \
36 # | grep associatedTitle.originalTitleText.text )"
37 # | head -n 1 \
38 # | cut -f 3)"
39
40 #[ -z "${title}" ] && exit 1
41 #
42 #printf "%s\n" "${title}"
43
44 # Evil_Bob Ver2: Thanks!
45 curl -H 'Accept-Language: en' \
46 -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0' \
47 -s "${imdburi}" \
48 | extractjson | sed 1q | json2tsv | LC_ALL=C awk '
49 BEGIN {
50 FS = OFS = "\t";
51 }
52 $1 == ".@type" { type = $3; }
53 $1 == ".description" { description = $3; }
54 $1 == ".name" { name = $3; uriname = gensub(" ", "+", "g", $3); }
55 $1 == ".aggregateRating.ratingValue" { rating = $3; }
56 $1 == ".datePublished" { published = substr($3, 1, 4); }
57 END {
58 printf("gophers://bitreich.org/1/bay/search/%s | %s (%s) from %s, rating: %s: %s\n",
59 uriname, name, type, published, rating, description);
60 }'
61
62