In my last part of this topic, I touched on using IE7's built in RSS Platform to setup a few podcasts to be automatically downloaded.
I wanted to use Windows Media Player to sync the Podcasts with my MP3 player. My particular player (Sansa Fuze 8gb) requires the Genre tag to be set to 'Podcast' in order to show up in the approrpriate place in the UI.
To start with, I create a NTFS symbolic link for each podcasts folder. Explaining Vista's implementation of symbolic links is beyond the scope of this article. See http://en.wikipedia.org/wiki/NTFS_symbolic_link if you want to begin a research project on them.
All you really need to know is that by using symbolic links, I can access a folder using
c:\users\gaurhoth\podcasts\{feed name}
instead of
C:\Users\gaurhoth\AppData\Local\Microsoft\Windows\Temporary Internet Files\Enclosure\{E4E0D525-2BAC-4618-BA87-3A6310945820}
This does require Vista. Since we are using a LINK to the original folder that the RSS Platform manages, we can let the RSS Platform handle removing old enclosures instead of having to write extra code.
The next big task that I let powershell handle for me is removing the Read Only attribute so that I can remove any Alternate Data Streams (another topic covered in many articles on the internet - search for 'Alternate Data Streams in NTFS'). This is equivalent to clicking 'UNBLOCK' in the Properties of certain files downloaded using IE.
I also update the MP3 Genre Tag to say 'Podcast' using taglib-sharp which you can find at http://www.taglib-sharp.com/Download/.
Setting up Windows Media Player is pretty straight-forward. Create an 'Auto-Playlist' to sync with your device like this:
Next, setup your library to pick up audio files from your podcasts folder (the symbolic link created using Powershell):
You can download the script here: podcastsync.ps1 and it's pasted below:
# Require taglib-sharp. See http://www.taglib-sharp.com/Download/.
# You'll find the compiled .NET 2.0 DLLs in taglib-sharp-x.x.x.x-windows.zip
# Change path appropriately
[void][Reflection.Assembly]::LoadFile("c:\Users\gaurhoth\ps\poshpodsync\taglib-sharp.dll")
# Root of folder to store the symbolic links
$podcasthome = "$home\podcasts"
# Root of the Feed Folder where you are storing podcasts feeds
$feedhome = 'Podcasts'
if (-not [system.IO.Directory]::Exists("$podcasthome")) {
Throw "$podcasthome does not exists."
}
# enumerate the feeds under under your $feedhome
$feeds = (New-Object -ComObject Microsoft.FeedsManager).RootFolder.getsubfolder($feedhome)
foreach ($feed in $feeds.feeds) {
if (-not (Test-Path "$podcasthome\$($feed.Name)")) {
#create NTFS Symbolic Links to path were IE7 stores the enclosures for each feed
cmd /c "mklink /J `"$podcasthome\$($feed.name)`" `"$($feed.localenclosurepath)`""
}
get-childitem "$podcasthome\$($feed.name)" -Recurse -Include *.mp3,*.wma | % {
Write-Host "$_"
# Test for ReadOnly flag and remove if present
if ($_.attributes -band [system.IO.FileAttributes]::ReadOnly) {
$_.attributes = $_.attributes -bxor [system.IO.FileAttributes]::ReadOnly
}
# Simulates clicking 'UNBLOCK' on properties of a file downloaded
# using Internet Explorer. Look up Alternate Data Streams in NTFS if your
# curious.
cmd /c "echo on > `"$($_):Zone.Identifier`""
# Using taglib-sharp to make sure each podcast is tagged as a podcast.
# My mp3 player uses the tag to create a separate list of files separate
# from my music list.
$media = [TagLib.File]::Create($_.fullname)
$dirty = $FALSE
if (-not $media.Tag.Artists) {
$media.Tag.Artists = $feed.Name
$dirty = $TRUE
}
if (-not $media.Tag.Album) {
$media.Tag.Artists = $feed.name
$dirty = $TRUE
}
if ($media.Tag.Genres -notmatch "Podcast") {
$media.Tag.Genres = "Podcast"
$dirty = $TRUE
}
if ($dirty) { $media.Save() }
#replace Read-Only or IE RSS Platform doesn't clean up old enclosures.
if (-not ($_.attributes -band [system.IO.FileAttributes]::ReadOnly)) {
$_.attributes = $_.attributes -bxor [system.IO.FileAttributes]::ReadOnly
}
}
}
That's all for now.
Gaurhoth