imdb.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
imdb.sh (670B)
---
1 #!/bin/sh
2
3 if test "$1" = ""; then
4 echo "usage: $0 <imdb_URL>" >&2
5 exit 1
6 fi
7
8 curl \
9 -f -s -m 10 \
10 -L --max-redirs 0 \
11 -H 'Accept-Language: en' \
12 -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0' \
13 "$1" | \
14 extractjson | \
15 sed 1q | \
16 json2tsv | \
17 LC_ALL=C awk '
18 BEGIN {
19 FS = OFS = "\t";
20 }
21 $1 == ".@type" { type = $3; }
22 $1 == ".description" { description = $3; }
23 $1 == ".name" { name = $3; }
24 $1 == ".aggregateRating.ratingValue" { rating = $3; }
25 $1 == ".datePublished" { published = substr($3, 1, 4); }
26 END {
27 if (length(name))
28 printf("%s (%s) from %s, rating: %s: %s\n",
29 name, type, published, rating, description);
30 }'