Fall back to pearson dictionary if urbandictionary doesnt know a word, fixes #27
This commit is contained in:
parent
f414c3a0b3
commit
45d5c4db6f
@ -15,7 +15,13 @@ def get_definition(content):
|
||||
).json()['list'][0]['definition']
|
||||
|
||||
except IndexError:
|
||||
definition = 'No definition found'
|
||||
try:
|
||||
# Try another dictionary
|
||||
definition = requests.get(
|
||||
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format('%20'.join(word))
|
||||
).json()['results'][0]['senses'][0]['definition'][0]
|
||||
except IndexError:
|
||||
definition = 'No definition found'
|
||||
|
||||
return "`{}`\n```{}```".format(' '.join(word), definition)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user