update jisho.py according to suggestions

This commit is contained in:
Austin Huang 2022-04-01 09:18:19 -04:00
parent 934ae4e086
commit a399248f56
No known key found for this signature in database
GPG key ID: 84C23AA04587A91F

View file

@ -14,9 +14,11 @@ about = {
"use_official_api": True, "use_official_api": True,
"require_api_key": False, "require_api_key": False,
"results": 'JSON', "results": 'JSON',
"language": 'ja',
} }
categories = ['dictionaries'] categories = ['dictionaries']
engine_type = 'online_dictionary'
paging = False paging = False
URL = 'https://jisho.org' URL = 'https://jisho.org'
@ -35,12 +37,13 @@ def response(resp):
results = [] results = []
infoboxed = False infoboxed = False
search_results = json.loads(resp.text) search_results = resp.json()
pages = search_results.get('data', []) pages = search_results.get('data', [])
for page in pages: for page in pages:
# Entries that are purely from Wikipedia are excluded. # Entries that are purely from Wikipedia are excluded.
if page['senses'][0]['parts_of_speech'][0] != 'Wikipedia definition': if page['senses'][0]['parts_of_speech'] != [] and page['senses'][0]['parts_of_speech'][0] == 'Wikipedia definition':
pass
# Process alternative forms # Process alternative forms
japanese = page['japanese'] japanese = page['japanese']
alt_forms = [] alt_forms = []