Skip to content

Commit 1a77758

Browse files
committed
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.
1 parent 678e8bd commit 1a77758

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

newsapi/newsapi_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
5050
else:
5151
raise TypeError('keyword/phrase q param should be a str')
5252

53-
# Sources
53+
# Sources
54+
if (sources is not None) and ((country is not None) or (category is not None)):
55+
raise ValueError('cannot mix country/category param with sources param.')
56+
57+
# Sources
5458
if sources is not None:
5559
if type(sources) == str:
5660
payload['sources'] = sources
5761
else:
5862
raise TypeError('sources param should be a str')
5963

60-
# Sources
61-
if (country is not None) and (category is not None):
62-
raise ValueError('cannot mix country/category param with sources param.')
63-
6464
# Language
6565
if language is not None:
6666
if type(language) == str:

0 commit comments

Comments
 (0)