diff options
Diffstat (limited to 'ch23/23_a_1/PodMain.hs')
| -rw-r--r-- | ch23/23_a_1/PodMain.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ch23/23_a_1/PodMain.hs b/ch23/23_a_1/PodMain.hs new file mode 100644 index 0000000..5e58ec4 --- /dev/null +++ b/ch23/23_a_1/PodMain.hs @@ -0,0 +1,37 @@ +{-- snippet imports --}
+module PodMain where
+
+import PodDownload
+import PodDB
+import PodTypes
+import Database.HDBC
+
+{-- snippet workerFuncs --}
+addUrl dbh url =
+ do addPodcast dbh pc
+ commit dbh
+ where pc = Podcast {castId = 0, castURL = url}
+
+update :: IConnection conn => conn -> (String -> IO ()) -> IO ()
+update dbh logf =
+ do pclist <- getPodcasts dbh
+ mapM_ procPodcast pclist
+ logf "Update complete."
+ where procPodcast pc =
+ do logf $ "Updating from " ++ (castURL pc)
+ updatePodcastFromFeed dbh pc
+
+download dbh logf =
+ do pclist <- getPodcasts dbh
+ mapM_ procPodcast pclist
+ logf "Download complete."
+ where procPodcast pc =
+ do logf $ "Considering " ++ (castURL pc)
+ episodelist <- getPodcastEpisodes dbh pc
+ let dleps = filter (\ep -> epDone ep == False)
+ episodelist
+ mapM_ procEpisode dleps
+ procEpisode ep =
+ do logf $ "Downloading " ++ (epURL ep)
+ getEpisode dbh ep
+{-- /snippet workerFuncs --}
|
