Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#CHECK THE PATH ON LINE 2 and the FEED on LINE 3
cd "C:\users\scott\Downloads"
$a = ([xml](new-object net.webclient).downloadstring("https://channel9.msdn.com/Series/CSharp-101/feed/mp4"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[-1]
$file
if (!(test-path $file)) {
(New-Object System.Net.WebClient).DownloadFile($url, $file)
}
}
@skycommand

This comment has been minimized.

Copy link

commented Sep 29, 2019

Try this:

Param (
   $DownloadFolder = 'C:\users\scott\Downloads',
   $DownloadURL = 'https://channel9.msdn.com/Series/CSharp-101/feed/mp4'
)

#CHECK THE PATH ON LINE 2 and the FEED on LINE 3
Push-Location $DownloadFolder
$a = ([xml](New-Object net.webclient).downloadstring($DownloadURL))
$a.rss.channel.item | ForEach-Object {  
    $url = New-Object System.Uri($_.enclosure.url)
    $file = $url.Segments[-1]
    $file
    if (!(Test-Path $file)) {
        (New-Object System.Net.WebClient).DownloadFile($url, $file)
    }
}
Pop-Location

Now you can call the script and give both the download location and the download URL, like this:

& .\DownloadVideosFromRSS.ps1 -DownloadFolder "D:\MyCoolVids" -DownloadURL 'https://channel9.msdn.com/Series/NET-Core-101/feed/mp4high'

Now, I should of think of a way to make the script prepend numbers to each file name so that these downloaded videos could be watched in the correct order.

@ArkNieckarz

This comment has been minimized.

Copy link

commented Sep 29, 2019

# This will download high quality mp4 video files, ~1.14GB in total!!!
# Prepend sequence numbers to each file.
#CHECK THE PATH ON LINE 2 and the FEED on LINE 3
cd "c:\TEMP"
$a = ([xml](new-object net.webclient).downloadstring("https://channel9.msdn.com/Series/CSharp-101/feed/mp4"))
$cnt = 20
$a.rss.channel.item | foreach{  
    $url = New-Object System.Uri($_.enclosure.url)
    $file = $url.Segments[-1]
    $cnt = $cnt - 1
    $file_name = "$cnt" + "_" + $file
    if (!(test-path $file)) {
    $f = $url.OriginalString
    $n = $f.Replace(".mp4", "_high.mp4")
        echo $n, $file_name
        (New-Object System.Net.WebClient).DownloadFile($n, $file_name)
    }
}
@liuning0820

This comment has been minimized.

Copy link

commented Sep 29, 2019

#CHECK THE PATH ON LINE 2 and the FEED on LINE 3
cd "$env:USERPROFILE\Downloads"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.