-
-
Save pa-0/621f77fa8f2bbab692ee46d7859f83f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Update-dotNETVideo | |
{ | |
[CmdletBinding()] | |
param ( | |
# A path to subtitle file of folder where the subtitles are located. | |
[Parameter(Mandatory = $true, | |
ValueFromPipeline = $true, | |
ValueFromPipelineByPropertyName = $true, | |
ValueFromRemainingArguments = $false, | |
Position = 0, | |
ParameterSetName = 'Basic')] | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript( { | |
if ( -Not ($_ | Test-Path) ) | |
{ | |
throw "The path does not exist." | |
} | |
return $true | |
})] | |
[System.IO.FileInfo] | |
$Path, | |
# A show-to-download name. | |
[Parameter(Mandatory = $true, | |
ValueFromPipeline = $true, | |
ValueFromPipelineByPropertyName = $true, | |
ValueFromRemainingArguments = $false, | |
Position = 1)] | |
[ValidateNotNullOrEmpty()] | |
[String] | |
$Name, | |
# A switch for high quality video download | |
[Parameter(Mandatory = $false)] | |
[Switch] | |
$HighQuality | |
) | |
Process | |
{ | |
if(!(Test-Path -Path "$Path\$Name")) | |
{ | |
New-Item -Path $Path -Name $Name -ItemType Directory -Force | Write-Verbose | |
} | |
Set-Location -Path "$Path\$Name" | |
if ($HighQuality) | |
{ | |
$suffix = "high" | |
} | |
$urlToRss = "https://channel9.msdn.com/Series/$Name/feed/mp4$suffix" | |
try | |
{ | |
([System.Net.WebRequest]::Create($urlToRss)).GetResponse() | Write-Verbose # Test if it is show or series. | |
} | |
catch | |
{ | |
$urlToRss = "https://channel9.msdn.com/Shows/$Name/feed/mp4$suffix" | |
} | |
Write-Verbose -Message "RSS URL: $urlToRss" | |
$a = ([xml](new-object net.webclient).downloadstring($urlToRss)) | |
$a.rss.channel.item | | |
ForEach-Object { | |
$url = New-Object System.Uri($_.enclosure.url) | |
$file = $url.Segments[-1] | |
$file | |
$file = "$Path\$Name\$file" | |
if (!(test-path $file)) | |
{ | |
(New-Object -TypeName ([System.Net.WebClient])).DownloadFile($url, $file) | |
} | |
} | |
} | |
} | |
@('XamarinShow','CSharp-101','ASPNET-Core-101','Xamarin-101','Entity-Framework-Core-101','NET-Core-101','Desktop-and-NET-Core-101','Docker-and-NET-Core-101') | | |
Update-dotNETVideo -Path "$env:USERPROFILE\Downloads" -HighQuality -Verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment