Yahoo Pipes, Now with Pseudo Branching!

See Also:

· PipeJAX my little widget to easily embed your pipes into your web page with customizable formatting.
· Using regexes for another type of pseudo branching

Ok, so I got an email today saying that Yahoo had built a new Split module (that let’s you basically clone a feed at any point in your pipe) and perhaps that and judicious use of filter could approximate the branching I had suggested they implement. So, I figured I’d give it a try with my ol’ testbed the technorati search – my goal was to have that pipe take an input that would let you configure whether or not you wanted the domain to appear appended to the end of the title. I already have the domain appending code, so I just needed the if statement.

So, with glee and excitement I cloned my technorati search and added in a split and started messing around. My initial plan was to use split, then a regex down one side and then union them back together and filter the ones I didn’t want out. I couldn’t quite wrap my brain around how exactly to get the filtering to work, but as I was thinking about it I realized that all I needed was my good ol’ regex. God, I love perl compatible regex’s, is there anything they can’t do? I’m almost done with the cooking me breakfast regex, as a matter of fact.

Anyhow, the fix is actually pretty simple – I take the new user text input (show_domain) and decide that if you want to show the domain on the title you must pass in the string “yes”. If you pass in nothing or any other string the domain will not be appended to the title.

So, then, I take whatever you pass in and create a new string (with concatenate) that is “-==[the value of what you passed in]“. Then in my regex the first thing I do is append to the end of title the value of that string concatenation. Now comes the good part, the second part of the regex replaces the “-==yes” found at the end of title with ‘-=={link}”.

That is, effectively, my branching statement. If you passed in yes to the show_domain parameter, then at the end of title will be found ‘-==yes’ and the second regex will match and do the substitution with the link. If you passed in anything other than yes (including nothing) the second regex will not match, no substitution will take place and the domain will thus not appear.

Finally, the third regex removes all the non-domainy parts from the link (if it was added in the second step) and the fourth and last step simply removes any remaining “-==” from the string (which would be the case if you didn’t pass in show_domain).

So, I think given that pipes really at this point can only handle rss entities, branching can be made to work this way using regexes. Split is probably more suited for pulling in multiple feeds, so that if you had a feed coming in, you could pass it through content-analysis and then search technorati and yahoo search (as an example) for related results and combine them all.

See Also:

· PipeJAX my little widget to easily embed your pipes into your web page with customizable formatting.
· Using regexes for another type of pseudo branching
· Some basic thoughts on the Regex module
· My technorati pipe that uses this
· my similar postings pipe that incorporates the new technorati search.

  • cool007


  • Earth2marsh, definitely. Split offers some pretty interesting options as well. I like your pipe, very cool work. I had started playing around with that type of thing to try and create an if/then type of module - but lost patience along the way. :)

  • Earth2marsh

    split --> filter (both branches) --> case specific transform (e.g. regex) --> union can make branching work too. here's an example pipe where the scraped page sometimes has a mail-in rebate, sometimes not, which affects the final price.

    Nice trick of yours though!

  • Can i use it to translate a hole site ?

blog comments powered by Disqus

Not Found

Sorry, but what you are looking for isn't here...