2

I am merging two feeds using Yahoo pipes and using the output feed on a website. However, as would like to identify the "feed source" for each item in the output feed. Is it possible to manipulate the original feeds so I can add another node/element to the feed items?

Thanks

Andy
  • 541
  • 2
  • 4
  • 14

1 Answers1

3

One way to do that is using the Regex operator. Let's say you want to add a new field called source. You could use Regex with parameters:

  • In: item.source
  • replace: .*
  • with: (the text you want)

See it in action here: http://pipes.yahoo.com/janos/7a3b9993cfc143d414fe7b637b1bd95a

That is, I have two feeds, I added a source attribute in the first with value "Question 1" and in the second with value "Question 2".

As an added bonus interesting undocumented Yahoo Pipes hack, I used one more Regex after the Union to make the source appear in the title.

However, this only adds the attribute to the node in the pipe debugger. You can use it for further processing, like I added it here to the title, it won't create a <source> tag in the output. That's because the RSS output of Yahoo Pipes removes all other fields that are not in the RSS standard. You can still see it in the JSON output though.

janos
  • 120,954
  • 29
  • 226
  • 236
  • In the example you given http://pipes.yahoo.com/janos/7a3b9993cfc143d414fe7b637b1bd95a,when I look at the http://pipes.yahoo.com/pipes/pipe.run?_id=7a3b9993cfc143d414fe7b637b1bd95a&_render=rss, I can't see a an element called sources like this in any of the items. I can only see it in the titles. – Andy Sep 27 '13 at 13:59
  • In the pipe output debugger you can see the `source` attribute. However, since this is a non-standard RSS field, if you use the RSS output of Yahoo Pipes, the field is removed, instead of converting to a `` tag. You can still see it in the JSON output though. – janos Sep 27 '13 at 14:16
  • Thanks, I am going to stick to RSS but will use the author as my source. How can I use REgEx to replace the content of the author field with my own text? – Andy Sep 27 '13 at 16:12
  • 2
    The same way as I did in `item.source`: replace `item.author` with `${source}` – janos Sep 28 '13 at 09:51