diff --git a/database_caller.py b/database_caller.py index 26e938c..7a53641 100755 --- a/database_caller.py +++ b/database_caller.py @@ -516,24 +516,16 @@ def updateForex(api_key, logf): def updateNews(api_key, logf): - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?category=technology' - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country=GB' - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?lang=en' - - try: f = open('csv/news_settings.json', 'r') all_settings = json.load(f) f.close() - - - - + if all_settings['use_country']: if all_settings['country'] == 'Worldwide': url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news_worldwide?' else: - c_dict = {'United States':'US', 'Australia':'AU', 'Canada': 'CA', 'Great Britain':'GB', 'New Zealand':'NZ', 'Ireland':'IE', 'Singapore':'SG', 'South Africa': 'ZA'} + c_dict = {'United States':'US', 'Australia':'AU', 'Canada': 'CA', 'Great Britain':'GB', 'New Zealand':'NZ', 'Ireland':'IE', 'Singapore':'SG', 'South Africa': 'ZA', 'Germany': 'DE', 'Hong Kong': 'HK', 'Japan': 'JP', 'South Korea': 'KR', 'China': 'CN', 'France': 'FR', 'India': 'IN', 'Italy': 'IT', 'Switzerland': 'CH', 'Netherlands': 'NL', 'Spain': 'ES', 'Brazil': 'BR', 'Portugal': 'PT'} cc = c_dict[all_settings['country']] url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country={}'.format(cc) elif all_settings['use_category']: @@ -547,9 +539,7 @@ def updateNews(api_key, logf): max_headlines = int(all_settings['num_headlines']) #load user settings headlines = data[:max_headlines] - headline_sources = [headline['source'] for headline in headlines] - - + headline_sources = [headline['source'] for headline in headlines] headline_titles = [headline['title'] for headline in headlines] headline_times = [headline['publishedAt'] for headline in headlines]