summaryrefslogtreecommitdiff
path: root/parser/ozchai.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-12-19 16:03:45 +0600
committerunwox <me@unwox.com>2024-12-19 16:13:42 +0600
commit441d7fd5a5a0ccf8d53238d717ec5119024cbbfa (patch)
tree0ab998dfaaddd0d6bcde9aa6d398364fc996531f /parser/ozchai.fnl
parentd3a445ad7270e788812dd16e19a2820fc70a91b6 (diff)
parse teaware volume and let users filter by it
Diffstat (limited to 'parser/ozchai.fnl')
-rw-r--r--parser/ozchai.fnl7
1 files changed, 7 insertions, 0 deletions
diff --git a/parser/ozchai.fnl b/parser/ozchai.fnl
index 16a3265..937a35b 100644
--- a/parser/ozchai.fnl
+++ b/parser/ozchai.fnl
@@ -1,5 +1,6 @@
(import-macros {: map} :lib.macro)
+(local parser (require :parser.parser))
(local array (require :lib.array))
(local http (require :lib.http))
(local number (require :lib.number))
@@ -23,6 +24,11 @@
(local gallery (json.decode product.gallery))
(local weight (number.string->number (. product.editions 1 :Вес)))
(local price (number.string->number (. product.editions 1 :price)))
+ (var volume nil)
+ (each [_ c (ipairs product.characteristics)]
+ (when (= (. c :title) "Объем")
+ (set volume (parser.guess-volume c.value))))
+
{:site "ozchai"
:id product.url
:url product.url
@@ -33,6 +39,7 @@
(. gallery 1 :img)
"")
:weight weight
+ :volume volume
:price price
:price-per (if (and price weight (< 0 weight))
(/ (math.ceil (* (/ price weight) 10)) 10)