Search This Blog

2020-11-22

PowerShell: Download TS Video Series from URL with Running Number

Product: Microsoft PowerShell
Version: 7.0

If you need to download a video of type TS extension, and it has the same URL, but each file has a running sequential number, this PowerShell script will download everyone into local machine, and you can specify the output file name as desire

Get_Video1.ps1
$url_main="https://www.szhysws.com:65/20190422/BS7i3zoM/2000kb/hls/83Fe3552"
1..600 | foreach {
$i="{0:000}" -f $_
 $url="$url_main$i.ts"
 $file="S01E01-$i.ts"
 Write-Output $file
 Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -MaximumRetryCount 100 -Uri $url -OutFile $file }

Remove "-MaximumRetryCount 100" for PowerShell version 3-4, or if it doesn't support this parameter

No comments: