jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 243 forks source link

Weather app not working #132

Closed Jon889 closed 10 years ago

Jon889 commented 10 years ago

In settings I've set my location as "London". The weather app requests data from the following URL:
http://api.wunderground.com/api/#key#/geolookup/conditions/lang:EN/q/en/London.json
which just returns a list of Londons (several in the US, and the UK one somewhere near the end). I think the URL to actually get the weather should be:
http://api.wunderground.com/api/#key#/geolookup/conditions/lang:EN/q/UK/London.json

Note the last en becomes a UK, i.e. it's not a language parameter, but a country/state parameter.

The relevant code seems to be line 85 in jquery.mcjs.weather.js:

o.queryParameters = "lang:"+o.LANG+"/q/"+o.language+"/"+ o.location+".json";

should be something like:

o.queryParameters = "lang:"+o.LANG+"/q/"+country+"/"+ o.location+".json";

but I'm not sure where to get a country? Add an option in settings?

jansmolders86 commented 10 years ago

What a great use case! I'll have to think about that. I wonder if we can use the navigator string for this or as you suggest, simply add a country option. I feel the most for the latter.

Jon889 commented 10 years ago

I think a country option would be better than using the navigator string as the user would have more control and navigator strings can be changed/are a bit flimsy. I looked at the underground API documentation and the locations ambiguous and it returns a list of possible cities, each one will have an unique identifier which can be used. So perhaps just stick with the City in Settings and instead if it's ambiguous present the list to the user? Is there a precedent for saving data that's relevant only to one app?

jansmolders86 commented 10 years ago

I added the country option Jon! I like your option to let the user pick. I'll add it in Trello as a todo.

Does it work for you now?

Jon889 commented 10 years ago

It didn't quite work, because I didn't have a country option in my config already, it wasn't saving it. Also wunderground didn't like GB instead it liked UK for United Kingdom. I fixed these in commit 72e278

Also is the plan for all the apps to move to angular?

jansmolders86 commented 10 years ago

Great job Jonathan!

I'll close this issue but first I'll answer your question : Yes I would love to move entirely to Angular but simply haven't had the time to do so :)