Question

Hello I'm building a Yahoo Pipe to feed my Facebook Fanpage. I have plenty of RSS Feeds which stream pictures and I want to limit the output to one picture per hour. But I'm completely new to pipes and can't find an understandable tutorial. Pipe looks like that

RSS1   RSS2 ... RSSn
  |      |       |
  +-----UNION----+
         |
     PIPE OUTPUT
Was it helpful?

Solution

You can do that using this algorithm:

  1. Create a new field that contains the date truncated to hours
  2. Use the Unique operator on this new field to get only one item per hour

You could implement this using pipes like this:

  1. Copy pubDate to, say, datepart, using a Rename operator, with params:

    • item.pubDate
    • Copy As
    • datepart
  2. Truncate datepart, using a Regex operator, with params:

    • In = item.datepart
    • replace = ^(.{13}).*
    • with = $1

    That is, since date fields are represented as YYYY-mm-DDTHH:MM:ssZ we take the first 13 characters to get the date part up until the hour and discard the rest. For example if pubDate was 2013-11-03T13:34:37 then we get 2013-11-03T13.

  3. Use a Unique operator based on item.datepart to filter items

As a simple demo, I put together a pipe for you that shows 1 question per month tagged yahoo-pipes on stackoverflow:

http://pipes.yahoo.com/pipes/pipe.info?_id=72fea3931e145324f308f0d5f6852d93

Note that you will get different results depending on where you put these elements. For example, you could put this logic after your union, to get one image per hour from all your source feeds combined. Or you could put this logic before your union, to get one image per hour per feed.

You might also ask, in case of multiple images per hour, which one will be picked? The first one. I think the default ordering is by pubDate. To make Yahoo Pipes pick a different item, insert an appropriate Sort operator before Unique.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top