Product: PowerShell
PowerShell script which shown an example to download video from web, which contains multi-part TS video.
Assumptions:
- The TS video starts with number 1
- Last part of the video is number 600
- The file name is a running number that increment by 1
- All videos have exact same URL, but different by running number
- The filename has 3 character digit, e.g. 001, 002, 003
- The output file is call S01E08-[part].ts
- The video extension is .ts
- 5 parallel download
Start-Job -Scriptblock {
1..100 | foreach {
$url_main="https://www.szhysws.com:65/20190422/RuBaJpqw/2000kb/hls/1svhk1647"
$i="{0:000}" -f $_
$url="$url_main$i.ts"
$file="S01E08-$i.ts"
Write-Output $file
Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -Uri $url -OutFile $file
}
}
Start-Job -Scriptblock {
101..200 | foreach {
$url_main="https://www.szhysws.com:65/20190422/RuBaJpqw/2000kb/hls/1svhk1647"
$i="{0:000}" -f $_
$url="$url_main$i.ts"
$file="S01E08-$i.ts"
Write-Output $file
Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -Uri $url -OutFile $file
}
}
Start-Job -Scriptblock {
201..300 | foreach {
$url_main="https://www.szhysws.com:65/20190422/RuBaJpqw/2000kb/hls/1svhk1647"
$i="{0:000}" -f $_
$url="$url_main$i.ts"
$file="S01E08-$i.ts"
Write-Output $file
Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -Uri $url -OutFile $file
}
}
Start-Job -Scriptblock {
301..400 | foreach {
$url_main="https://www.szhysws.com:65/20190422/RuBaJpqw/2000kb/hls/1svhk1647"
$i="{0:000}" -f $_
$url="$url_main$i.ts"
$file="S01E08-$i.ts"
Write-Output $file
Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -Uri $url -OutFile $file
}
}
Start-Job -Scriptblock {
401..600 | foreach {
$url_main="https://www.szhysws.com:65/20190422/RuBaJpqw/2000kb/hls/1svhk1647"
$i="{0:000}" -f $_
$url="$url_main$i.ts"
$file="S01E08-$i.ts"
Write-Output $file
Invoke-WebRequest -UserAgent "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" -Uri $url -OutFile $file
}
}
|
No comments:
Post a Comment