more news countries

This commit is contained in:
Justin 2023-03-17 19:03:20 +08:00 committed by GitHub
parent 67e0d8b5bc
commit 31d9b47a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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']:
@ -548,8 +540,6 @@ def updateNews(api_key, logf):
#load user settings
headlines = data[:max_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]