Download PowerScripting podcast episodes using PowerShell and BITS

by ravikanthchaganti on February 8, 2010
376 Views

Update (3/5): Fixed an issue with empty podcast enclosure links 

PowerScripting podcast series is a great source of PowerShell related information. I have been following the same since episode 80, if I remember that well. At present the site has no way to download all the episodes in one single click. So, this morning I wrote a quick script to download all of these episodes to my local archive using BITS file transfer service. It is a simple one and did not require lot of effort.  

Import-Module BitsTransfer
$webclient = New-Object System.Net.WebClient
$podcastFeed = ([xml]$webClient.DownloadString("http://feeds.feedburner.com/powerscripting")).rss.channel.item
$podcastFeed | % { Start-BitsTransfer -Source $_.origEnclosureLink -Destination C:\Podcasts\PowerScripting -Asynchronous }

 This snippet will download all podcast episodes (MP3) files using BITS file transfer service. You can monitor the progress using Get-BitsTransfer cmdlet. After testing this, I thought I will just put the whole thing in to a simple script so that I can re-use the same for other podcast feeds too. The result is the following PowerShell v2 script. 

Podcasts.ps1 (Downloaded 88 times)
   

Note: I have not tested this script with any feed URL other than PowerScripting podcast. At the same time, I don’t see a reason why this should fail if the feed URL is formatted similar to PowerScripting Feed URL. 

 This script is a bit more intelligent than the above code snippet. It can detect if proxy authentication is required and takes the feed URL as a parameter. After you dot source the script, 

Get-Podcast -url http://feeds.feedburner.com/powerscripting

Get-Podcast Output 

As you see in the output, Get-Podcast returns a custom object with three properties Title, PodcastURL and PodcastMedia. PodcastMedia property contains the link to MP3 file, PodcastURL is the episode page and Title is just title. To download all the episodes at once  

Import-Module BitsTransfer
$podcasts = Get-Podcast -url "http://feeds.feedburner.com/powerscripting"
$podcasts | % { Start-BitsTransfer -Source $_.podcastMedia -Destination C:\Podcasts\PowerScripting -Asynchronous }

 Note: I have not tested this script with any feed URL other than PowerScripting podcast. At the same time, I don’t see a reason why this should fail if the feed URL is formatted similar to PowerScripting Feed URL. 

Get-Podcast can be a natural extension to BITS File transfer powerpack and that is what I did. I created another option in the Powerpack to download podcasts. This is what you see in the new release of powerpack. 

BITS PowerPack

BITS PowerPack

Over here, you can either open the episode web page or download the media using BITS. Once you start the download, all download jobs will appear in List of Active Jobs. Hope you find this useful.

Related Posts

Leave a Comment

Previous post:

Next post: