Skip to content

Commit

Permalink
news api is down, replacing with alternate news api which requires sl…
Browse files Browse the repository at this point in the history
…ightly different parameters (#2873)
  • Loading branch information
vipulchhajer authored Nov 20, 2024
1 parent 970ec22 commit d100fcf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/indianews/india_news.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ load("schema.star", "schema")
load("secret.star", "secret")
load("time.star", "time")

#get dates to ping api
today = time.now()
todayf = today.format("2006-01-02")
yesterday = today - time.parse_duration("86400s")
yesterdayf = yesterday.format("2006-01-02")

#this is the API service for news
NEWS_URL = "http://newsapi.org/v2/top-headlines?sources=google-news-in&apiKey="
NEWS_URL = "http://newsapi.org/v2/everything?q=india&searchIn=description&sortBy=popularity&from={}&to={}&domains=indiatimes.com,livemint.com,thehindu.com,indianexpress.com&language=en&apiKey=".format(yesterdayf, todayf)

def main(config):
# set default api key
DEFAULT_API = secret.decrypt("AV6+xWcEX/4Xe45UOOKJO96fq/wjTvGwFn7rE8EUXwcONEWE7sG+eXYjEm5M+PmmS5GTV1NzbV3z3X5q7XWdN69xtfpB1KWMBedJf2kndTR6QWsBWZXizDHWDVMA5IUYO14Y7X2tlr+eKCuAZU7iri9BUTuBdO7+5sVRgPU3QoObSbsE9L8=")

#intialize headline randomizer
random.seed(time.now().unix // 60)
shift = random.number(0, 5)
shift = random.number(0, 95)

#Display error if no API found
if DEFAULT_API == None:
Expand Down

0 comments on commit d100fcf

Please sign in to comment.