(hass, url)
return result
Download files, and return the content.
Download files, and return the content.
Download files and return the content .
async def async_download_file(hass, url):
    """
    Download files, and return the content.
    """
    logger = Logger("hacs.download.downloader")
    if url is None:
        return

    # There is a bug somewhere... TODO: Find that bug....
    if "tags/" in url:
        url = url.replace("tags/", "")

    logger.debug(f"Donwloading {url}")

    result = None

    with async_timeout.timeout(5, loop=hass.loop):
        request = await async_get_clientsession(hass).get(url)

        # Make sure that we got a valid result
        if request.status == 200:
            result = await request.read()
        else:
            raise HacsNotSoBasicException(
                "Got status code {} when trying to download {}".format(
                    request.status, url
                )
            )

    return result
async def async_download_file ( hass , url ) : logger = Logger ( "hacs.download.downloader" ) if url is None : return # There is a bug somewhere... TODO: Find that bug.... if "tags/" in url : url = url . replace ( "tags/" , "" ) logger . debug ( f"Donwloading {url}" ) result = None with async_timeout . timeout ( 5 , loop = hass . loop ) : request = await async_get_clientsession ( hass ) . get ( url ) # Make sure that we got a valid result if request . status == 200 : result = await request . read ( ) else : raise HacsNotSoBasicException ( "Got status code {} when trying to download {}" . format ( request . status , url ) ) return result