#!/usr/bin/env python3

# http://inamidst.com/saxo/
# Created by Sean B. Palmer

import json
import saxo

@saxo.pipe
def ud(arg):
    url = "http://api.urbandictionary.com/v0/define"
    page = saxo.request(url, query={"term": arg})
    data = json.loads(page["text"])
    defs = data["list"]
    if not defs:
        return "Sorry, no definitions found"
    return defs[0]["definition"].replace("\r\n", " ")
