Zabaware Support Forums

Zabaware Forums => Programming using the Ultra Hal Brain Editor => Topic started by: Bill DeWitt on March 16, 2007, 04:14:50 PM

Title: On line DVD rental RSS plugin
Post by: Bill DeWitt on March 16, 2007, 04:14:50 PM
Not intended to imply any association between Hal and NetFlix, I adapted my weather plugin to make a plugin that will read if there has been any recent shipments from my NetFlix queue. If you have an account, you can get the RSS feed for your shipments and replace the url line below.

Offered with no promises, watch for wordwrap and missing backslashes.

There is also a Zip on my plugin page.


Rem Type=Plugin
Rem Name= NetFlix
Rem Author= Bill DeWitt
Rem Host=Assistant

'-----------------------------------------------------------------
'This sub sets up the plug-ins option panel in Hal's options dialog
'-----------------------------------------------------------------
 
Sub OptionsPanel()
lblPlugin(0).Caption = "Simple plugin to read your NetFlix shipments."
lblPlugin(0).Move 120, 120, 3300, 1200
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub      

Rem PLUGIN: PLUGINAREA7
'FIXME Make separate functions for each level.
'verify that you want the memory function
LoadMemory=Array("new movies")
If ParseRequest(OriginalSentence,LoadMemory) Then
'verify that you are making a request
LoadRequest=Array("please","can you","will you","could you","would you","if you don't mind","I'd like you to","I would like you to")
If ParseRequest(OriginalSentence,LoadMemory) Then
    GetResponse = GetMovies()
End If
End If


Rem PLUGIN: FUNCTIONS
'===================================
Function ParseRequest(Source, Matrix)
'Reads information from an array to verify a request
For Each Datum In Matrix
If InStr(1,Source,Datum,1) Then
 ParseRequest = True
End If
Next
End Function

Function GetMovies()
       Dim objXMLNews
       Dim NewsArray()
       set objXMLNews = CreateObject("Msxml2.DomDocument.4.0")
       objXMLNews.async = False
       objXMLNews.ValidateOnParse = false

       objXMLNews.load("http://rss.netflix.com/TrackingRSS?id=xxxxxxxxxxxxx_your_own_id_xxxxxxxxxxxxxxx")
       Dim xmlNodeNews
       set xmlNodeNews = objXMLNews.documentElement.selectNodes("//item")
       Dim xmlNewsItem
       dim strResult
       For Each xmlNewsItem In xmlNodeNews
           CountNews = CountNews+1
       Next
       ReDim NewsArray(CountNews-1)
       s="NetFlix states that they have "
       For Each xmlNewsItem In xmlNodeNews
           Set MyMovies = xmlNewsItem.selectSingleNode("title")
           s=s+ xmlNewsItem.selectSingleNode("title").Text & ", "        
       Next

GetMovies = s
End Function