def retrieve_urls()

in source/lambda/capture_news_feed/util/config_helper.py [0:0]


def retrieve_urls(country=None, language=None, topic=None):
    """
    This function calls the newscatcher api and returns the urls to be invoked.
    """
    try:
        if country:
            country = None if country == "ALL" else validate_2_char_iso_code(country)

        if language:
            language = None if language == "ALL" else validate_2_char_iso_code(language)

        if topic:
            topic = None if topic == "ALL" else validate_topic(topic)

        logger.info(f"Parameters to retrieve list are - country:{country}, language:{language}, topic:{topic}")
        url_list = newscatcher.urls(country=country, language=language, topic=topic)
        logger.debug(f"retrieved url list: {url_list}")
        return url_list

    except TypeError:
        logger.error("Fetching urls threw an Error")
        raise