import re


def update_hidden(url, hidden=0):
    # type: (str, int) -> str
    """Updates or appends the 'hide' parameter for a URL"""
    pattern = r"hide=(\d+)"
    return re.sub(pattern, "hide={}".format(hidden), url) \
        if re.search(pattern, url) \
        else "{}&hide={}".format(url, hidden)