From 1a777582c4644c34be94363e4809adea38993de9 Mon Sep 17 00:00:00 2001 From: Arnav Mishra Date: Wed, 18 Apr 2018 11:40:35 -0500 Subject: [PATCH] Allowing country + category searches for news. The newsapi allows news queries with both country and category parameters in the payload. However, it doesn't allow country and source or category and source mixed parameters. The update to the code reflects the corrected parameter options. --- newsapi/newsapi_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/newsapi/newsapi_client.py b/newsapi/newsapi_client.py index 9519a5c..763eeed 100644 --- a/newsapi/newsapi_client.py +++ b/newsapi/newsapi_client.py @@ -50,17 +50,17 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c else: raise TypeError('keyword/phrase q param should be a str') - # Sources + # Sources + if (sources is not None) and ((country is not None) or (category is not None)): + raise ValueError('cannot mix country/category param with sources param.') + + # Sources if sources is not None: if type(sources) == str: payload['sources'] = sources else: raise TypeError('sources param should be a str') - # Sources - if (country is not None) and (category is not None): - raise ValueError('cannot mix country/category param with sources param.') - # Language if language is not None: if type(language) == str: