Closed cyphar closed 1 year ago
This is the error you see when trying to look up 俄:
Exception occurred during processing of request from ('127.0.0.1', 38032)
Traceback (most recent call last):
File "socketserver", line 683, in process_request_thread
File "socketserver", line 360, in finish_request
File "http.server", line 653, in __init__
File "socketserver", line 747, in __init__
File "http.server", line 427, in handle
File "http.server", line 415, in handle_one_request
File "/home/cyphar/.local/share/Anki2/addons21/580654285/__init__.py", line 231, in do_GET
audio_sources = self.forvo.word(term)
File "/home/cyphar/.local/share/Anki2/addons21/580654285/__init__.py", line 117, in word
gender = re.search(r"\((Male|Female)",i.get_text(strip=True)).group(1).strip()
AttributeError: 'NoneType' object has no attribute 'group'
Tested and working, will deploy soon. Thank you!
Some words have recordings that do not have a designated gender (俄 for instance), which would previously cause the add-on to crash with an error (due to re.search returning None). Fix this by handling the case more gracefully.
Fixes: 40f5a9ab6f09 ("Update init.py") Signed-off-by: Aleksa Sarai cyphar@cyphar.com