import requests


def makeRadioURL(date):
    """Gets the URL for an episode from its date."""
    urlbase = "https://media.focusonthefamily.com/fotf/mp3/aio/"
    urltip = "aio_{0}.mp3".format(date)
    # Sometimes the URLS contain aio and sometimes aiow.  I don't see a pattern so I try both.
    if requests.get(urlbase + urltip, timeout=2, stream=True).status_code == 200:
        return urlbase + urltip
    else:
        return urlbase + urltip.replace("aio", "aiow")