Skip to content

Instantly share code, notes, and snippets.

@marcelodeaguiar
Created May 28, 2014 12:32
Show Gist options
  • Save marcelodeaguiar/857f35114b15f4015ff9 to your computer and use it in GitHub Desktop.
Save marcelodeaguiar/857f35114b15f4015ff9 to your computer and use it in GitHub Desktop.
Download channel9 video/audio feeds (proxy supported)
Function Get-ProxyWebClient {
$webclient = New-Object System.Net.WebClient
$proxy = New-Object System.Net.WebProxy($global:ProxyUrl, $global:ProxyPort)
$proxy.Credentials = (Get-Credential).GetNetworkCredential()
$webclient.Proxy = $proxy
return $webclient
}
Function Channel9Downloader( [string]$feed, [string]$destination ) {
# $feed = "http://channel9.msdn.com/Shows/Azure-Friday/feed/mp4high"
# $destination = "AzureFriday"
mkdir "~\Desktop\${destination}"
cd "~\Desktop\${destination}"
$w = Get-ProxyWebClient
$a = ([xml]($w).downloadstring($feed))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[-1]
if (!(test-path $file))
{
Start-BitsTransfer -Source $url -Destination $file -Asynchronous
}
}
Start-Job {
While ((Get-BitsTransfer).JobState -contains 'Transferring') {
Get-BitsTransfer | Where-Object { $_.JobState -eq 'Transferred' } | Foreach { Complete-BitsTransfer -BitsJob $_ }
Start-Sleep 5
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment