Skip to content

Commit

Permalink
allow ean and prefix parameters to be passed as string or integer
Browse files Browse the repository at this point in the history
  • Loading branch information
willamowius committed Mar 3, 2022
1 parent 065218b commit 01a0ea7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions eansearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, token):

def barcodeLookup(self, ean, lang=1):
"""Lookup the product name for an EAN barcode"""
contents = self._urlopen(self._apiurl + "&op=barcode-lookup&ean=" + ean + "&language=" + str(lang))
contents = self._urlopen(self._apiurl + "&op=barcode-lookup&ean=" + str(ean) + "&language=" + str(lang))
data = json.loads(contents)
if "error" in data[0]:
return None
Expand All @@ -26,7 +26,7 @@ def barcodeLookup(self, ean, lang=1):

def barcodeSearch(self, ean, lang=1):
"""Lookup the product info for an EAN barcode"""
contents = self._urlopen(self._apiurl + "&op=barcode-lookup&ean=" + ean + "&language=" + str(lang))
contents = self._urlopen(self._apiurl + "&op=barcode-lookup&ean=" + str(ean) + "&language=" + str(lang))
data = json.loads(contents)
if "error" in data[0]:
return None
Expand All @@ -35,7 +35,7 @@ def barcodeSearch(self, ean, lang=1):

def verifyChecksum(self, ean):
"""verify checksum of an EAN barcode"""
contents = self._urlopen(self._apiurl + "&op=verify-checksum&ean=" + ean)
contents = self._urlopen(self._apiurl + "&op=verify-checksum&ean=" + str(ean))
data = json.loads(contents)
if "error" in data[0]:
return None
Expand All @@ -56,7 +56,7 @@ def categorySearch(self, category, name='', page=0, lang=99):

def barcodePrefixSearch(self, prefix, page=0, lang=1):
"""search for a prefix of EAN barcodes"""
contents = self._urlopen(self._apiurl + "&op=barcode-prefix-search&prefix=" + prefix + "&page=" + str(page) + "&language=" + str(lang))
contents = self._urlopen(self._apiurl + "&op=barcode-prefix-search&prefix=" + str(prefix) + "&page=" + str(page) + "&language=" + str(lang))
data = json.loads(contents)
return data["productlist"]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
description='A Python class for EAN and ISBN name lookup and validation using the API on ean-search.org',
long_description=long_description,
long_description_content_type="text/markdown",
version='1.4.0',
version='1.5.0',
url='https://github.com/eansearch/python-ean-search',
author='Jan Willamowius',
author_email='[email protected]',
Expand Down

0 comments on commit 01a0ea7

Please sign in to comment.