tChange 35mm order, remove old snapshot - filmtools - various tools for photogr… | |
git clone git://src.adamsgaard.dk/filmtools | |
Log | |
Files | |
Refs | |
--- | |
commit 114aa08838c019e9c4dacea81acfc3591e78f3d5 | |
parent 3df21184b1937f8571f7c240f739210c749c3f96 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 20 Apr 2020 11:11:48 +0200 | |
Change 35mm order, remove old snapshot | |
Diffstat: | |
A filmprice | 184 +++++++++++++++++++++++++++++… | |
D filmprice.sh | 184 -----------------------------… | |
D filmprice_2020-04-18 | 44 -----------------------------… | |
3 files changed, 184 insertions(+), 228 deletions(-) | |
--- | |
diff --git a/filmprice b/filmprice | |
t@@ -0,0 +1,184 @@ | |
+#!/bin/sh | |
+# get current film prices from fotoimpex and return price per roll | |
+ | |
+rolls_per_bulk_roll=19 | |
+ | |
+die() { | |
+ printf 'error: %s' "$1" >&2 | |
+ exit 1 | |
+} | |
+ | |
+# 1: product string, 2: format | |
+fotoimpex_path() { | |
+ case "$2" in | |
+ 120) | |
+ case "$1" in | |
+ kodak-portra-400|fuji-pro-400-h) | |
+ printf '%s-120-medium-format-film-sing… | |
+ *) | |
+ printf '%s-120-medium-format-film.html… | |
+ esac;; | |
+ 135) | |
+ case "$1" in | |
+ ilford-pan-f) | |
+ printf '%s-13536-50-asa.html' "$1";; | |
+ ilford-fp4) | |
+ printf '%s-125-asa-13536.html' "$1";; | |
+ ilford-hp5) | |
+ printf '%s-13536-400-asa.html' "$1";; | |
+ fuji-fujicolor-c200) | |
+ printf '%s-135-36-single-pack.html' "$… | |
+ kodak-t-max-p3200) | |
+ printf '%s-tmz-35-mm-film.html' "$1";; | |
+ kodak-portra-400|rollei*) | |
+ printf '%s-135-36.html' "$1";; | |
+ kodak-ektar-100) | |
+ printf '%s-35mm-film-13536.html' "$1";; | |
+ *) | |
+ printf '%s-13536.html' "$1";; | |
+ esac;; | |
+ 30.5m) | |
+ case "$1" in | |
+ ilford-delta-400) | |
+ printf '%s-kb-305m-bulk-roll.html' "$1… | |
+ ilford-fp4|ilford-hp5) | |
+ printf '%s-13536-bulk-roll-305m.html' … | |
+ kodak*) | |
+ printf '%s-305m-bulk-film.html' "$1";; | |
+ rollei-rpx-400) | |
+ printf '%s-35mm-305m-bulk-roll.html' "… | |
+ *) | |
+ printf '%s-305m-bulk-roll.html' "$1";; | |
+ esac;; | |
+ 4x5) | |
+ printf '%s-102x127-cm-4x5-inch-25-sheets.html' "$1";; | |
+ *) | |
+ die "unknown film format '$2'" | |
+ esac | |
+} | |
+ | |
+# 1: product string, 2: format | |
+fotoimpex_url() { | |
+ printf 'https://www.fotoimpex.com/films/%s\n' "$(fotoimpex_path "$1" "… | |
+} | |
+ | |
+macodirect_url() { | |
+ printf 'https://www.macodirect.de/en/film/%s\n' "$(fotoimpex_path "$1"… | |
+} | |
+ | |
+fotoimpex_extract_price() { | |
+ if grep -qE 'From *10' "$1"; then | |
+ if grep -qE 'From *5' "$1"; then | |
+ n=6 | |
+ else | |
+ n=4 | |
+ fi | |
+ else | |
+ n=2 | |
+ fi | |
+ price="$(grep EUR "$1" | head -$n | tail -1 | \ | |
+ sed 's,.*<b>,, | |
+ s#,#.#g | |
+ s, , ,g | |
+ s,</b>.*,, | |
+ s, *EUR,,')" | |
+ if [ ! -z "$price" ]; then | |
+ if [ "$2" = "30.5m" ]; then | |
+ printf '%.2f' \ | |
+ "$(echo "${price}"/"${rolls_per_bulk_roll}" | … | |
+ else | |
+ printf '%s' "$price" | |
+ fi | |
+ else | |
+ printf '--\t--' | |
+ fi | |
+} | |
+ | |
+get_html() { | |
+ if type -v hurl >/dev/null 2>&1; then | |
+ hurl "$1" 2>/dev/null | |
+ elif type -v curl >/dev/null 2>&1; then | |
+ curl -s "$1" 2>/dev/null | |
+ else | |
+ die 'no suitable html fetcher found' | |
+ fi | |
+ sleep 1 | |
+ if [ $? -ne 0 ]; then | |
+ return 1 | |
+ fi | |
+} | |
+ | |
+eur_to_dkk() { | |
+ printf '%.2f' "$(printf '%s*7.46\n' "$1" | bc -l)" | |
+} | |
+ | |
+fotoimpex() { | |
+ out="fotoimpex_${1}_${2}.html" | |
+ url="$(fotoimpex_url "$1" "$2")" | |
+ if [ ! -e "$out" ]; then | |
+ if ! get_html "$url" > "$out"; then | |
+ rm -f "$out" | |
+ fi | |
+ fi | |
+ if [ -e "$out" ]; then | |
+ price="$(fotoimpex_extract_price "$out" "$2")" | |
+ if [ ! "$price" = "-- --" ]; then | |
+ printf '%-24s\t%s\t' "$1" "$2" | |
+ printf '%s\tEUR\t' "$price" | |
+ printf '%s\tDKK\t' "$(eur_to_dkk "$price")" | |
+ printf '%s\n' "$url" | |
+ fi | |
+ fi | |
+} | |
+ | |
+macodirect() { | |
+ out="macodirect_${1}_${2}.html" | |
+ url="$(macodirect_url "$1" "$2")" | |
+ if [ ! -e "$out" ]; then | |
+ if ! get_html "$url" > "$out"; then | |
+ rm -f "$out" | |
+ fi | |
+ fi | |
+# if [ -e "$out" ]; then | |
+# price="$(macodirect_extract_price "$out" "$2")" | |
+# if [ ! "$price" = "-- --" ]; then | |
+# printf '%-24s\t%s\t' "$1" "$2" | |
+# printf '%s\tEUR\t' "$price" | |
+# printf '%s\tDKK\t' "$(eur_to_dkk "$price")" | |
+# printf '%s\n' "$url" | |
+# fi | |
+# fi | |
+} | |
+ | |
+ | |
+film_products="ilford-delta-100 | |
+ilford-delta-400 | |
+ilford-pan-f | |
+ilford-fp4 | |
+ilford-hp5 | |
+fuji-neopan-acros-ii-neu-100 | |
+fuji-fujicolor-c200 | |
+fuji-pro-400-h | |
+kodak-t-max-100 | |
+kodak-t-max-400 | |
+kodak-t-max-p3200 | |
+kodak-tri-x-400 | |
+kodak-ektar-100 | |
+kodak-portra-160 | |
+kodak-portra-400 | |
+kodak-portra-800 | |
+rollei-rpx-25 | |
+rollei-rpx-100 | |
+rollei-rpx-400" | |
+ | |
+film_formats="135 | |
+30.5m | |
+120 | |
+4x5" | |
+ | |
+for p in $film_products; do | |
+ for f in $film_formats; do | |
+ fotoimpex "$p" "$f" | |
+ macodirect "$p" "$f" | |
+ done | |
+done | |
diff --git a/filmprice.sh b/filmprice.sh | |
t@@ -1,184 +0,0 @@ | |
-#!/bin/sh | |
-# get current film prices from fotoimpex and return price per roll | |
- | |
-rolls_per_bulk_roll=19 | |
- | |
-die() { | |
- printf 'error: %s' "$1" >&2 | |
- exit 1 | |
-} | |
- | |
-# 1: product string, 2: format | |
-fotoimpex_path() { | |
- case "$2" in | |
- 120) | |
- case "$1" in | |
- kodak-portra-400|fuji-pro-400-h) | |
- printf '%s-120-medium-format-film-sing… | |
- *) | |
- printf '%s-120-medium-format-film.html… | |
- esac;; | |
- 135) | |
- case "$1" in | |
- ilford-pan-f) | |
- printf '%s-13536-50-asa.html' "$1";; | |
- ilford-fp4) | |
- printf '%s-125-asa-13536.html' "$1";; | |
- ilford-hp5) | |
- printf '%s-13536-400-asa.html' "$1";; | |
- fuji-fujicolor-c200) | |
- printf '%s-135-36-single-pack.html' "$… | |
- kodak-t-max-p3200) | |
- printf '%s-tmz-35-mm-film.html' "$1";; | |
- kodak-portra-400|rollei*) | |
- printf '%s-135-36.html' "$1";; | |
- kodak-ektar-100) | |
- printf '%s-35mm-film-13536.html' "$1";; | |
- *) | |
- printf '%s-13536.html' "$1";; | |
- esac;; | |
- 30.5m) | |
- case "$1" in | |
- ilford-delta-400) | |
- printf '%s-kb-305m-bulk-roll.html' "$1… | |
- ilford-fp4|ilford-hp5) | |
- printf '%s-13536-bulk-roll-305m.html' … | |
- kodak*) | |
- printf '%s-305m-bulk-film.html' "$1";; | |
- rollei-rpx-400) | |
- printf '%s-35mm-305m-bulk-roll.html' "… | |
- *) | |
- printf '%s-305m-bulk-roll.html' "$1";; | |
- esac;; | |
- 4x5) | |
- printf '%s-102x127-cm-4x5-inch-25-sheets.html' "$1";; | |
- *) | |
- die "unknown film format '$2'" | |
- esac | |
-} | |
- | |
-# 1: product string, 2: format | |
-fotoimpex_url() { | |
- printf 'https://www.fotoimpex.com/films/%s\n' "$(fotoimpex_path "$1" "… | |
-} | |
- | |
-macodirect_url() { | |
- printf 'https://www.macodirect.de/en/film/%s\n' "$(fotoimpex_path "$1"… | |
-} | |
- | |
-fotoimpex_extract_price() { | |
- if grep -qE 'From *10' "$1"; then | |
- if grep -qE 'From *5' "$1"; then | |
- n=6 | |
- else | |
- n=4 | |
- fi | |
- else | |
- n=2 | |
- fi | |
- price="$(grep EUR "$1" | head -$n | tail -1 | \ | |
- sed 's,.*<b>,, | |
- s#,#.#g | |
- s, , ,g | |
- s,</b>.*,, | |
- s, *EUR,,')" | |
- if [ ! -z "$price" ]; then | |
- if [ "$2" = "30.5m" ]; then | |
- printf '%.2f' \ | |
- "$(echo "${price}"/"${rolls_per_bulk_roll}" | … | |
- else | |
- printf '%s' "$price" | |
- fi | |
- else | |
- printf '--\t--' | |
- fi | |
-} | |
- | |
-get_html() { | |
- if type -v hurl >/dev/null 2>&1; then | |
- hurl "$1" 2>/dev/null | |
- elif type -v curl >/dev/null 2>&1; then | |
- curl -s "$1" 2>/dev/null | |
- else | |
- die 'no suitable html fetcher found' | |
- fi | |
- sleep 1 | |
- if [ $? -ne 0 ]; then | |
- return 1 | |
- fi | |
-} | |
- | |
-eur_to_dkk() { | |
- printf '%.2f' "$(printf '%s*7.46\n' "$1" | bc -l)" | |
-} | |
- | |
-fotoimpex() { | |
- out="fotoimpex_${1}_${2}.html" | |
- url="$(fotoimpex_url "$1" "$2")" | |
- if [ ! -e "$out" ]; then | |
- if ! get_html "$url" > "$out"; then | |
- rm -f "$out" | |
- fi | |
- fi | |
- if [ -e "$out" ]; then | |
- price="$(fotoimpex_extract_price "$out" "$2")" | |
- if [ ! "$price" = "-- --" ]; then | |
- printf '%-24s\t%s\t' "$1" "$2" | |
- printf '%s\tEUR\t' "$price" | |
- printf '%s\tDKK\t' "$(eur_to_dkk "$price")" | |
- printf '%s\n' "$url" | |
- fi | |
- fi | |
-} | |
- | |
-macodirect() { | |
- out="macodirect_${1}_${2}.html" | |
- url="$(macodirect_url "$1" "$2")" | |
- if [ ! -e "$out" ]; then | |
- if ! get_html "$url" > "$out"; then | |
- rm -f "$out" | |
- fi | |
- fi | |
-# if [ -e "$out" ]; then | |
-# price="$(macodirect_extract_price "$out" "$2")" | |
-# if [ ! "$price" = "-- --" ]; then | |
-# printf '%-24s\t%s\t' "$1" "$2" | |
-# printf '%s\tEUR\t' "$price" | |
-# printf '%s\tDKK\t' "$(eur_to_dkk "$price")" | |
-# printf '%s\n' "$url" | |
-# fi | |
-# fi | |
-} | |
- | |
- | |
-film_products="ilford-delta-100 | |
-ilford-delta-400 | |
-ilford-pan-f | |
-ilford-fp4 | |
-ilford-hp5 | |
-fuji-neopan-acros-ii-neu-100 | |
-fuji-fujicolor-c200 | |
-fuji-pro-400-h | |
-kodak-t-max-100 | |
-kodak-t-max-400 | |
-kodak-t-max-p3200 | |
-kodak-tri-x-400 | |
-kodak-ektar-100 | |
-kodak-portra-160 | |
-kodak-portra-400 | |
-kodak-portra-800 | |
-rollei-rpx-25 | |
-rollei-rpx-100 | |
-rollei-rpx-400" | |
- | |
-film_formats="135 | |
-120 | |
-4x5 | |
-30.5m" | |
- | |
-for p in $film_products; do | |
- for f in $film_formats; do | |
- fotoimpex "$p" "$f" | |
- macodirect "$p" "$f" | |
- done | |
-done | |
diff --git a/filmprice_2020-04-18 b/filmprice_2020-04-18 | |
t@@ -1,44 +0,0 @@ | |
-ilford-delta-100 135 6.60 EUR 49.24 … | |
-ilford-delta-100 120 5.65 EUR 42.15 … | |
-ilford-delta-100 4x5 58.20 EUR 434.17 … | |
-ilford-delta-100 30.5m 4.99 EUR 37.23 … | |
-ilford-delta-400 135 6.60 EUR 49.24 … | |
-ilford-delta-400 120 5.65 EUR 42.15 … | |
-ilford-delta-400 30.5m 4.99 EUR 37.23 … | |
-ilford-pan-f 135 7.10 EUR 52.97 … | |
-ilford-pan-f 120 6.10 EUR 45.51 … | |
-ilford-fp4 135 5.90 EUR 44.01 … | |
-ilford-fp4 120 4.90 EUR 36.55 … | |
-ilford-fp4 4x5 51.20 EUR 381.95 … | |
-ilford-fp4 30.5m 4.84 EUR 36.11 … | |
-ilford-hp5 135 5.60 EUR 41.78 … | |
-ilford-hp5 120 4.90 EUR 36.55 … | |
-ilford-hp5 4x5 50.20 EUR 374.49 … | |
-ilford-hp5 30.5m 4.42 EUR 32.97 … | |
-fuji-neopan-acros-ii-neu-100 135 12.95 EUR 96.61 … | |
-fuji-fujicolor-c200 135 2.99 EUR 22.31 … | |
-fuji-pro-400-h 135 9.90 EUR 73.85 … | |
-fuji-pro-400-h 120 8.15 EUR 60.80 … | |
-kodak-t-max-100 135 7.10 EUR 52.97 … | |
-kodak-t-max-100 120 7.10 EUR 52.97 … | |
-kodak-t-max-400 135 8.00 EUR 59.68 … | |
-kodak-t-max-400 120 7.10 EUR 52.97 … | |
-kodak-t-max-p3200 135 9.80 EUR 73.11 … | |
-kodak-tri-x-400 135 7.50 EUR 55.95 … | |
-kodak-tri-x-400 120 8.20 EUR 61.17 … | |
-kodak-tri-x-400 30.5m 9.95 EUR 74.23 … | |
-kodak-ektar-100 135 9.00 EUR 67.14 … | |
-kodak-ektar-100 120 6.80 EUR 50.73 … | |
-kodak-portra-160 135 9.10 EUR 67.89 … | |
-kodak-portra-160 120 9.25 EUR 69.00 … | |
-kodak-portra-400 135 9.55 EUR 71.24 … | |
-kodak-portra-400 120 9.00 EUR 67.14 … | |
-kodak-portra-800 135 12.60 EUR 94.00 … | |
-kodak-portra-800 120 11.70 EUR 87.28 … | |
-rollei-rpx-25 135 5.49 EUR 40.96 … | |
-rollei-rpx-25 120 5.00 EUR 37.30 … | |
-rollei-rpx-100 135 4.75 EUR 35.44 … | |
-rollei-rpx-100 120 5.15 EUR 38.42 … | |
-rollei-rpx-400 135 4.70 EUR 35.06 … | |
-rollei-rpx-400 120 5.15 EUR 38.42 … | |
-rollei-rpx-400 30.5m 3.29 EUR 24.54 … |