|
random image pipe?
 |
Hello, I've been poking around yahoo pipes, and I can't find a module to grab a random value. Maybe this is really basic and I overlooked something? I'm trying to make a pipe that will grab 1 random image from my account, and make an rss feed from that. Each time the feed was called, a new image would result from it.
Any pointers would be greatly appreciated.
Posted at 3:49AM, 4 April 2008 PDT
(
permalink
)
|
 |
One solution is to use the web-services offered by random.org to get a random number in your desired range.
Another solution is to generate the current time by setting a “Date Builder” to “Today”, taking its “utime” field, and applying the math to that. I prefer this method. Have a look at this.
Posted 3 months ago.
(
permalink
)
|
 |
Hi, thanks so much for the link. I have implemented the beginnings of a pipe, but I'm lacking some basic knowledge. I have a module calling a feed, I have your tips on how to generate a random number, but I lack the glue to fit them together. Do I count the image feed, and extract the number for that? I am close, I can feel it, just missing some tools.
Posted 2 months ago.
(
permalink
)
|
 |
frogwasteland, let us see…
The objective is to choose 1 photo at random from your photostream.
Suppose we have the total number of photos available through a “Number input” module. Let us call it total. We can get the current UNIX time by creating a “Date Builder” set to “Today”. We connect it to a “String builder” just so that we can choose its “utime” field. Since the pipe will always be called at a different time, we could assume that from one pipe-run to another, this is a large random number, which I shall call time. If we use a “Math” module to perform time % total, then the resultant number is a random number between 0 and total - 1. If we add 1, we get a random number between 1 and total, which is what we want. Let us call this number n.
Once we have n, our task is to get the nth photo in our photostream. One way of doing this is by calling flickr.people.getPublicPhotos with per_page = 1 and page = n.
So now we have a pipe that takes the total number of photos in your photostream as input, and outputs a single item containing the info of a random photo from your photostream.
We create a new pipe that calls flickr.people.getPublicPhotos to get the “total” attribute off the “photos” element (using per_page=1 to economise on bandwidth, since we only need the total), and then pass that total to the pipe we built before, by embedding it inside a “Loop” module.
Some simple transformations to convert the XML to a nice RSS item, and we’re done :)
Make sure you make it take a generic NSID… and post it here for all to use ;)
Posted 2 months ago.
(
permalink
)
|
 |
Hi, thank you so much for your help so far. So I've created 2 pipes. One just fetches flickr.people.getPublicPhotos to get the total amount (the "number input module". )However, its output seems to be capped at 100 pictures. Is this the flickr max? The second module is working, and calling a different file each time, if I hardcode a number into the simple math field. I've run into some problems embedding the pipe in a loop. If the pipe that is inside the loop is expecting the total value, how exactly is that passed to the simple math number field? I've made a user input module called 'total' and tried to get the photos.photo count into the field, but the pipe will not let me drop the amount in there, which means there is something obvious that has escaped me again.
Originally posted 2 months ago.
(
permalink
)
frogwasteland edited this topic 2 months ago.
|
Would you like to comment?
Sign up for a free account, or sign in (if you're already a member).
|
|