Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ErrorActionPreference = "Stop"
- $ProgressPreference = "SilentlyContinue"
- $url = "https://archive.org/details/CNBC_20191029_170000_The_Exchange"
- $savePath = "C:\Temp"
- $showName = Split-Path -Path $url -Leaf
- $showSavePath = [IO.Path]::Combine($savePath, $showName)
- if (!(Test-Path -Path $showSavePath)) { $null = mkdir $showSavePath }
- $page = Invoke-WebRequest -Uri $url -UseBasicParsing
- if (!($page.Content -match "js-tv3-init.+?value='(.+?)'")) { throw "Failed to extract video segments from web page" }
- $videoUrls = ($Matches[1] | ConvertFrom-Json).'TV3.clipstream_clips'
- $segmentCount = 1
- $ffmpegFileList = [IO.Path]::Combine($showSavePath, "ffmpegJoin.txt")
- foreach ($videoUrl in $videoUrls)
- {
- $segmentFileName = [IO.Path]::Combine($showSavePath, "$($showName)_$($segmentCount.ToString('0000')).mp4")
- Write-Output "Downloading '$($videoUrl)' to '$($segmentFileName)'"
- Invoke-WebRequest -Uri $videoUrl -UseBasicParsing -OutFile $segmentFileName
- "file '$($segmentFileName -replace "\\", "/")'" | Out-File -FilePath $ffmpegFileList -Encoding ascii -Append
- $segmentCount++
- #Start-Sleep -Milliseconds (Get-Random -Minimum 250 -Maximum 1500)
- }
- $joinedVideoFileName = $segmentFileName = [IO.Path]::Combine($showSavePath, "$($showName).mp4")
- $ffArgs = @("-f concat", "-safe 0", "-i", "`"$ffmpegFileList`"", "-c copy", "`"$joinedVideoFileName`"")
- Start-Process -FilePath ffmpeg -ArgumentList $ffArgs -Wait -NoNewWindow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement