Browse Source

amazon: support quantities

Fabian Peter Hammerle 8 years ago
parent
commit
92423a274b
1 changed files with 2 additions and 2 deletions
  1. 2 2
      order-confirmation-mail-parser

+ 2 - 2
order-confirmation-mail-parser

@@ -192,7 +192,7 @@ def parse_amazon(msg):
     articles_text = msg_text.split('Bestellte(r) Artikel:')[1].split('_' * 10)[0].strip()
     for article_text in re.split(ur'\n\t*\n', articles_text):
         article_match = re.match(
-            ur' *(?P<name>.*)\n'
+            ur' *((?P<quantity>\d+) x )?(?P<name>.*)\n'
                 + ur'( *von (?P<authors>.*)\n)?'
                 + ur' *(?P<price_brutto_currency>[A-Z]+) (?P<price_brutto>\d+,\d+)\n'
                 + ur'( *Zustand: (?P<state>.*)\n)?'
@@ -211,7 +211,7 @@ def parse_amazon(msg):
                 float(article['price_brutto'].replace(',', '.')),
                 article['price_brutto_currency']
                 ),
-            quantity = 1,
+            quantity = int(article['quantity']) if article['quantity'] else 1,
             authors = article['authors'].split(',') if article['authors'] else [],
             state = article['state'],
             reseller = article['reseller'],