United Kingdom
Asked — Edited

Rss Feeds

@MovieMaker mentioned he wanted more RSS Feeds in the AI topic earlier and listed out a few so...

Here is a project with a single Script Manager (renamed as RSS Reader so you can import in to your project via the merge button - I suspect you don't already have a command called RSS Reader).

I'm still working on it, I need to find some better RSS feeds or add in some code to cut off some of the feeds and remove the information we don't want (the poem of the day is a prime example).

It should hopefully make it clear how you can use pretty much any RSS url in the script (they are all the same script with a different feed url). Simply have your Speech Recognition commands run ControlCommand() with the relevant info to start the required feed reader. For instance;

ControlCommand("RSS Reader", ScriptStart, "Inspirational Quote")

I was (and have) going to make a single script which would read the feed from a list of available feeds however it all seemed like a lot of hard work for no gain what so ever. You could alter the code in the scripts I've linked to and use a WaitForChange() to hold off reading anything until a command was given which would change the feed url to the correct one, but this added far too many variables for my liking. I have another idea which may work to avoid having to copy and paste the same code in each script but again, unless there is good reason not to, I don't see copy and pasting code over and over again necessarily as a bad thing.

Please feel free to list any and all RSS feeds for information you use or would like to be included and I will add the scripts as we go. Keep checking the cloud, updates will just happen so make sure you check the notepad within the project to see what's been added and when it was last updated.


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

United Kingdom
#9  

Yeah, it's just a case of changing the $feedurl variable in each of the scripts really.

I did have an idea of making one main script and then another which would select the correct feed url but since the code is so simple and short per script it made more sense, at least to me, to just duplicate the script each time and change the URL to suit, saving as a new script.

The basic code for the scripts is;


# Script Title
# Author: Rich Pyke

# Define variables
# Quote Feed URL
$feedurl = "url to rss feed"

# Speak the story
SpeakRSSDescription($feedurl,1)

# End of script
Halt()

So it's so simple to adjust to suit a different RSS feed. To be honest, the whole script could be replaced with just the SpeakRSSDescription() command and hardcode the URL each time. Everything else in the script is pretty much redundant but it allows for future modification and alteration to include a more complex script if the requirement is ever there (i.e. find location from GPS sensor, look up correct weather forecast for location, read multiple stories etc.)

However, with rss feeds such as news and forum posts there is always going to be more than one story, this is where the code will change. The News Feed RSS script from a few months ago asks the user if they want to hear another story and continues until a no is heard. This script will be added to the next update of this script along with 2 blank scripts, one for a single story and one for multiple stories. Depending on my weekend I should hopefully have it updated over the next couple of days.

#10  

Rich, If you find any other RSS feeds please share, like you always do. You have encouraged me to explore and update my project many times. Thank you Steve S

#12  

I love this feature. I have a question about it though. Can you place a RSS feed into a variable as mentioned above, an then use a replace type of command to strip out the extra characters like non-breakable space's ( ) with " ". I haven't found a replace yet, and substring type functions could be a lot of script for a large article. Does anyone have a sample script that does this?

#13  

Here is the issue that I am running up against if I wasn't clear in what I was asking. I don't think that I was at all...

I am trying to remove the " " from this feed.

SpeakRSS("http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml",1)

If you place this into a script and run it, you will see what I am running into. This bot is going to be used at a elementary and high school to introduce students to robotics, so any advice you can give would be greatly appreciated.
Thanks for any advice.

#14  

@steve, please share your finished rss script with us.

thanks, Mel

#15  

Here is one way is use a variable in RSS. I am sure there are many ways. This is an example by Rich that I modified adding a random # gen.

Quote Of The Day

Author: Rich Pyke (modifed by Steve S - random quotes)

Define variables

Quote Feed URL

Pick a random number from 1 to 5

$response = GetRandom(1,5) print ($response)

Use response depending on random number

If($response = 1) $feedurl = "http://www.quotesdaddy.com/feed/tagged/Inspirational"; ElseIf($response = 2) $feedurl = "http://www.quotesdaddy.com/feed/tagged/baseball"; ElseIf($response = 3) $feedurl = "http://www.quotesdaddy.com/feed/tagged/political"; ElseIf($response = 4) $feedurl = "http://www.quotesdaddy.com/feed/tagged/man"; ElseIf($response = 5) $feedurl = "http://www.quotesdaddy.com/feed/tagged/women"; EndIf

Speak the story

SpeakRSSDescription($feedurl,1)

End of script

Halt()

#16  

I guess the question should be phrased more like this...

I want to take the xml that is being passed back from a web request, and store it in either a variable. I then want to use something like Replace($returnedtext,"&npsb;"," ") to remove "&npsb; values (and any others I come across) from the feed so that the text to speech piece can read the rss feed without reading the extra invisible characters.

I may just write an app that runs on my desktop that does this periodically, clean the data, and then place it in files on my machine to be read by the robot. I hoped not to have to this, but I cant find anything in EZ-B that is going to allow me to do this yet. Its not any big deal. I just hoped that there was a method of doing this more easily.

BTW, I have written all of the scripts for my next project (except for movement scripts). ARC is so simple to use and pretty powerful. I am impressed. Great job EZ-Robot team!