def METHOD_NAME(sock, url):
    """
    Get filename from given `~urllib.request.urlopen` object and URL.
    First, tries the "Content-Disposition", if unavailable, extracts name from the URL.
    Parameters
    ----------
    sock : `~urllib.request.urlopen`
        The `~urllib.request.urlopen` to parse for the filename.
    url : `str`
        The URL to parse for the filename.
    Returns
    -------
    `str`:
        The filename.
    """
    name = None
    cd = sock.headers.get('Content-Disposition', None)
    if cd is not None:
        try:
            name = get_content_disposition(cd)
        except IndexError:
            pass
    if not name:
        parsed = urlparse(url)
        name = parsed.path.rstrip('/').rsplit('/', 1)[-1]
    return str(name)