Murzchnvok / polybar-collection

Beautiful collection of Polybar themes
815 stars 46 forks source link

change api to get location #23

Open nguyenhuy158 opened 1 month ago

nguyenhuy158 commented 1 month ago

I clone your repo and get error when get city from old api https://ipapi.co/json

error:

python3 $HOME/polybar-collection/scripts/weather/main.py -u metric -a 61527dc595b1f41998133d77d4d7b106
Traceback (most recent call last):
  File "/home/huy/polybar-collection/scripts/weather/main.py", line 120, in <module>
    main()
  File "/home/huy/polybar-collection/scripts/weather/main.py", line 106, in main
    city = args.city[0] if args.city else get_city()
                                          ^^^^^^^^^^
  File "/home/huy/polybar-collection/scripts/weather/main.py", line 17, in get_city
    return r.json()["city"]
           ~~~~~~~~^^^^^^^^
KeyError: 'city'

I recomment you change to http://ip-api.com/json it also free too.

Murzchnvok commented 1 month ago

Hmm, the API is working here, so not sure what the problem is. I probably forgot to add an exception from when you have connection problems or something. But it would be pretty easy to change the API just in case it's not working yet for you. Anyway thanks for reporting.