File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ Param (
2+ [Parameter (Mandatory = $true )]
3+ [string ]
4+ $RssUrl ,
5+
6+ [ValidateScript ({Test-Path $_ - PathType ' Container' })]
7+ [string ]
8+ $DownloadFolder = ' .\'
9+ )
10+
11+ Push-Location $DownloadFolder
12+
13+ $WebClient = New-Object System.Net.WebClient
14+
15+ Write-Output ' Downloading RSS feed...'
16+ try {
17+ $RSSWebObject = ([xml ]($WebClient ).downloadstring($RssUrl ))
18+ }
19+ catch {
20+ throw
21+ break
22+ }
23+
24+ $counter = 0 ;
25+ foreach ($item in $RSSWebObject.rss.channel.item ) {
26+ $counter ++
27+
28+ if ($null -eq $item.enclosure.url ) {
29+ Write-Output $ (' {0:D2}: No URL found)' -f $counter )
30+ continue
31+ }
32+ $url = New-Object System.Uri($item.enclosure.url ) - ErrorAction Stop
33+ $FileName = ' {0:D2}. {1}' -f $counter , $url.Segments [-1 ]
34+
35+ Write-Output $FileName
36+ if (! (Test-Path $FileName )) {
37+ # $WebClient.DownloadFile($url, $FileName)
38+ Invoke-WebRequest - Uri $url - OutFile $FileName - ErrorAction Stop
39+ }
40+ }
41+
42+ Pop-Location
You can’t perform that action at this time.
0 commit comments