Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too) - Jon Galloway

Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

I tweaked my NuGet downloader PowerShell script to handle the Channel 9 media feeds, so you can grab a local copy of all session videos in the format of your choice:

  • WMV (high and low quality)
  • MV4 (high and low quality)
  • MP3
  • WMA

There are a few ultra-premium professional features in this script, like a download progress bar, logic to skip download if you’ve already grabbed some of the files, and pre-written filter strings to let you select the media type. Despite these advanced features, I pledge to think about keeping this script free for community use.

Just kidding, it’s Public Domain, like all the code on my blog.

Works with other Channel 9 feeds

The first setting is the feed url, which is different for each series or show. You can browse to a show / series, grab the RSS feed link, and update the script.

Why a script to download from an RSS feed?

This is a great question. The deal is that the Channel 9 RSS feed includes the low quality video file as the default enclosure. That makes sense in most cases, but not when you need to read code. I already had a script which did most of the work, so I just added some logic to grab the media URL based on some (admittedly a bit ugly) string matching.

I wouldn’t be surprised if there’s a smarter way, like adding a parameter to the RSS feed or something. Until I hear differently, I assert that this is a great script because it works on my machine.

Note: Now that I’ve got a local copy, I’ll be uploading a torrent via ClearBits, which is a bit more efficient than having everyone pull them from Channel 9.

How To Use

(same instructions as the NuGet downloader script – see that post for a little more detail and screenshots)

The easiest way to use the following script (included at the end of this post) is to open it in the PowerShell ISE (Integrated Scripting Environment). If you're running Windows 7 , just tap the Windows key and type "powershell" - you should see "Windows PowerShell ISE" show up in your Programs list. Paste in the code, save it if you'd like, and hit F5 to run it.

mvcConf Downloader

You can also paste the whole script into the NuGet Package Manager Console, but you lose the beautiful progress bar and maybe some other features.

There are a few settings you may want to tweak:

  • feedUrl indicates the feed you’re downloading. It’s already set for mvcConf, but you can change it to download other series.
  • overwrite indicates whether you want to force downloading even if you already have a file. It defaults to false, meaning that files you’ve already got will be skipped.
  • destinationDirectory defaults to a new folder called mvcConfVideo in your Documents folder. You can change that to any path you’d like.
  • downloadFilter determines which media type will be downloaded. Default is HD WMV. To change the media type, just copy the download filter string from the list shown below.

The Script

# --- settings ---
$feedUrl = "http://channel9.msdn.com/Series/mvcConf/RSS"
$overwrite = $false
$destinationDirectory = join-path ([Environment]::GetFolderPath("MyDocuments")) "mvcConfVideo"

# Download filter options
# "_high_ch9\.mp4"               - High quality mp4
# "_low_ch9\.mp4"                - Low quality mp4
# "_2MB_ch9\.wmv"                - High quality wmv (default)
# "^((?>(?!_2MB).)*)_ch9\.wmv"   - Low quality wmv (excluding high quality wmv)
# "_ch9\.wma"                    - WMA (audio)
# "_ch9\.mp3"                    - MP3
$downloadFilter = "_2MB_ch9\.wmv"

# --- locals ---
$webClient = New-Object System.Net.WebClient

# --- functions ---
function DownloadEntries {
 param ([string]$feedUrl) 
 $feed = [xml]$webClient.DownloadString($feedUrl)
 $progress = 0
 $entries = $feed.rss.channel.item.Length
 $feed.rss.channel.item | foreach {
    $url = New-Object System.Uri(($_.group.content | where {$_.url -match $downloadFilter}).url)
    $fileName = $url.Segments[-1]
    $saveFileName = join-path $destinationDirectory $fileName
    $pagepercent = [Math]::floor((++$progress)/$entries*100)
    if ((-not $overwrite) -and (Test-Path -path $saveFileName)) 
    {
        write-progress -activity "$fileName already downloaded" -status "$pagepercent% of current page complete" -percentcomplete $pagepercent
    }
    else 
    {
        write-progress -activity "Downloading $fileName" -status "$pagepercent% of current page complete" -percentcomplete $pagepercent
        $webClient.DownloadFile($url, $saveFileName)
    }
  }
}  

# --- do the actual work ---

# if dest dir doesn't exist, create it
if (!(Test-Path -path $destinationDirectory)) { New-Item $destinationDirectory -type directory }

DownloadEntries $feedUrl
Published Friday, February 18, 2011 1:56 AM by Jon Galloway
Filed under: ,

Comments

# re: Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

I will try it out now. you know the destinationDirectory variable, can set that like below;

$destinationDirectory = join-path (GetFolderPath("E:\MyDocuments")) "mvcConfVideo"

Sunday, February 20, 2011 3:47 AM by tugberk_ugurlu_

# re: Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

firstly, Thanks for the code. well I am now downloading the files but I have run into some problems;

first of all, I couldn't run the script beacuse of some restriction policy. set a new excecution policy with below script code inside power shell;

Set-ExecutionPolicy RemoteSigned

but I couldn't run it either and I figured it might be that I didn't run ps with admin role. I started ps with admin role and set the Set-ExecutionPolicy RemoteSigned and I am all good to go now. I will take a while I guess to download aIl the files.

Sunday, February 20, 2011 4:27 AM by tugberk_ugurlu_

# mvcConf 2 - All session videos are up, time for a recap

Dear MVC community: You are awesome Thanks for making mvcConf 2 a much bigger success than we'd ever

Monday, February 21, 2011 2:18 PM by Jon Galloway

# re: Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

I've updated your script to Name the file after the titel of the entry.

Also get that last part of the destination directory from the rss feed url.

It awaits a rss feed url as parameter, so you can load every rss feed without problems.

Fixed the pagepercent, and used a tmp file for saving (mainly for my DLNA Server)

https://gist.github.com/837672

Monday, February 21, 2011 3:41 PM by Albert Weinert

# AppleScript to download files from channel9 | Tomas Jansson

Pingback from  AppleScript to download files from channel9 | Tomas Jansson

# re: Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

The subsequent time I learn a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to learn, however I really thought youd have something interesting to say. All I hear is a bunch of whining about something that you could possibly fix when you werent too busy looking for attention. グッチアウトレット www.guccihonmono2013.com

Saturday, February 23, 2013 12:27 AM by sadyvudbwsw@gmail.com

# re: Download mvcConf session videos with a PowerShell script (should work with other Channel 9 feeds, too)

preceding poser wispy soloman vitality Dyanne Melba mudslinger qualitative コーチ 店舗 http://www.aiyoocoach.com/

Thursday, March 14, 2013 3:55 PM by rpggkprxwkl@gmail.com

Leave a Comment

(required) 
(required) 
(optional)
(required)