Skip to content

Instantly share code, notes, and snippets.

@camalot
Last active August 29, 2015 13:58
Show Gist options
  • Save camalot/6c897065c91ae5242404 to your computer and use it in GitHub Desktop.
Save camalot/6c897065c91ae5242404 to your computer and use it in GitHub Desktop.
# Edit the following variable as required.
$destination="F:\Media\Build2014\"
$list = "F:\Media\Build2014\episodes.txt"
if(!(test-path($destination))){
New-Item $destination -ItemType directory
}
if((test-path($list))) {
$grabbed = get-content $list
} else {
New-Item $list -type file
$grabbed = @()
}
# This is the initial part of the URL for the WMV High videos. (this is a comma separated list of feeds)
@("http://s.ch9.ms/Events/Build/2014/RSS/mp4high","http://s.ch9.ms/Events/Build/2014/RSS/mp4")|foreach{
$rss=invoke-webrequest -uri $_
[xml]$rss.Content|foreach{
$_.SelectNodes("rss/channel/item/enclosure")
}|where {
# only if it does not exist in the episodes file
$grabbed -notcontains($_.url.split("/")[-1])
}|foreach{
$fn = $_.url.split("/")[-1]
$ext = $fn.split(".")[-1]
$title = $_.ParentNode.SelectSingleNode("title/text()").Value.Replace(":","-").Replace("+","_").Replace("\\","_").Replace("/","_").Replace("?","_").Trim()
# even if it is not in the episodes file, if the destination exists, it will be skipped.
if(!(test-path ($destination + $title + "." + $ext))){
"Downloading: " + $title + " : " + $fn.split(".")[0]
$out = $destination + $title + "." + $ext
start-bitstransfer $_.url $out
Out-File $list -Append -InputObject $fn
start-sleep -seconds 30
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment