Skip to content
This repository has been archived by the owner on Aug 11, 2018. It is now read-only.

Reflect changes to the Yahoo API format #143

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions applet.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ const Util = imports.misc.util
const UUID = "weather@mockturtl"
const APPLET_ICON = "view-refresh-symbolic"
const CMD_SETTINGS = "cinnamon-settings applets " + UUID
const WOEID_URL = "http://edg3.co.uk/snippets/weather-location-codes/"
const WOEID_URL = "http://woeid.rosselliot.co.nz"
const CMD_WOEID_LOOKUP = "xdg-open " + WOEID_URL

// Conversion Factors
@@ -59,7 +59,7 @@ const EN_DASH = '\u2013'

// Query
const QUERY_PARAMS = '?format=json&q=select '
const QUERY_TABLE = 'feednormalizer where url="http://xml.weather.yahoo.com/forecastrss/'
const QUERY_TABLE = 'weather.forecast'
const QUERY_VIEW = '*'
const QUERY_URL = 'http://query.yahooapis.com/v1/public/yql' + QUERY_PARAMS + QUERY_VIEW + ' from ' + QUERY_TABLE

@@ -386,7 +386,7 @@ MyApplet.prototype = {
//this.dumpKeys()
this.loadJsonAsync(this.weatherUrl(), function(json) {
try {
let weather = json.get_object_member('query').get_object_member('results').get_object_member('rss').get_object_member('channel')
let weather = json.get_object_member('query').get_object_member('results').get_object_member('channel')
let weather_c = weather.get_object_member('item').get_object_member('condition')
let forecast = weather.get_object_member('item').get_array_member('forecast').get_elements()

@@ -470,6 +470,12 @@ MyApplet.prototype = {
break
}
this._currentWeatherWind.text = (wind_direction ? wind_direction + ' ' : '') + wind + ' ' + _(this._windSpeedUnit)

// Override wind chill units with our preference
// Yahoo API always returns Fahrenheit
if (this._temperatureUnit == WeatherUnits.CELSIUS) {
wind_chill = Math.round((wind_chill - 32) / 1.8)
}
this._currentWeatherWindChill.text = wind_chill + ' ' + this.unitToUnicode()

// Override pressure units with our preference
@@ -798,8 +804,8 @@ MyApplet.prototype = {
}

, weatherUrl: function weatherUrl() {
//let output = QUERY_URL + ' where location="' + this._woeid + '" and u="' + this.unitToUrl() + '"'
let output = QUERY_URL + this._woeid + '_' + this.unitToUrl() + '.xml"'
let output = QUERY_URL + ' where woeid="' + this._woeid + '" and u="' + this.unitToUrl() + '"'
//let output = QUERY_URL + this._woeid + '_' + this.unitToUrl() + '.xml"'
return output
}

2 changes: 1 addition & 1 deletion settings-schema.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
{ "type": "button"
, "description": "Get WOEID"
, "callback": "woeidLookup"
, "tooltip": "http://edg3.co.uk/snippets/weather-location-codes/"
, "tooltip": "http://woeid.rosselliot.co.nz/"
}
, "woeid":
{ "type": "entry"