📜 ⬆️ ⬇️

An example of creating a pipe in Yahoo! Pipes.

I was asked to talk about how Yahoo! Pipes, and here I disassembled one of the examples from the translation of an article about this wonderful service.


So, this is what we see when we start creating a new pipe:


')
On the left is the toolbar, below is the debugger, in which you can watch the intermediate values ​​at the outputs of each plate.
Now we will create a pipe that will take the last listened tracks from last.fm and show the corresponding pictures.

1. First, you need to get the username on last.fm. To do this, drag the Text Input panel onto the workspace and fill its fields. The panel itself is located in the User Inputs section of the left plate.
Name field - the name of the panel;
Prompt - the request that will be written when viewing the pipe;
Default - the value that will be set by default;
Debug - the value that will be used in debug mode, all data in the lower Debug field is taken using this particular value.



2. Now, we need to pull out the user rss feed with the last tracks listened to by the user entered.
It is known that the link to rss with the latest songs on last.fm is of the form ws.audioscrobbler.com/1.0/user/Uznick/recenttracks.rss . It is clear that the first thing to do is to add the line /recenttracks.rss to the username entered above. To do this, we transfer the String Concatenate tool from the Strings section to the working field. By default, it has one input field, but we need two. Why two? Because this tool works as follows: adds a line from the second field to the line from the first field. Create the second field and enter /recenttracks.rss there, connect the dash with the user to the first field and look through the debug window: it now has uznick / recenttracks.rss, and this is what you need.



3. Now we will create a full path to the feed with tracks. To do this, use the URLBuilder tool in the URL section. In principle, we could use the familiar String Concatenate, but there is one thing: at the output of String Concatenate we get the data of the String type, and we need to generate the data of the URL type.
We transfer URLBuilder to the workspace and fill its fields. In the Base field, enter the main part of the URL, in our case it is ws.audioscrobbler.com/1.0/user . You don’t need to enter anything in the path elements now, just connect the output String Concatenate with it and see the result: ws.audioscrobbler.com/1.0/user/uznick/recenttracks.rss is written in the debug field, that's right.



4. Get the content of the rss stream. The Fetch element from the Sources section will help us with this. We connect its input with the output of the previous element and look in the debug, there we have a list of songs.



5. All that is left for us to do is to extract the pictures from Flickr with these results and replace the songs with them. Drag the For Each: Replace element onto the workspace from the Operators panel, then drag the Flicr module from the Sources panel into it. Select the number of entries that need to be torn out from Flickr in the Find field (say, 5) and select in the images of field from which field you need to take the names of these pictures (we need to choose the title). Now we connect the input of the For Each element with the output of the Fetch element, then the For Each output with the input of the Pipe Output block (any block must end with this block) and that's it, the pipe is ready.



Now the pipe can be saved (Save in the upper right corner) or published to the public (Publish ibid.).



Link to the received pipe: pipes.yahoo.com/pipes/dtak0t282xGsC7COJphxuA

This is my first guide, write impressions and comments in the comments.

Source: https://habr.com/ru/post/5049/


All Articles