Tuesday, August 18, 2009 at 7:32 PM.
newsRiverSuite.playlist.download
on download (url, folder) { <<Changes <<2/28/06; 5:08:26 AM by DW <<Created. Reads a special kind of RSS feed, one that doesn't change. It's got a bunch of podcasts or songs, download them all, and that's it. local (xmltext = tcp.httpreadurl (url)); xml.compile (xmltext, @xstruct); <<scratchpad.xstruct = xstruct local (adrrss = xml.getaddress (@xstruct, "rss")); local (adrchannel = xml.getaddress (adrrss, "channel")); for adr in adrchannel { if nameof (adr^) contains "item" { local (adrtitle = xml.getaddress (adr, "title")); local (adrenclosure = xml.getaddress (adr, "enclosure")); local (url = adrenclosure^.["/atts"].url); local (extension = string.nthfield (url, ".", string.countfields (url, "."))); local (fname = adrtitle^, maxsize = 32 - sizeof (extension) - 1); if sizeof (fname) > maxsize { fname = string.mid (fname, 1, maxsize)}; local (f = folder + fname + "." + extension); file.surefilepath (f); if not file.exists (f) { //don't download again local (content = tcp.httpreadurl (url)); file.writewholefile (f, content)}}}}; bundle { //test code local (folder =frontier.pathstring + "Carnival Cast" + file.getpathchar ()); file.surefilepath (folder + "xxx"); file.openfolder (folder); download ("http://pod-serve.com/podcasts/feed/carnvial-cast", folder)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.