It is currently July 20th, 2019, 8:53 pm

Example using YQL "universal" feed reader

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Example using YQL "universal" feed reader

jsmorley » December 7th, 2013, 7:37 pm

moshi wrote:i think the Greek feed has a similar issue. if you don't select top-level fields, it works just fine.

the Hebrew feed might be something completely different, maybe related to the right-to-left writing.
Well, while "universal" is probably an unachievable goal, this comes pretty darn close...
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Example using YQL "universal" feed reader

jsmorley » December 7th, 2013, 8:14 pm

Added a custom context menu on the skin in the first post to choose one of 12 example feeds. Simply right click the header and choose one to change to that feed.

Edit Feeds.inc to change to ones you like.
2.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: Example using YQL "universal" feed reader

moshi » December 8th, 2013, 9:22 am

as a next step, how about instead of:

Code: Select all

where url="#FeedURL#"
use

Code: Select all

where url in ("#FeedURL#")
so one can aggregate multiple feeds as in:

Code: Select all

where url in ("http://foo.com/","http://bar.com/")
the result formatting for a

Code: Select all

select title,entry.title, ...
kinda asks for it
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Example using YQL "universal" feed reader

jsmorley » December 8th, 2013, 1:29 pm

moshi wrote:as a next step, how about instead of:

Code: Select all

where url="#FeedURL#"
use

Code: Select all

where url in ("#FeedURL#")
so one can aggregate multiple feeds as in:

Code: Select all

where url in ("http://foo.com/","http://bar.com/")
the result formatting for a

Code: Select all

select title,entry.title, ...
kinda asks for it
I thought about that, but I always resist trying to do application development in Rainmeter code. It's not the right tool for that. Aggregating a bunch of feeds into one just to display 5 items is pointless, and I am not interested in replacing Feedly with a Rainmeter skin that has 1/10th of the capabilities. I like a little "breaking news" type skin on my second monitor so I can see at a glance that something really important has just happened, but other than that I'd just as soon go to a web site to browse through hundreds of items and do searches, and all that. That's just me of course.

Still, there are some other things, even in the context of a little "bird's eye view of a feed" skin that you want to keep on the desktop, that the YQL things brings to the table. I need to play with things like "where" on the field values, to see if I can have an InputText and search one or more feeds for the five newest items "about" some topic. That might be fun.

On another note, after looking at the Google News feed, I see why they removed sorting by time from the xml capabilities. The way Google aggregates news from tons of sources all over the world really means that items "grouped" together by "topic" and sorted by "relevance" in a tool that can support that (like their web page in a browser) is the only thing that makes sense.

No matter how you sort the xml using YQL, the raw feed from Google is just annoying. Things just jump on and off of it as new "sources" are added to an existing topic that is "relevant", but not necessarily "new". Every update from the site is just an annoying mess when sorted by time, and not terribly useful when sorted by relevance with no grouping. It is the grouping into topics, and then displaying the topics by relevance (in which time is a factor, but not at the individual item level) that makes http://news.google.com useful.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: Example using YQL "universal" feed reader

moshi » December 8th, 2013, 1:56 pm

in my opinion that's the wrong approach. as most feeds rarely have more than 10 items and you probably don't want to cache older items, you would need to use a large amount of feeds to get any results for a search most of the time.

i do use InputText to search for news in my Evi skin, but what i do here is using apis that support a query parameter. i use Google, Bing, Yahoo! and the Huffington Post. the first three even support localization.

aggregating them with YQL could indeed be fun, but i kinda fear the duplicates, as doing some semantic filtering is impossible with the tools we have. but at least one could try to get the links (they often contain reference stuff, so for example the New York Times knows that this visitor came from Google News) "normalized" (not with YQL, but RegExpSubstitute) and use Lua to filter the YQL results.
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Example using YQL "universal" feed reader

jsmorley » December 8th, 2013, 2:00 pm

moshi wrote:in my opinion that's the wrong approach. as most feeds rarely have more than 10 items and you probably don't want to cache older items, you would need to use a large amount of feeds to get any results for a search most of the time.

i do use InputText to search for news in my Evi skin, but what i do here is using apis that support a query parameter. i use Google, Bing, Yahoo! and the Huffington Post. the first three even support localization.

aggregating them with YQL could indeed be fun, but i kinda fear the duplicates, as doing some semantic filtering is impossible with the tools we have. but at least one could try to get the links (they often contain reference stuff, so for example the New York Times knows that this visitor came from Google News) "normalized" (not with YQL, but RegExpSubstitute) and use Lua to filter the YQL results.
That's true. I'll have to look at using some Lua to add to the capabilities.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: Example using YQL "universal" feed reader

moshi » December 8th, 2013, 3:39 pm

not sure if you have looked into the community tables yet, but you might find this interesting.

Code: Select all

select titleNoFormatting,unescapedUrl,publisher,publishedDate,image.url from google.news where q = "Mandela"
the native Google News api is of course far more powerful, but the select makes parsing results a lot easier as it strips the related results (in this example)


edit:

Code: Select all

URL="http://query.yahooapis.com/v1/public/yql?q=select titleNoFormatting,unescapedUrl,publisher,publishedDate,image.url from google.news where q = "Mandela"&env=store://datatables.org/alltableswithkeys"
i guess i just figured out what the &env=store://datatables.org/alltableswithkeys is for, this parameter is needed for the community tables.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: Example using YQL "universal" feed reader

moshi » December 9th, 2013, 1:00 am

this is a little off-topic, but it shows a few methods on how to build mashups with YQL:

Code: Select all

URL="http://query.yahooapis.com/v1/public/yql?q=select subscribed from metar.table(0,3) where icao in (select icao from pidgets.airports where near="47.4034996032715,10.2870998382568")&env=store://datatables.org/alltableswithkeys"
what this does:

first it searches airports near a lat/lon pair:
from pidgets.airports where near="47.4034996032715,10.2870998382568"

from the results it picks only the ICAO (airport code) fields:
select icao

then it searches for METAR weather reports for the results of the first search:
from metar.table where icao in ( ... )

we only need three results in the skin, so let's pick the first three:
from metar.table(0,3)
0 is the offset, 3 is the amount, this is cool for dynamic webparser variables

from the results it picks only the natural language report fields:
select subscribed
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Example using YQL "universal" feed reader

jsmorley » December 9th, 2013, 1:24 am

How does one know what public tables are available in the datatables.org store and what they are for and what their structure is? I suspect you didn't just guess at that metar stuff.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: Example using YQL "universal" feed reader

moshi » December 9th, 2013, 1:59 am

you go the YQL Console: http://developer.yahoo.com/yql/console/
in the top left tick the "Show Community Tables" checkbox and the you can browse through them.

many don't work any longer or require an api key, but there are still a few gems to be found.