Coder Social home page Coder Social logo

zemmsoares / polybar-news Goto Github PK

View Code? Open in Web Editor NEW
51.0 1.0 0.0 5.73 MB

๐Ÿ“ฐ News display module for Polybar & i3blocks

License: MIT License

Python 84.49% Shell 15.51%
polybar i3-blocks polybar-config polybar-scripts polybar-module hackernews hackernews-api newsaggregator

polybar-news's People

Contributors

zemmsoares avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

polybar-news's Issues

Strange Error

I installed everything, and believe I have it all set up. I'm assuming I was also required to chmod +x all of the scripts correct?

When I go to try the python script to check that it is pulling news I get the following:

Traceback (most recent call last):
  File "/home/myusername/.config/polybar/scripts/news/news.py", line 32, in <module>
    f = open(path, "w")
FileNotFoundError: [Errno 2] No such file or directory: '~/home/myusername/.config/polybar/scripts/news/current_news.txt'

There is a blank copy of current_news.txt in that listed folder.
screenshot-20221202-045747Z-selected

my news.py

#!/usr/bin/python
       
  import requests
  import os.path
       
  #path where news are saved in txt (default current directory)
  save_path ='~/home/myusername/.config/polybar/scripts/news'
       
  #get your api key at https://newsapi.org/
  api_key = "my api key"
       
  #find sources & country codes at https://newsapi.org/sources
  sources = "ign,bbc-news"
  country = ""
       
  # save_url saves URL so that it is possible to open the news in the browser
  # the url will always be the most recent, enable if number_news = 1
  save_url = False
  number_news = 3
       
  try: 
      data = requests.get('https://newsapi.org/v2/top-headlines?apiKey='+api_    key+'&sources='+sources+'&country='+country).json()
        
       news_string = ""
        
       for x in range(number_news):
         sourceName = data['articles'][x]['source']['name']
         title = data['articles'][x]['title']
         news_string += '['+sourceName+ '] '+ title + ' '
       
       path = os.path.join(save_path,"current_news.txt")
      f = open(path, "w")                                                    
       f.write(news_string)
       f.close()
        
       if save_url == True:
         url = data['articles'][0]['url']
         path = os.path.join(save_path,"current_url.txt")
         f = open(path, "w")
       f.write(url)
        f.close()
      
     
 except requests.exceptions.RequestException as e:

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.