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

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

#17  

This is C# code that will convert RSS into a text file. Now to figure out how to get ARC to read the desired section of the text file.

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml; using System.IO; using System.Text; namespace WindowsFormsApplication3 { static class Program { /// <summary> /// Used to convert RSS read to plain text file /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);

        XmlDocument rssXmlDoc = new XmlDocument();

        // Load the RSS file from the RSS URL
        rssXmlDoc.Load(&quot;http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml?1&quot;);

        // Parse the Items in the RSS file
        XmlNodeList rssNodes = rssXmlDoc.SelectNodes(&quot;rss/channel/item&quot;);

        StringBuilder rssContent = new StringBuilder();
        System.IO.StreamWriter file = new System.IO.StreamWriter(&quot;C:\\rssfeeds\\Test.txt&quot;);
           
        // Iterate through the items in the RSS file
        foreach (XmlNode rssNode in rssNodes)
        {
            XmlNode rssSubNode = rssNode.SelectSingleNode(&quot;title&quot;);
            string title = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;

            rssSubNode = rssNode.SelectSingleNode(&quot;link&quot;);
            string link = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;

            rssSubNode = rssNode.SelectSingleNode(&quot;description&quot;);
            string description = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;
            // Removes the &amp;nbsp; characters - may not be needed
            rssContent.Append(description.Replace(&quot;&amp;nbsp;&quot;, &quot;&quot;));
            // regex to turn html into text
            file.WriteLine(System.Text.RegularExpressions.Regex.Replace(rssContent.ToString(),&quot;&lt;[^&gt;]*&gt;&quot;,&quot;&quot;));
         }
        file.Close();
        Application.Run(new Form1());
        
    }

}

}

#18  

Here is the solution that I have so far.

I have a C# app that will convert an rss feed into a text file. Here is the code below. You can parameterize it and make it run for multiple rss feeds. You can also have it write the files to a different location. Feel free to modify it however suits you.

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml; using System.IO; using System.Text; namespace WindowsFormsApplication3 { static class Program { /// <summary> /// Used to convert RSS read to plain text file /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);

        XmlDocument rssXmlDoc = new XmlDocument();
        string nextline = null;

        // Load the RSS file from the RSS URL
        rssXmlDoc.Load(&quot;http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml?1&quot;);

        // Parse the Items in the RSS file
        XmlNodeList rssNodes = rssXmlDoc.SelectNodes(&quot;rss/channel/item&quot;);

        StringBuilder rssContent = new StringBuilder();
        System.IO.StreamWriter file = new System.IO.StreamWriter(&quot;C:\\rssfeeds\\Test.txt&quot;);
           
        // Iterate through the items in the RSS file
        foreach (XmlNode rssNode in rssNodes)
        {
            XmlNode rssSubNode = rssNode.SelectSingleNode(&quot;title&quot;);
            string title = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;

            rssSubNode = rssNode.SelectSingleNode(&quot;link&quot;);
            string link = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;

            rssSubNode = rssNode.SelectSingleNode(&quot;description&quot;);
            string description = rssSubNode != null ? rssSubNode.InnerText : &quot;&quot;;
            // Removes the &amp;nbsp; characters - may not be needed
            rssContent.Append(description.Replace(&quot;&amp;nbsp;&quot;, &quot;&quot;));
            // regex to turn html into text
            nextline = System.Text.RegularExpressions.Regex.Replace(rssContent.ToString(), &quot;&lt;[^&gt;]*&gt;&quot;, &quot;&quot;);
            //replace whitespace
            nextline = System.Text.RegularExpressions.Regex.Replace(nextline, &quot;[\n\r\t]&quot;, &quot; &quot;);
            nextline = nextline.Replace(&quot;\&quot;&quot;,&quot;&quot;);
            nextline = nextline.Replace(&quot;(&quot;,&quot;&quot;);
            nextline = nextline.Replace(&quot;)&quot;, &quot;&quot;);
            nextline = nextline.Replace(&quot;&amp;mdash;&quot;, &quot;&quot;);
            int cutat = 0;
            cutat = nextline.IndexOf(&quot;Biography&quot;);
            nextline = nextline.Remove(cutat);
            file.WriteLine(nextline);
            break;

         }
        file.Close();
        Application.Run(new Form1());
        
    }

}

}

Then in EX-Builder, I have a script called DailyPoem. It reads the file into a variable, and then reads(says) the variable.

$rsstext = filereadline("c:\rssfeeds\test.txt") say($rsstext) filereadclose("C:\rssfeeds\test.txt")

I plan on making the code far better. This was just an effort to get something working. I will clean it up and post it for people to use. I will also try to figure out how to make this far less of a two step process and see if it is possible to put the app somehow as a component ARC. I know there is an SDK, but I haven't played much with it.

I hope this helps others who have had this issue with RSS feeds.