add imdb script - randomcrap - random crap programs of varying quality
HTML git clone git://git.codemadness.org/randomcrap
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 3460be2b98420fda3f4a6017615054da29f931d5
DIR parent 103e6fb96c7a6800ca18dc56515871200bfd995c
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 3 Mar 2023 00:44:55 +0100
add imdb script
Diffstat:
A imdb.sh | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)
---
DIR diff --git a/imdb.sh b/imdb.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if test "$1" = ""; then
+ echo "usage: $0 <imdb_URL>" >&2
+ exit 1
+fi
+
+curl \
+ -f -s -m 10 \
+ -L --max-redirs 0 \
+ -H 'Accept-Language: en' \
+ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0' \
+ "$1" | \
+extractjson | \
+sed 1q | \
+json2tsv | \
+LC_ALL=C awk '
+BEGIN {
+ FS = OFS = "\t";
+}
+$1 == ".@type" { type = $3; }
+$1 == ".description" { description = $3; }
+$1 == ".name" { name = $3; }
+$1 == ".aggregateRating.ratingValue" { rating = $3; }
+$1 == ".datePublished" { published = substr($3, 1, 4); }
+END {
+ if (length(name))
+ printf("%s (%s) from %s, rating: %s: %s\n",
+ name, type, published, rating, description);
+}'