Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location for weather #1

Open
ymkim92 opened this issue Aug 5, 2014 · 5 comments
Open

Location for weather #1

ymkim92 opened this issue Aug 5, 2014 · 5 comments

Comments

@ymkim92
Copy link

ymkim92 commented Aug 5, 2014

Hi zenzire,

You may know the w for weather location from:
http://weather.yahooapis.com/forecastrss?**w=493776**&u=c

It will be great if you add some note on README.md for how to change a location from this site https://weather.yahoo.com/

Regards,
Young

@ghost
Copy link

ghost commented Oct 26, 2014

Yeah, would be great to add autolocation finding too.

I just cobbled this together, its silly how hard in linux it is to find a location now.

This uses your ip to find your WOEID.

Just place this in a file like whereami, chmod u+x whereami

And then you should be good to go. I will now try to add this to your conky script.

###

#!/bin/bash

# use your ip to find your location, and then post out a WOEId
# THANKS TO YAHOO

MY_IP=$(curl -s ifconfig.co)
MY_LOC=$(curl -s ipinfo.io/$MY_IP/loc)
ARR_LOC=(${MY_LOC/,/ })

# LAT  echo ${ARR_LOC[0]}
# LONG echo ${ARR_LOC[1]}

WOEID="`curl --silent http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22${ARR_LOC[0]}%2C${ARR_LOC[1]}%22%20and%20gflags%3D%22R%22 | grep '<woeid>' | sed -e 's|^.*<woeid>\(.*\)</woeid>.*$|\1|'`"
echo $WOEID

Next

create something like;

getweatherrss
chmod u+x getweatherrss

In the conkyrc script, replace the line:

${execi 300 ~/bin/getweatherrss > ~/.cache/weather.xml}

with:

${execi 300 ~/bin/getweather" -o ~/.cache/weather.xml}

@ghost
Copy link

ghost commented Oct 26, 2014

Ok, figured it out. That should get pretty close to your location, and all depends upon you having a web connection which the weather requires anyway...and, no need for an API key.

@ghost
Copy link

ghost commented Oct 26, 2014

Do you want a patch to this? I found another bug in your greps too...

@mrmierzejewski
Copy link
Owner

@rejon, thank you for your suggestions.
Please propose your fix and I will merge it with my code.

@jvault
Copy link

jvault commented Dec 26, 2015

# Soucers #
# Start get a location
${execi 3600 curl -s "https://weather.yahoo.com/_xhr/get-current-location/" -o ~/.cache/weather/auto-location}
\
# end get location
# Start get a weather
${execi 900 curl -s "http://weather.yahooapis.com/forecastrss?w=$(grep -o -E "\"woeid\":[0-9]{6,8}," ~/.cache/weather/auto-location | grep -o -E "[0-9]{6,8}")&u=c" -o ~/.cache/weather/weather.xml}
\
# end get weather
# Start set a weather 
# (Optional: known location watch https://settings.yahoo.com/locations)
#\
# ${execi 900 curl -s "http://weather.yahooapis.com/forecastrss?w=148899&u=c" -o ~/.cache/weather/weather.xml}
#\
# end set weather

I did like that, but not perfect woeid is no presice could be inexacta location.
I change files ~ / .cache / to ~ / .cache / weather /)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants