please, work?
This commit is contained in:
parent
08b1e82f41
commit
c05b6b25c2
|
@ -23,7 +23,7 @@ def mcwiki(inp):
|
|||
if p.text_content():
|
||||
summary = " ".join(p.text_content().splitlines())
|
||||
summary = re.sub("\[\d+\]", "", summary)
|
||||
summary = text.truncate_str(summary, 250)
|
||||
return "%s :: \x02%s\x02" % (summary, url)
|
||||
summary = text.truncate_str(summary, 200)
|
||||
return "%s :: %s" % (summary, url)
|
||||
|
||||
return "Unknown Error."
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from util import hook, http, text
|
||||
from util import hook, http, text, web
|
||||
import re
|
||||
|
||||
base_url = 'http://www.urbandictionary.com/iphone/search/define'
|
||||
|
||||
|
@ -21,19 +22,26 @@ def urban(inp):
|
|||
else:
|
||||
id = 1
|
||||
|
||||
|
||||
# fetch the definitions
|
||||
page = http.get_json(base_url, term=input, referer="http://m.urbandictionary.com")
|
||||
defs = page['list']
|
||||
print page
|
||||
|
||||
if page['result_type'] == 'no_results':
|
||||
return 'Not found.'
|
||||
|
||||
# try getting the requested definition
|
||||
try:
|
||||
output = u"[%i/%i] %s: %s" % \
|
||||
(id, len(defs), defs[id - 1]['word'],
|
||||
defs[id - 1]['definition'].replace('\r\n', ' '))
|
||||
definition = defs[id - 1]['definition'].replace('\r\n', ' ')
|
||||
definition = re.sub('\s+', ' ', definition).strip() # remove excess spaces
|
||||
definition = text.truncate_str(definition, 200)
|
||||
except IndexError:
|
||||
return 'Not found.'
|
||||
|
||||
return text.truncate_str(output, 250)
|
||||
url = defs[id - 1]['permalink']
|
||||
|
||||
output = u"[%i/%i] %s :: %s" % \
|
||||
(id, len(defs), definition, url)
|
||||
|
||||
return output
|
||||
|
|
|
@ -44,6 +44,6 @@ def wiki(inp):
|
|||
|
||||
desc = re.sub('\s+', ' ', desc).strip() # remove excess spaces
|
||||
|
||||
desc = text.truncate_str(desc, 250)
|
||||
desc = text.truncate_str(desc, 200)
|
||||
|
||||
return '%s -- %s' % (desc, http.quote(url, ':/'))
|
||||
return '%s :: %s' % (desc, http.quote(url, ':/'))
|
||||
|
|
Reference in a new issue