Introduction
Introduction Statistics Contact Development Disclaimer Help
tfilmprice - filmtools - various tools for photographic film development and da…
git clone git://src.adamsgaard.dk/filmtools
Log
Files
Refs
LICENSE
---
tfilmprice (4128B)
---
1 #!/bin/sh
2 # get current film prices from fotoimpex and return price per roll
3
4 rolls_per_bulk_roll=19
5
6 die() {
7 printf '%s: error: %s\n' "${0##*/}" "$1" >&2
8 exit 1
9 }
10
11 # 1: product string, 2: format
12 fotoimpex_path() {
13 case "$2" in
14 120)
15 case "$1" in
16 kodak-portra-400|fuji-pro-400-h)
17 printf '%s-120-medium-format-fil…
18 *)
19 printf '%s-120-medium-format-fil…
20 esac;;
21 135)
22 case "$1" in
23 adox-chs-100-ii)
24 printf '%s-35mm-film-13536.html'…
25 adox-cms-20-ii)
26 printf '%s-13536-35mm-36-exposur…
27 adox-hr-50)
28 printf '%s-13536-with-speed-boos…
29 adox-silvermax)
30 printf '%s-bw-film-with-high-sil…
31 ilford-pan-f)
32 printf '%s-13536-50-asa.html' "$…
33 ilford-fp4)
34 printf '%s-125-asa-13536.html' "…
35 ilford-hp5)
36 printf '%s-13536-400-asa.html' "…
37 fuji-fujicolor-c200)
38 printf '%s-135-36-single-pack.ht…
39 kodak-t-max-p3200)
40 printf '%s-tmz-35-mm-film.html' …
41 kodak-portra-400|rollei*)
42 printf '%s-135-36.html' "$1";;
43 kodak-ektar-100)
44 printf '%s-35mm-film-13536.html'…
45 *)
46 printf '%s-13536.html' "$1";;
47 esac;;
48 30.5m)
49 case "$1" in
50 ilford-delta-400)
51 printf '%s-kb-305m-bulk-roll.htm…
52 ilford-fp4|ilford-hp5)
53 printf '%s-13536-bulk-roll-305m.…
54 kodak*)
55 printf '%s-305m-bulk-film.html' …
56 rollei-rpx-400)
57 printf '%s-35mm-305m-bulk-roll.h…
58 *)
59 printf '%s-305m-bulk-roll.html' …
60 esac;;
61 4x5)
62 printf '%s-102x127-cm-4x5-inch-25-sheets.html' "…
63 *)
64 die "unknown film format '$2'"
65 esac
66 }
67
68 # 1: product string, 2: format
69 fotoimpex_url() {
70 printf 'https://www.fotoimpex.com/films/%s\n' "$(fotoimpex_path …
71 }
72
73 macodirect_url() {
74 printf 'https://www.macodirect.de/en/film/%s\n' "$(fotoimpex_pat…
75 }
76
77 fotoimpex_extract_price() {
78 if grep -qE 'From *10' "$1"; then
79 if grep -qE 'From *5' "$1"; then
80 n=6
81 else
82 n=4
83 fi
84 else
85 n=2
86 fi
87 price="$(grep EUR "$1" | head -$n | tail -1 | \
88 sed 's,.*<b>,,
89 s#,#.#g
90 s,&nbsp;, ,g
91 s,</b>.*,,
92 s, *EUR,,')"
93 if [ ! -z "$price" ]; then
94 if [ "$2" = "30.5m" ]; then
95 printf '%.2f' \
96 "$(echo "${price}"/"${rolls_per_bulk_rol…
97 else
98 printf '%s' "$price"
99 fi
100 else
101 printf -- '--\t--'
102 fi
103 }
104
105 get_html() {
106 if command -v hurl >/dev/null 2>&1; then
107 hurl "$1" 2>/dev/null
108 elif command -v curl >/dev/null 2>&1; then
109 curl -s "$1" 2>/dev/null
110 else
111 die 'no suitable html fetcher found'
112 fi
113 sleep 1
114 if [ $? -ne 0 ]; then
115 return 1
116 fi
117 }
118
119 eur_to_dkk() {
120 printf '%.2f' "$(printf '%s*7.46\n' "$1" | bc -l)"
121 }
122
123 fotoimpex() {
124 out="fotoimpex_${1}_${2}.html"
125 url="$(fotoimpex_url "$1" "$2")"
126 if [ ! -e "$out" ]; then
127 if ! get_html "$url" > "$out"; then
128 rm -f "$out"
129 fi
130 fi
131 if [ -e "$out" ]; then
132 price="$(fotoimpex_extract_price "$out" "$2")"
133 if [ ! "$price" = "-- --" ]; then
134 printf '%-24s\t%s\t' "$1" "$2"
135 printf '%s\tEUR\t' "$price"
136 printf '%s\tDKK\t' "$(eur_to_dkk "$price")"
137 printf '%s\n' "$url"
138 fi
139 fi
140 }
141
142 macodirect() {
143 out="macodirect_${1}_${2}.html"
144 url="$(macodirect_url "$1" "$2")"
145 if [ ! -e "$out" ]; then
146 if ! get_html "$url" > "$out"; then
147 rm -f "$out"
148 fi
149 fi
150 # if [ -e "$out" ]; then
151 # price="$(macodirect_extract_price "$out" "$2")"
152 # if [ ! "$price" = "-- --" ]; then
153 # printf '%-24s\t%s\t' "$1" "$2"
154 # printf '%s\tEUR\t' "$price"
155 # printf '%s\tDKK\t' "$(eur_to_dkk "$price")"
156 # printf '%s\n' "$url"
157 # fi
158 # fi
159 }
160
161
162 film_products="adox-chs-100-ii
163 adox-cms-20-ii
164 adox-hr-50
165 adox-silvermax
166 ilford-delta-100
167 ilford-delta-400
168 ilford-pan-f
169 ilford-fp4
170 ilford-hp5
171 fuji-neopan-acros-ii-neu-100
172 fuji-fujicolor-c200
173 fuji-pro-400-h
174 kodak-t-max-100
175 kodak-t-max-400
176 kodak-t-max-p3200
177 kodak-tri-x-400
178 kodak-ektar-100
179 kodak-portra-160
180 kodak-portra-400
181 kodak-portra-800
182 rollei-rpx-25
183 rollei-rpx-100
184 rollei-rpx-400"
185
186 film_formats="135
187 30.5m
188 120
189 4x5"
190
191 for p in $film_products; do
192 for f in $film_formats; do
193 fotoimpex "$p" "$f"
194 macodirect "$p" "$f"
195 done
196 done
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.