def get_metadata(cfg, file_root):
    metadata = None
    cities = get_cities(cfg)
    url_field = cfg['url_field']
    urls = get_known_urls(file_root, cities)
    (metadata, urls) = read_metadata(file_root, cities, url_field)
    if cfg['refresh_metadata']:
        print('fetching metadata')
        (metadata, urls) = fetch_metadata(cfg, metadata, urls)
        print('writing metadata')
        write_metadata(metadata, cfg, file_root)
        print('writing url list')
        write_urls(urls, cfg)
    return metadata
def get_metadata(cfg, file_root):
    metadata = None
    cities = get_cities(cfg)
    url_field = cfg['url_field']
    urls = get_known_urls(file_root, cities)
    (metadata, urls) = read_metadata(file_root, cities, url_field)
    if cfg['refresh_metadata']:
        print('fetching metadata')
        (metadata, urls) = fetch_metadata(cfg, metadata, urls)
        print('writing metadata')
        write_metadata(metadata, cfg, file_root)
        print('writing url list')
        write_urls(urls, cfg)
    return metadata