Chapter 22. Extended Example: Web Client Programming

By this point, you’ve seen how to interact with a database, parse things, and handle errors. Let’s now take this a step farther and introduce a web client library to the mix.

We’ll develop a real application in this chapter: a podcast downloader, or podcatcher. The idea of a podcatcher is simple. It is given a list of URLs to process. Downloading each of these URLs results in an XML file in the RSS format. Inside this XML file, we’ll find references to URLs for audio files to download.

Podcatchers usually let the user subscribe to podcasts by adding RSS URLs to their configuration. Then, the user can periodically run an update operation. The podcatcher will download the RSS documents, examine them for audio file references, and download any audio files that haven’t already been downloaded on behalf of this user.

Tip

Users often call the RSS document a podcast or the podcast feed, and call each individual audio file an episode.

To make this happen, we need to have several things:

  • An HTTP client library to download files

  • An XML parser

  • A way to specify and persistently store which podcasts we’re interested in

  • A way to persistently store which podcast episodes we’ve already downloaded

The last two items can be accommodated via a database that we’ll set up using HDBC. The first two can be accommodated via other library modules we’ll introduce in this chapter.

Tip

The code in this chapter was written specifically for this book, but is based on ...

Get Real World Haskell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.