Skip to content
Snippets Groups Projects
Verified Commit 27915cdc authored by Spotlight Deveaux's avatar Spotlight Deveaux :fox:
Browse files

testing push

parents
Branches master
No related tags found
No related merge requests found
DOCS.md 0 → 100644
select city, country, countryAbbr, state, stateAbbr, locationID, woeid from partner.weather.locations where query="H" and lang='en-GB'
select * from yql.query.multi where queries="
select city,
country,
locationID,
woeid,
state,
latitude,
longitude,
proximateStation.ID,
proximateStation.city,
currently.condition.code,
currently.timezone,
currently.moonphase,
currently.moonfacevisible,
currently.temp,
currently.time24,
currently.sunrise24,
currently.sunset24,
forecast.day.dayOfWeek,
forecast.day.poP,
forecast.day.temp.high,
forecast.day.temp.low,
forecast.day.condition.code,
location.extended_forecast_url
from partner.weather.forecasts where (woeid=2459115) and lang='en-GB' and unit='c';
select woeid,
hourlyforecast.hour.time24,
hourlyforecast.hour.condition.code,
hourlyforecast.hour.condition.poP,
hourlyforecast.hour.condition.temp
from partner.weather.forecasts.hourly where (woeid=2459115) and lang='en-GB' and unit='c'
""
\ No newline at end of file
go.mod 0 → 100644
module sin_enabler
go 1.13
require github.com/gin-gonic/gin v1.4.0
go.sum 0 → 100644
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
main.go 0 → 100644
package main
import (
"github.com/gin-gonic/gin"
"log"
"net/http"
"regexp"
"strings"
)
var WoeIDExtractor = regexp.MustCompile(`.*where \(woeid=(\d+)\).*`)
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "Hi!")
})
r.GET("/v1/yql", yqlHandler)
log.Fatal(r.Run("localhost:8888"))
// [truncated]GET /v1/yql?crossProduct=optimized&env=store%3A%2F%2Fy8kbem5LYN3AXbLbrDFnAp&q=select%20%2A%20from%20yql.query.multi%20where%20queries%3D%22select%20city%2Ccountry%2ClocationID%2Cwoeid%2Cstate%2Clatitude%2Clongitude%2Cproximate
}
func yqlHandler(c *gin.Context) {
woeID := WoeIDExtractor.FindString(c.Query("q"))
if woeID == "" {
c.Status(http.StatusForbidden)
}
log.Printf("looking for woeid %s", woeID)
if !strings.Contains(c.Query("q"), "hourly") {
c.XML(http.StatusOK, NewQueryResult(locations))
} else {
//c.XML(http.StatusOK, NewMetaQueryResult(weatherInfo, weatherMeta))
c.Header("Content-Type", "application/xml; charset=utf-8")
c.File("./support/test.xml")
}
}
//var locations = []Location{
// {
// Place: "Snotville",
// LocationID: "SNVL18374",
// City: "Snotville",
// Country: "United States",
// CountryAbbr: "US",
// State: "Fox",
// StateAbbr: "FX",
// WoeID: "2459114",
// },
// {
// Place: "Snotville",
// LocationID: "SNVL18374",
// City: "Snotville",
// Country: "United Kingdom",
// CountryAbbr: "UK",
// State: "Fox",
// StateAbbr: "FX",
// WoeID: "2459114",
// },
// {
// Place: "Snotville",
// LocationID: "SNVL18374",
// City: "Snotville",
// Country: "The Republic of Snoot",
// CountryAbbr: "RPST",
// State: "Fox",
// StateAbbr: "FX",
// WoeID: "2459114",
// },
//}
var locations = []Location{
{
Place: "H",
LocationID: "RSXX0063",
City: "Москва",
Country: "Россия",
CountryAbbr: "RU",
State: "Московская Область",
StateAbbr: "H",
WoeID: "2346910",
},
}
//var weatherInfo = FullData{
// HourData: []HourData{
// {
// Hour: 0,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 1,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 2,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 3,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 4,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 5,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 6,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 7,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 8,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 9,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 10,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 11,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 12,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 14,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 13,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 15,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 16,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 17,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 18,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 19,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 20,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 21,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 22,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 23,
// Temp: 2,
// Condition: Thunderstorms,
// }, {
// Hour: 24,
// Temp: 2,
// Condition: Thunderstorms,
// },
// },
// ForecastData: []ForecastData{
// {
// Day: 0,
// Condition: Thunderstorms,
// },
// {
// Day: 1,
// Condition: Thunderstorms,
// }, {
// Day: 2,
// Condition: Thunderstorms,
// }, {
// Day: 3,
// Condition: Thunderstorms,
// }, {
// Day: 4,
// Condition: Thunderstorms,
// }, {
// Day: 5,
// Condition: Thunderstorms,
// }, {
// Day: 6,
// Condition: Thunderstorms,
// },
// {
// Day: 7,
// Condition: Thunderstorms,
// },
// {
// Day: 8,
// Condition: Thunderstorms,
// },
// },
// Currently: 69,
//}
//
//var weatherMeta = MetaInfo{
// UnitData: WeatherInfo{
// Units: "C",
// },
// YahooWeatherURL: "http://l.yimg.com/a/i/us/we/52/26.gif",
// TWCWeatherURL: "http://l.yimg.com/a/i/us/we/52/26.gif",
//}
package main
import (
"encoding/xml"
)
type QueryResult struct {
XMLName xml.Name `xml:"query"`
Result Result
}
type QueryResultMeta struct {
XMLName xml.Name `xml:"query"`
Result Result
Meta Meta
}
type Result struct {
XMLName xml.Name `xml:"results"`
DataWrapper
}
type Meta struct {
XMLName xml.Name `xml:"meta"`
DataWrapper
}
type DataWrapper struct {
Data interface{}
}
type Location struct {
XMLName xml.Name `xml:"location"`
Place string `xml:"place,attr"`
LocationID string `xml:"locationID,attr"`
City string `xml:"city,attr"`
Country string `xml:"country,attr"`
CountryAbbr string `xml:"countryAbbr,attr"`
State string `xml:"state,attr"`
StateAbbr string `xml:"stateAbbr,attr"`
WoeID string `xml:"woeid,attr"`
}
type FullData struct {
XMLName xml.Name `xml:"location"`
// Location attributes
LocationID string `xml:"locationID,attr"`
WoeID string `xml:"hourlyforecast>woeid,attr"`
Latitude string `xml:"latitude,attr"`
Longitude string `xml:"longitude, attr"`
// Data enclosed
Conditions []Condition `xml:"hourlyforecast>hour>condition"`
//ForecastData []ForecastData `xml:"forecast"`
Currently int `xml:"currently"`
}
type Condition struct {
Time24 string `xml:"time24,attr"`
Temp string `xml:"temp,attr"`
ConditionCode int `xml:"code,attr"`
PercentageParticipation float32 `xml:"poP,attr"`
}
type MetaInfo struct {
UnitData UnitInfo `xml:"weather"`
YahooWeatherURL string `xml:"yahoo_mobile_url"`
TWCWeatherURL string `xml:"twc_mobile_url"`
}
type UnitInfo struct {
XMLName xml.Name `xml:"units"`
DistanceUnits string `xml:"distanceUnits,attr"`
TemperatureUnits string `xml:"tempUnits,attr"`
}
func NewQueryResult(info interface{}) QueryResult {
r := QueryResult{
Result: Result{DataWrapper: DataWrapper{Data: info}},
}
return r
}
func NewMetaQueryResult(info interface{}, meta interface{}) QueryResultMeta {
r := QueryResultMeta{
Result: Result{DataWrapper: DataWrapper{Data: info}},
Meta: Meta{DataWrapper: DataWrapper{Data: meta}},
}
return r
}
# support
No packages here, just useful scripts.
`redirect_weather.py` intercepts the default YQL domain, the since-defunct `apple-mobile.query.yahooapis.com` to localhost:8888. Modify as needed to fit your desires! You may want to do this for rapid prototyping, or to avoid hooking your device to be internal to have the preferences key respected
"""
Redirects apple-mobile.query.yahooapis.com to the configured port.
"""
from mitmproxy import http
LOCAL_PORT = 8888
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_host == "apple-mobile.query.yahooapis.com":
flow.request.host = "localhost"
flow.request.port = LOCAL_PORT
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="2" yahoo:created="2015-10-01T12:38:19Z" yahoo:lang="ru">
<meta>
<meta>
<weather>
<yahoo_mobile_url>http://m.yahoo.com/?.tsrc=appleww&amp;.lang=ru</yahoo_mobile_url>
<twc_mobile_url>http://itunes.apple.com/us/app/the-weather-channel/id295646461?mt=8&amp;uo=4</twc_mobile_url>
<units distanceUnits="km" pressureUnits="mb" speedUnits="km/h" tempUnits="C" />
</weather>
</meta>
<meta>
<weather>
<yahoo_mobile_url>http://m.yahoo.com/?.tsrc=appleww&amp;.lang=ru</yahoo_mobile_url>
<twc_mobile_url>http://itunes.apple.com/us/app/the-weather-channel/id295646461?mt=8&amp;uo=4</twc_mobile_url>
<units tempUnits="C" />
</weather>
</meta>
</meta>
<results>
<results>
<location city="Москва" country="Россия" latitude="55.45" locationID="RSXX0063" longitude="37.36" state="Московская Область" woeid="2346910">
<proximateStation ID="RSXX0063" city="Moscow" />
<!-- <currently barometer="1014.3" barometricTrend="falling" dewpoint="14" feelsLike="21" heatIndex="21" moonfacevisible="27.6%" moonphase="1" obsStnId="KOAK" percentHumidity="63" sunrise="6:10 am" sunrise24="06:10" sunset="8:17 pm" sunset24="20:17" temp="21" time24="13:53" timezone="GMT-7" tz="PDT" visibility="16.09" windChill="21" windDirection="WNW" windDirectionDegree="290" windSpeed="22.53">-->
<currently moonfacevisible="85.7%" moonphase="5" sunrise24="05:38" sunset24="17:15" temp="14" time24="14:59" timezone="GMT-7" windChill="21" windSpeed="22.53" heatIndex="21" barometer="1014.3" barometricTrend="falling" dewpoint="14" feelsLike="21" obsStnId="KOAK" percentHumidity="63" sunrise="6:10 am" sunset="8:17 pm" tz="PDT" visibility="16.09" windDirection="WNW" windDirectionDegree="290">
<condition code="34" />
</currently>
<forecast>
<day dayOfWeek="1" poP="0">
<temp high="17" low="6" />
<condition code="32" />
</day>
<day dayOfWeek="2" poP="70">
<temp high="12" low="9" />
<condition code="11" />
</day>
<day dayOfWeek="3" poP="10">
<temp high="16" low="6" />
<condition code="24" />
</day>
<day dayOfWeek="4" poP="0">
<temp high="12" low="2" />
<condition code="30" />
</day>
<day dayOfWeek="5" poP="0">
<temp high="15" low="7" />
<condition code="34" />
</day>
<day dayOfWeek="6" poP="40">
<temp high="14" low="3" />
<condition code="39" />
</day>
<extended_forecast_url>http://m.yahoo.com/search?p=Москва,+Московская+Область&amp;.tsrc=appleww&amp;.lang=ru</extended_forecast_url>
</forecast>
<!-- </location>-->
<!-- </results>-->
<!-- <results>-->
<!-- <location woeid="2346910">-->
<hourlyforecast>
<hour time24="03:00">
<condition code="32" poP="0" temp="12" />
</hour>
<hour time24="04:00">
<condition code="32" poP="0" temp="11" />
</hour>
<hour time24="05:00">
<condition code="31" poP="0" temp="9" />
</hour>
<hour time24="06:00">
<condition code="31" poP="0" temp="9" />
</hour>
<hour time24="07:00">
<condition code="31" poP="0" temp="9" />
</hour>
<hour time24="08:00">
<condition code="31" poP="0" temp="8" />
</hour>
<hour time24="09:00">
<condition code="31" poP="0" temp="8" />
</hour>
<hour time24="10:00">
<condition code="31" poP="0" temp="8" />
</hour>
<hour time24="11:00">
<condition code="31" poP="0" temp="8" />
</hour>
<hour time24="12:00">
<condition code="31" poP="0" temp="8" />
</hour>
<hour time24="13:00">
<condition code="33" poP="0" temp="7" />
</hour>
<hour time24="14:00">
<condition code="29" poP="0" temp="7" />
</hour>
</hourlyforecast>
</location>
</results>
</results>
</query>
<!-- total: 5 -->
<!-- engine1151.yql.bf1.yahoo.com -->
\ No newline at end of file
package main
const (
Tornado = iota
TropicalStorm
Hurricane
SevereThunderstorms
Thunderstorms
MixedRainAndSnow
MixedRainAndSleet
MixedSnowAndSleet
FreezingDrizzle
Drizzle
FreezingRain
Showers
Rain
SnowFlurries
LightSnowShowers
BlowingSnow
Snow
Hail
Sleet
Dust
Foggy
Haze
Smoky
Blustery
Windy
Cold
Cloudy
MostlyCloudyNight
MostlyCloudyDay
PartlyCloudyNight
PartlyCloudyDay
ClearNight
Sunny
FairNight
FairDay
MixedRainAndHail
Hot
IsolatedThunderstorms
ScatteredThunderstorms
ScatteredShowersDay
HeavyRain
ScatteredSnowShowersDay
HeavySnow
Blizzard
NotAvailable
ScatteredShowersNight
ScatteredSnowShowersNight
ScatteredThundershowers
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment