import logging


def parse_links(links):
    """Parse an entry's links to find the audio file.

    Returns
    -------
    Optional[str]
        The url of the audio file
    Optional[int]
        The size of the audio file
    Optional[str]
        The mimetype of the audio file
    """
    logger = logging.getLogger(__name__)

    for link in links:
        # Check that the link is an enclosure
        if "rel" not in link or link.rel != "enclosure":
            continue

        # Check that the link is valid
        if "href" not in link:
            logger.warning("Skipping enclosure with no href attribute.")
            continue

        return link.href, link.get("length", None), link.type

    logger.warning("No enclosure found.")
    return None, None, None