urban: fix multi-word terms
This commit is contained in:
parent
9a3fce367a
commit
b8c3fe073b
|
@ -17,7 +17,7 @@ class Urban(Plugin):
|
||||||
%%ud <term>...
|
%%ud <term>...
|
||||||
"""
|
"""
|
||||||
# Clean, strip and split term by whitespace
|
# Clean, strip and split term by whitespace
|
||||||
term = ' '.join(args.get('<term>')).lower().strip().split()
|
term = ' '.join(args.get('<term>')).lower().strip()
|
||||||
|
|
||||||
if term[-1].isdigit():
|
if term[-1].isdigit():
|
||||||
# Parse number at end as index - 1 and slice term
|
# Parse number at end as index - 1 and slice term
|
||||||
|
@ -30,6 +30,9 @@ class Urban(Plugin):
|
||||||
# Fetch data for term from urban dictionary as json
|
# Fetch data for term from urban dictionary as json
|
||||||
data = requests.get(self.URL, params=dict(term=term)).json()
|
data = requests.get(self.URL, params=dict(term=term)).json()
|
||||||
|
|
||||||
|
if data.get("list") is None:
|
||||||
|
return "API Error"
|
||||||
|
|
||||||
res_length = len(data['list'])
|
res_length = len(data['list'])
|
||||||
|
|
||||||
# No results
|
# No results
|
||||||
|
|
Loading…
Reference in New Issue
Block a user