Fall back to pearson dictionary if urbandictionary doesnt know a word, fixes #27
This commit is contained in:
parent
f414c3a0b3
commit
45d5c4db6f
@ -14,6 +14,12 @@ def get_definition(content):
|
|||||||
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
||||||
).json()['list'][0]['definition']
|
).json()['list'][0]['definition']
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
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:
|
except IndexError:
|
||||||
definition = 'No definition found'
|
definition = 'No definition found'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user