AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1510596
Accepted
somebadhat
somebadhat
Asked: 2019-12-17 21:57:29 +0800 CST2019-12-17 21:57:29 +0800 CST 2019-12-17 21:57:29 +0800 CST

如何使用 cmd 或 PowerShell 脚本捕获/记录/下载多个流式音频 url?

  • 772

Windows 10 64 位。

如何使用 cmd 或 PowerShell 脚本捕获/记录/下载多个流式音频 url?

我每晚使用 cmd 批处理从 15 个服务器捕获 15 个 .mp3 音频流,持续一个小时。我经历过 wget、ffmpeg、vlc 和 curl。我的脚本产生了不可靠的结果,只有七分之一的一天所有 15 个流捕获一个小时。卷曲是最可靠的。我为每个流打开一个 curl 实例。

start "" /min %windir%\curl.exe.lnk http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q -o "%temp%\bbc1.mp3" 

我今晚尝试了powershell,但失败了。15个powershell实例中的一半慢慢地关闭了自己,​​另一半没有捕获一个小时。

start "" /min "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.lnk" -Command "(new-object net.webclient).DownloadFile('http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q', '%temp%\bbc1.mp3')"

我认为在一个 powershell 实例中捕获 15 个流可能会更好,但第二个流永远不会启动,因为第一个流永远不会结束。

$Urls = @()
$Urls += "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q"  
$Urls += "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio3_mf_q"

$OutPath = "$env:temp\"

ForEach ( $item in $Urls) {
$file = $OutPath +  ($item).split('/')[-1] + ".mp3"
(New-Object System.Net.WebClient).DownloadFile($item, $file)
}

四个小时的 bing 和 google 没有答案。

如何从命令行捕获/录制/下载流式音频?

我没有被困在 powershell 或 curl 上。唯一的要求是它在 Windows 10 64 位上运行,它可靠地捕获所有 15 个流,并且它可以在没有用户交互的情况下运行。

audio cmd.exe
  • 2 2 个回答
  • 1756 Views

2 个回答

  • Voted
  1. somebadhat
    2019-12-30T07:44:34+08:002019-12-30T07:44:34+08:00

    Windows 10 64 位。不需要管理员权限。

    如何使用 streamripper v1.64.6、sleep、PowerShell 5.1 ( System.Net.WebClient DownloadFileAsync )、curl v.7.55.1 和 ffmpeg v.3.4 使用 cmd 或 PowerShell 脚本捕获/记录/下载多个流式音频 url。音频流以多种方式提供服务,依靠一种方法进行捕获并不是一个好主意。

    我在 cmd、streamripper v.1.64.6 和 ffmpeg v.3.4 方面取得了很大的成功。

    停止进程用于杀死 ffmpeg 和 curl 以将下载写入文件。

    您可以在使用 Windows Media Player 下载流时收听流。元数据长度不会总是正确显示。

    ffmpeg 可以用来做很多后期处理,比如写元数据和修剪。将路径更改为 ffmpeg 和 curl。streamripper、System.Net.WebClient 和 curl 默认覆盖。我将ffmpeg设置为覆盖。

    这些脚本下载 30 秒。

    使用 cmd、streamripper 和 ffmpeg:当 streamripper 失去连接时,它会重命名原始文件并再次开始捕获。此批处理连接文件。Streamripper 将至少捕获 iheart、tunein、streamguys、streamtheworld、radiojar、abacast 和limelight 流。一如既往地编写命令start "" streamripper.exe.lnk以防止暂停。

    流 URL 更改。我写了一个页面,可以帮助查找流 URL。如何找到 iheart 流 url。

    # How to simultaneously, concurrently, in one instance of cmd capture / record / download multiple audio streams
    # Windows 10 64-bit. cmd, sleep, streamripper v.1.64.6 and ffmpeg v.3.4. 
    # https://superuser.com/posts/1510596/how-to-simultaneously-concurrently-in-one-instance-of-powershell-capture-multi 
    # Streamripper overwrites by default. I set ffmpeg to overwrite.
    START "" /min "streamripper.exe.lnk" https://ample.revma.ihrhls.com/zc1269 -A -a ALICE3 -d "%cd%" -l 30 -u "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11" --quiet
    sleep 5
    START "" /min "streamripper.exe.lnk" http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q -A -a BBC13 -d "%cd%" -l 30 -u "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11" --quiet
    sleep 1
    title DELAY WHILE  STREAMRIPPER COMPLETES IT'S TASKS. 
    echo. 
    echo    DELAY WHILE STREAMRIPPER COMPLETES IT'S TASKS. 
    echo. 
    :delaystreamripper
    echo    %time%
    SET errorlevel=
    TASKLIST|FIND /I "streamripper.exe"> nul
    IF not ERRORLEVEL 1 (
    ping 8.8.8.8> nul
    rem change next line. I use 180.
    sleep 10 
    GOTO :delaystreamripper
    )
    :concatenate 
    dir *).*> NUL 2>&1
    IF NOT ERRORLEVEL 1 (
    SETLOCAL ENABLEDELAYEDEXPANSION
    echo. 
    echo    DEL *.CUE
    del /q *.cue
    echo. 
    echo    dir /b *^).*
    dir /b *^).* 
    echo. 
    sleep 1 
    for /f %%g in ('dir "*).*" ^| find "File(s)"') do SET zcnt1=%%g
    rem in different2 (1).aac    g="different2"    h=(1)    and    i=aac    w/o the quotes
    for /f "tokens=1,2,3 delims=. " %%g in ('dir /b "*).*"') do (
    copy /b /y "%%g (*).%%i" + "%%g.%%i" "%%g.%%i.tmp" 
    del /q %%g*.%%i 
    ) 
    for /f %%g in ('dir "*.tmp" ^| find "File(s)"') do SET zcnt2=%%g
    for /f "tokens=1,2,3 delims=. " %%g in ('dir /b "*.tmp"') do (
    ren %%g.%%h.%%i %%g.%%h 
    )
    echo. &echo    Concatenate !zcnt1! files with !zcnt2! files: 
    SETLOCAL DISABLEDELAYEDEXPANSION    
    )
    :ffmpeg
    sleep 1 
    TITLE FFMPEG 
    ECHO. 
    ECHO    FFMPEG
    start "" /min "%windir%\ffmpeg.exe.lnk" -y -i "%cd%\bbc13.mp3" -metadata title="BBC RADIO 1" -metadata artist="HITS. NEW MUSIC." -metadata album="bbc.co.uk/sounds" -metadata album_artist="HITS. NEW MUSIC." -ss 00:01:15 -c copy "%cd%\bbc1.mp3" 
    sleep 1 
    start "" /min "%windir%\ffmpeg.exe.lnk" -y -i "%cd%\alice3.aac" -acodec libmp3lame -metadata title="ALICE 95.5FM" -metadata artist="alice95.5FM.iheart.com" -metadata album_artist="alice95.5FM.iheart.com" "%cd%\alice.mp3"
    rem
    

    使用 Powershell、curl 和 ffmpeg:

    # How to simultaneously, concurrently, in one instance of powershell capture / record / download multiple audio streams? 
    # Windows 10 64-bit. Powershell 5.1, curl v.7.55.1 and ffmpeg v.3.4
    # https://superuser.com/posts/1510596/how-to-simultaneously-concurrently-in-one-instance-of-powershell-capture-multi 
    # System.Net.WebClient and curl overwrite by default. I set ffmpeg to overwrite.
    $host.ui.rawui.WindowTitle = $CurrentUser.Name +  "     " +  $(get-date) + "      " +$MyInvocation.MyCommand.Path
    #echo. 
    write-host "
    Capture for 30 seconds. 
    $(get-date)
    "
    write-host "   "$MyInvocation.MyCommand.Path 
    $wc = New-Object System.Net.WebClient 
    $url = "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q" 
    $output = "$env:userprofile\desktop\bbc1.mp3" 
    $wc.DownloadFileAsync($url, $output) 
    $wc = New-Object System.Net.WebClient 
    $url = "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio3_mf_q" 
    $output = "$env:userprofile\desktop\bbc3.mp3" 
    $wc.DownloadFileAsync($url, $output)
    # overwrite 
    & "$env:windir\ffmpeg.exe.lnk" -y -i "http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws" -c copy "$env:userprofile\desktop\bbc4.mp3"  
    & "$env:windir\curl.exe.lnk" http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p -o "$env:userprofile\desktop\bbc62.mp3" 
    # set capture time for 30 seconds
    start-sleep 30 
    # set capture time for 2 minutes
    # start-sleep (60*2)
    # set capture time for 3 hours
    # start-sleep (3600*3)
    stop-process -force -name curl 
    stop-process -force -name ffmpeg 
    # set tags and trim.
    Write-Host "
    Trim first 15 seconds of bbc62.mp3 is next. Listen to it then press any key to continue. Trimmed file is saved as bbc6.mp3"
    cmd /c pause | out-null
    & "$env:windir\ffmpeg.exe" -y -i "$env:userprofile\desktop\bbc62.mp3" -metadata title="BBC RADIO 1" -metadata artist="HITS. NEW MUSIC." -metadata album="bbc.co.uk/sounds" -metadata album_artist="HITS. NEW MUSIC." -ss 00:00:15 -c copy "$env:userprofile\desktop\bbc6.mp3" 
    remove-item "$env:userprofile\desktop\bbc62.mp3"
    exit
    #
    

    谷歌搜索 - 使用 curl 下载音频流

    谷歌搜索 - 使用 ffmpeg 下载音频流

    谷歌搜索 - 使用 ffmpeg 编写元数据

    System.Net.WebClient 的替代方案: powershell 可以在 stackoverflow 上并行运行命令

    如何捕获流式音频 如何保存流式音频 如何输出流式音频 如何录制流式音频

    • 2
  2. Best Answer
    somebadhat
    2021-04-01T13:38:36+08:002021-04-01T13:38:36+08:00

    Windows 10 64 位,PowerShell 5 脚本,用于翻录/捕获/记录/保存/下载流媒体音频到闪存驱动器为带有 streamripper、wget、curl、ffmpeg 的 .mp3,操作系统删除可疑文件,如果没有鼠标或锁定桌面键盘活动 X 秒,禁止使用脚本,用户仅限于标准/用户权限,并在一小时内注销。剪掉前3分钟。

    在不询问的情况下强行杀死 ffmpeg、wget、curl 和 streamripper 的每个实例。

    默认是 10 秒捕获四个流。请参阅 $zseconds。

    如果 streamripper 无法成功处理您的流,请尝试 ffmpeg、wget 或 curl。

    <# BEGIN COMMENTS
    
    **This script is written to run at a Window 10 64-bit PC that no one is sitting at. 
    Automated keyboard and mouse events to keep PC awake / unlocked. 
    See  KEEP PC AWAKE / UNLOCKED**
    
    Windows 10 64-bit, PowerShell 5 script to Rip / Capture / Record / Save / Download 
    streaming audio to flash drive as .mp3 with streamripper, wget, curl, ffmpeg, OS 
    deletes suspicious files, locks the desktop if there is no mouse or keyboard activity 
    for X seconds, prohibits the use of scripts, user is limited to standard / user rights 
    and logs you off in one hour. Cut first 3 minutes.
    
    **Forcefully kills every instance of ffmpeg, wget, curl, and streamripper w/o asking.**
    
    **The default is 10 second capture of four streams. See $zseconds**
    
    Try ffmpeg, wget or curl if streamripper does not succeed with your stream.
    
    ~2GB of free space on flash drive. Streams are saved to $env:userprofile\
    downloads\$ztimestamp and written to flash drive that has 
    flashDrive:\DoNotDeleteFlash4291phIr_Wn.txt to directory flashDrive:\downloads\radio 
    by ffmpeg. The time to write to flash drive depends on the quality of the system and 
    flash drive.
    
    Dependencies:
    
    flashDrive:\DoNotDeleteFlash4291phIr_Wn.txt. Used to find flash drive.
    flashDrive:\downloads with 4.txt, 4.txt(FlashDriveLetter).lnk, curl, wget, ffmpeg,
    xxmklink, and streamripper. Create shortcuts on the command line with xxmklink.exe 
    http://www.xxcopy.com/download/xxmklink.zip.
    Copy streamripper files to flashDrive:\downloads\streamripper
    
    If scripts prohibited:
    Create shortcut with name: 
    
    4.txt(FlashDriveLetter) i.e. 4.txt(K)     Script creates shortcuts for 23 drive letter.
    
    Target: 
    
    powershell.exe $z=Get-Date -f 'ddhhmmss'; copy 4.txt 4.txt.$z.txt; gc 4.txt|powershell
    
    Run shortcut.
    
    Kill with CMD:
    
    taskkill /f /im ffmpeg.exe& taskkill /f /im wget.exe& taskkill /f /im curl.exe& taskkill /f /im streamripper.exe
    
    Kill with PowerShell:
    
    taskkill /f /im ffmpeg.exe; taskkill /f /im wget.exe; taskkill /f /im curl.exe; taskkill /f /im streamripper.exe
    
    END COMMENTS #>
    
    
    
    
    
    
    $zseconds=3060 ; # Rip / Capture / Record / Save / Download     51 minutes all streams.
    $zseconds=240 ; # 4 minutes all streams.
    $zseconds=10 ; $zdebug=0 ; # 10 seconds 4 streams.
    
    # BEGIN Store script block in variable
    $zblock= {
    # If not online exit
    ping -n 1 8.8.8.8|out-null; 
    # if not errorlevel 1 
    # if false 
    IF (-not $?){Write-Output "
    ddhhmmss is $ztimestamp1  Unable to get online.  Terminating script."|out-file $zdrive\downloads\documents\4txtDailyLog.txt -append;
    Write-Output "
    ddhhmmss is $ztimestamp1  Unable to get online.  Terminating script and exiting in 5 seconds.
    ";
    Start-Sleep 5 ;
    exit;
    }
    
    # BEGIN Rip / Capture / Record / Save / Download streaming audio
    
    if($zdebug -eq '0'){
    # if in debug mode do the following
    Write-output "
    The time is $((get-date $ztimestamp0 -f 'hh:mm:sstt') -replace ' ','')`n
    Recording for $($zseconds/60) minutes     Recording stop $((get-date $ztimestamp0.AddSeconds($zseconds) -f 'hh:mm:sstt') -replace ' ','')      Processing stop ~$((get-date $ztimestamp0.AddSeconds($zseconds+(gc $zdrive\downloads\documents\4txtFFmpegLastTimeTook.txt)) -f hh:mm:sstt) -replace ' ','';)`n 
    This is $zdrive\downloads\4.txt`n
    Loading ffmpeg, wget, curl and streamripper.`n
    The current directory is $pwd";
    & $zdrive\downloads\ffmpeg.exe.lnk -y -i "http://listen.xray.fm/stream" -metadata title='KXRY 107.1FM PORTLAND,OR' -metadata artist='xray.fm' -metadata album='PORTLAND, OR' -metadata album_artist='xray.fm' -c copy "$zdrive\downloads\radio\xray2.mp3" ;
    start-sleep 1 ;
    & $zdrive\downloads\wget.exe.lnk http://listen.xray.fm/stream -O "$env:userprofile\downloads\$ztimestamp1\XRAY3.mp3" ;
    start-sleep 1 ;
    & $zdrive\downloads\curl.exe.lnk http://stream.live.vc.bbcmedia.co.uk/bbc_6music -o "$env:userprofile\downloads\$ztimestamp1\BBC63.mp3" ;
    start-sleep 1 ;
    & $zdrive\downloads\streamripper\streamripper.exe.lnk http://ample.revma.ihrhls.com/zc1269 -A -a ALICE3 -d $env:userprofile\downloads\$ztimestamp1\ -l $zseconds -u "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0" ;
    
    } else {
    
    
    # YOUR STREAMS HERE 
    
    
    # Capture and process with ffmpeg
    $zcut='00:03:00' ;
    & $zdrive\downloads\ffmpeg.exe.lnk -y -i "http://listen.xray.fm/stream" -af volume='2.367188' -metadata title='KXRY 107.1FM PORTLAND,OR' -metadata artist='xray.fm' -metadata album='PORTLAND, OR' -metadata album_artist='xray.fm' -ss $zcut "$zdrive\downloads\radio\xray2.mp3" ;
    start-sleep 1 ;
    & $zdrive\downloads\wget.exe.lnk http://listen.xray.fm/stream -O "$env:userprofile\downloads\$ztimestamp1\XRAY3.mp3" ;
    start-sleep 1 ;
    & $zdrive\downloads\streamripper\streamripper.exe.lnk http://ample.revma.ihrhls.com/zc1269 -A -a ALICE3 -d $env:userprofile\downloads\$ztimestamp1\ -l $zseconds -u "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0" ;
    start-sleep 1 ;
    & $zdrive\downloads\curl.exe.lnk http://stream.live.vc.bbcmedia.co.uk/bbc_6music -o "$env:userprofile\downloads\$ztimestamp1\BBC63.mp3" ;
    start-sleep 1 ;
    }
    #    END Rip / Capture / Record / Save / Download streaming audio
    
    # BEGIN Wait for sleep $zseconds and streamripper to finish
    start-sleep $zseconds ;
    $ProcessList = @("streamripper") ; Do {$ProcessesFound = Get-Process | ? {$ProcessList -contains $_.Name} | Select-Object -ExpandProperty Name ; IF ($ProcessesFound) {Start-Sleep 1}}Until (!$ProcessesFound)
    stop-process -name wget -ErrorAction SilentlyContinue ;
    stop-process -name curl -ErrorAction SilentlyContinue ;
    stop-process -name ffmpeg -ErrorAction SilentlyContinue ;
    start-sleep 1 ;
    #   END  Wait for sleep $zseconds and streamripper to finish
    
    # BEGIN CONCATENATE. If multiple files of one stream with ( in file name, concatenate them. 
    $Files = @(gci "$env:userprofile\downloads\$ztimestamp1\*`(*") ;
    IF (!($Files.length -eq 0)) {
    Write-Output "Files concatenated..." ;
    Write-Output "Files concatenated."|out-file $zdrive\downloads\documents\4txtDailyLog.txt -append ;
    gci "$env:userprofile\downloads\$ztimestamp1\*`(*" | foreach-object {
    $z="$_" -replace ' \(.\)','' ;
    cmd /c copy /b $z + $_ "$z.tmp" ;
    remove-item $z ;
    rename-item "$z.tmp" $z ;
    }
    ri "$env:userprofile\downloads\$ztimestamp1\*`(*" ;
    start-sleep 1 ;
    }
    #    END CONCATENATE. If multiple files of one stream with ( in file name, concatenate them. 
    
    # BEGIN FFMPEG
    $zprocess = get-date ;
    Write-Output "
    FFmpeg began at $((Get-Date -f 'hh:mm:sstt') -replace ' : ',':')
    " ;
    Write-Output "    $((Get-Date -f 'hh:mm:sstt') -replace ' : ',':') FFmpeg begins."|out-file "$zdrive\downloads\documents\4txtDailyLog.txt" -append ;
    
    if($zdebug -eq '0'){
    $zcut='00:00:00' ;
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\xray3.mp3" -af volume='2.367188' -metadata title='KXRY 107.1FM PORTLAND,OR' -metadata artist='xray.fm' -metadata album='PORTLAND, OR' -metadata album_artist='xray.fm' -ss $zcut "$zdrive\downloads\radio\xray.mp3" ;
    start-sleep 1 ; 
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\alice3.aac" -acodec libmp3lame -metadata album='IHEARTRADIO.COM' -metadata title='ALICE 95.5FM' -metadata artist='alice95.5FM.iheart.com' -metadata album_artist='alice95.5FM.iheart.com' -ss $zcut "$zdrive\downloads\radio\alice.mp3" ;
    start-sleep 1 ; 
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\bbc63.mp3" -metadata title='BBC RADIO 6' -metadata artist='ALTERNATIVE.' -metadata album='bbc.co.uk/sounds' -metadata album_artist='ALTERNATIVE.' -ss $zcut -c copy "$zdrive\downloads\radio\bbc6.mp3" ;
    start-sleep 1 ; 
    
    } else {
    
    $zcut='00:03:00' ;
    
    
    # YOUR PROCESSING HERE 
    
    
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\xray3.mp3" -metadata title='KXRY 107.1FM PORTLAND,OR' -metadata artist='xray.fm' -metadata album='PORTLAND, OR' -metadata album_artist='xray.fm' -ss $zcut -af volume='2.367188' "$zdrive\downloads\radio\xray.mp3" ;
    start-sleep 1 ; 
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\alice3.aac" -metadata album='IHEARTRADIO.COM' -metadata title='ALICE 95.5FM' -metadata artist='alice95.5FM.iheart.com' -metadata album_artist='alice95.5FM.iheart.com' -ss $zcut -acodec libmp3lame "$zdrive\downloads\radio\alice.mp3" ;
    start-sleep 1 ; 
    & "$zdrive\downloads\ffmpeg.exe.lnk" -y -i "$env:userprofile\downloads\$ztimestamp1\bbc63.mp3" -metadata title='BBC RADIO 6' -metadata artist='ALTERNATIVE.' -metadata album='bbc.co.uk/sounds' -metadata album_artist='ALTERNATIVE.' -ss $zcut -c copy "$zdrive\downloads\radio\bbc6.mp3" ;
    start-sleep 1 ; 
    }
    #    END FFMPEG
    
    # BEGIN WAIT FOR WRITING TO FLASH DRIVE TO FINISH
    write "    Past last FFmpeg. Waiting for all instances of FFmpeg to finish." ;
    $ProcessList = @("ffmpeg") ; Do {$ProcessesFound = Get-Process | ? {$ProcessList -contains $_.Name} | Select-Object -ExpandProperty Name ; IF ($ProcessesFound) {Start-Sleep 1}}Until (!$ProcessesFound)
    $z=(get-date -f 'hh:mm:ss tt') -replace ' ','' ;
    Write-Output "    $z FFmpeg finishes."|out-file $zdrive\downloads\documents\4txtDailyLog.txt -append ;
    write "
    All instances of FFmpeg have finished. Have all files finished being written to flash drive?
    " ;
    #    END WAIT FOR WRITING TO FLASH DRIVE TO FINISH
    
    # BEGIN TIME IT TOOK FFMPEG TO PROCESS, COUNT AND FILE SIZE TO LOG
    $zprocess = (get-date) - $zprocess ;
    [math]::ceiling(($zprocess.totalseconds))|out-file "$zdrive\downloads\documents\4txtFFmpegLastTimeTook.txt" ;
    # how to run a command in Write-Output 
    Write-Output "    FFmpeg took: $($zprocess.minutes) minutes and $($zprocess.seconds) seconds." | out-file $zdrive\downloads\documents\4txtDailyLog.txt -append ;
    $z=gci $zdrive\downloads\radio|measure -property length -sum ;
    Write-output "    $($z.Count) streams for $(FileSize $z.Sum)" | out-file "$zdrive\downloads\documents\4txtDailyLog.txt" -append ;
    #    END TIME IT TOOK FFMPEG TO PROCESS, COUNT AND FILE SIZE TO LOG
    
    # BEGIN REVERSE APPEND PERMANENT LOGFILE
    Write-Output "
    Reverse append logfile." ; 
    (gc $zdrive\downloads\documents\4txtDailyLog.txt , $zdrive\downloads\documents\4txtPermanentLog.txt) | sc $zdrive\downloads\documents\4txtPermanentLog.txt ; 
    Write-Output " " ; # double space between Write-Output and Stop-Transcript in 4.txt.transcript.txt
                         
    #    END REVERSE APPEND PERMANENT LOGFILE
    
    Stop-Transcript | out-null ;
    #    END START TRANSCRIPT
    
    # BEGIN REVERSE APPEND PERMANENT TRANSCRIPT
    Write-Output "
    Reverse append transcript." ; 
    (gc $zdrive\downloads\4.txt.transcript.txt , $zdrive\downloads\padding.txt , $zdrive\downloads\4.txt.log2.txt) | sc $zdrive\downloads\4.txt.log2.txt ; 
    Write-Output " " ; 
    #    END REVERSE APPEND PERMANENT TRANSCRIPT
    
    # BEGIN CLEAN UP
    stop-process -name cmd -ErrorAction SilentlyContinue ;
    # Remove-Variable -name zdebug -ErrorAction SilentlyContinue;
    # Clear-Item variable:zdebug -ErrorAction SilentlyContinue;
    $z57 | remove-job -force ; # Kill $zblock2: KEEP PC AWAKE / UNLOCKED.
    # if(test-path "$env:temp\tmp.txt"){ ri "$env:temp\tmp.txt" } ;
    # if(test-path "$env:userprofile\downloads\$ztimestamp1"){ ri "$env:userprofile\downloads\$ztimestamp1" -force -recurse } ;
                                                           
    #    END CLEAN UP
    
    explorer $zdrive\downloads\radio\ ; 
    POPD ; 
    
    EXIT ;
    }
    #    END Store script block in variable
    
    
    
    
    
    
    
    
    
    
    # BEGIN Kill every instance of wget, curl, ffmpeg and streamripper w/o asking.
    stop-process -name wget -ErrorAction SilentlyContinue ;
    stop-process -name curl -ErrorAction SilentlyContinue ;
    stop-process -name ffmpeg -ErrorAction SilentlyContinue ;
    stop-process -name streamripper -ErrorAction SilentlyContinue ;
    #    END Kill every instance of wget, curl, ffmpeg and streamripper w/o asking.
    
    # BEGIN define functions
    Function FileSize() {[cmdletbinding()]Param ([long]$Type);If ($Type -ge 1TB) {[string]::Format("{0:0.00} TB", $Type / 1TB)}ElseIf ($Type -ge 1GB) {[string]::Format("{0:0.00} GB", $Type / 1GB)}ElseIf ($Type -ge 1MB) {[string]::Format("{0:0.00} MB", $Type / 1MB)}ElseIf ($Type -ge 1KB) {[string]::Format("{0:0.00} KB", $Type / 1KB)}ElseIf ($Type -gt 0) {[string]::Format("{0:0.00} Bytes", $Type)}}; <# End of function #>
    #   END define functions
    
    # BEGIN Flash drive letter to variable i.e. K:
    $z=@('D:','E:','F:','G:','H:','i:','J:','K:','L:','M:','N:','O:','P:','Q:','R:','S:','T:','U:','V:','W:','X:','Y:','Z:') ;  
    $z|foreach-object{if(test-path $_'\DoNotDeleteFlash4291phIr_Wn.txt'){$zdrive="$_"}} ;
    # $zdrive2=$zdrive.trim(':') ; # REMOVE COLON
    #   END Flash drive letter to variable i.e. K:
    
    # BEGIN Create shortcut to this file for 23 drive letter one time. 
    # Target: powershell.exe $z=Get-Date -f 'ddhhmmss'; copy $zMyCommandName $zMyCommandName.`$z.txt; gc $zMyCommandName|powershell
    # Start in: flashdrive:\downloads 
    # Run: Minimized
    IF(!(test-path "$zdrive\Downloads\4.txt(Z).lnk")) {
    $zMyCommandName=$myinvocation.mycommand.name ; # scripts not prohibited
    $zMyCommandName='4.txt' ; # scripts prohibited
    $z=@('D:','E:','F:','G:','H:','i:','J:','K:','L:','M:','N:','O:','P:','Q:','R:','S:','T:','U:','V:','W:','X:','Y:','Z:') ;  
    $z|foreach-object{
    $z=$_.trim(':');
    $SourceFileLocation = "$env:systemroot\System32\WindowsPowerShell\v1.0\powershell.exe" ;
    $ShortcutLocation = "$zdrive\downloads\$zMyCommandName($z).lnk" ;
    $WScriptShell = New-Object -ComObject WScript.Shell ;
    $Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation) ;
    $shortcut.WindowStyle="7" ;
    $shortcut.WorkingDirectory="$_\downloads" ;
    $Shortcut.TargetPath = "$SourceFileLocation" ;
    $Shortcut.IconLocation = "$env:systemroot\System32\WindowsPowerShell\v1.0\powershell.exe,0" ;
    $Shortcut.Arguments = "`$z=Get-Date -f 'ddhhmmss'; copy $zMyCommandName $zMyCommandName.`$z.txt; gc $zMyCommandName|powershell" ;
    $shortcut;
    $shortcut.Save();
    }
    }
    #   END Create shortcut to this file for 23 drive letter one time.
    
    # BEGIN Create timestamp / directory / file
    $ztimestamp0=Get-Date ;
    $ztimestamp1=Get-Date -f  'ddhhmmss' ;
    IF(!(test-path "$zdrive\Downloads\documents")) {ni -ItemType Directory "$zdrive\Downloads\documents" > $null} ;
    IF(!(test-path "$zdrive\Downloads\radio")) {ni -ItemType Directory "$zdrive\Downloads\radio" > $null} ;
    IF(!(test-path "$zdrive\Downloads\DoNotDelete")) {ni -ItemType Directory "$zdrive\Downloads\DoNotDelete" > $null} ;
    IF(!(test-path "$env:userprofile\downloads\$ztimestamp1")) {ni -ItemType Directory "$env:userprofile\downloads\$ztimestamp1" > $null} ;
    IF(![System.IO.File]::Exists("$zdrive\downloads\documents\4txtFFmpegLastTimeTook.txt")) {ni -Path "$zdrive\downloads\documents\" -Name "4txtFFmpegLastTimeTook.txt" -ItemType "file" -Value "100" > $null } ;
    $zseconds|out-file "$zdrive\downloads\DoNotDelete\6.ps1.DoNotDelete.txt" ; # used by flashdrive:\downloads\6.ps1     Keep PC Awake
    #    END Create directory / file 
    
    # BEGIN Possible script prohibited triggers
    
    
    #    END Possible script prohibited triggers   
    
    # BEGIN WINDOW TITLE
    # $MyInvocation does not work with get-content piped to powershell
    # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables
    $host.ui.rawui.WindowTitle ="This is 4.txt     Recording for $($zseconds/60) minutes.     Recording stop $((get-date $ztimestamp0.AddSeconds($zseconds) -f 'hh:mm:sstt') -replace ' ','')      Processing stop ~$((get-date $ztimestamp0.AddSeconds($zseconds+(gc $zdrive\downloads\documents\4txtFFmpegLastTimeTook.txt)) -f 'hh:mm:sstt') -replace ' ','')      This is $zdrive\downloads\4.txt" ;
    #   END WINDOW TITLE
    
    # CREATE SHORTCUTS
    & "$zdrive\downloads\xxmklink" $zdrive\downloads\ffmpeg.exe.lnk "$zdrive\downloads\ffmpeg.exe" `"`" "$zdrive\downloads" `"`" "7" `"`" ;
    & "$zdrive\downloads\xxmklink" $zdrive\downloads\wget.exe.lnk "$zdrive\downloads\wget.exe" `"`" "$zdrive\downloads" `"`" "7" `"`" ;
    & "$zdrive\downloads\xxmklink" $zdrive\downloads\curl.exe.lnk "$zdrive\downloads\curl.exe" `"`" "$zdrive\downloads" `"`" "7" `"`" ;
    & "$zdrive\downloads\xxmklink" $zdrive\downloads\streamripper\streamripper.exe.lnk "$zdrive\downloads\streamripper\streamripper.exe" `"`" "$zdrive\downloads\streamripper" `"`" "7" `"`" ;
    # BEGIN works. I have not found a use for it yet
    # & "$zdrive\downloads\xxmklink" $zdrive\downloads\6.ps1`($zdrive2`)KeepAwake.lnk "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe $z=Get-Date -f 'ddhhmmss'; copy 6.ps1 6.ps1.$z.txt; gc 6.ps1|powershell" `"`" "$zdrive\downloads" `"`" "7" `"`" ;
    #    END works. I have not found a use for it yet
    
    # Initialize 4txtDailyLog.txt
    Write-Output "$((Get-Date -f 'ddd MM/dd/yy')) $(((Get-Date -f 'hh:mm:sstt') -replace ' ',''))
    This is $env:userprofile on $env:computername running $zdrive\downloads\4.txt
    Capturing audio streams with ffmpeg, wget, curl and streamripper.
    Recording for $($zseconds/60) minutes.
    Recording will end around $((get-date $ztimestamp0.AddSeconds($zseconds) -f 'hh:mm:sstt') -replace ' ','') 
    Processing will end around $((get-date $ztimestamp0.AddSeconds($zseconds+(gc $zdrive\downloads\documents\4txtFFmpegLastTimeTook.txt)) -f hh:mm:sstt) -replace ' ','')"|out-file $zdrive\downloads\documents\4txtDailyLog.txt ;
    
     # BEGIN MINIMIZE ALL WINDOWS minimize window
    ((New-Object -ComObject Shell.Application).MinimizeAll()) ;
    #   END MINIMIZE ALL WINDOWS minimize window                 
    
    # BEGIN KEEP PC AWAKE / UNLOCKED. Sleep, move mouse, write-host, SendKeys.
    $zblock2={
    $myshell = New-Object -com "Wscript.Shell" ;
    while ($true)
    {
    Start-Sleep -s (Get-Random -Maximum 5 -Minimum 1) ;
    $Pos = [System.Windows.Forms.Cursor]::Position ;
    [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) + 1) , $Pos.Y) ;
    $Pos = [System.Windows.Forms.Cursor]::Position ;
    [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) - 1) , $Pos.Y) ;
    $word = -join ((65..90) + (97..122) | Get-Random -Count (Get-Random -Maximum 8 -Minimum 5) | % {[char]$_})
    Write-Host "$word" ;
    $myshell.sendkeys(".") ;
    } ;
    } ; # END ZBLOCK2
    
    $z57=start-job -scriptblock $zblock2 ; 
    # write-output "The job parameter id is $($z57.id)";
    # $z57|wait-job ;
    # $z57|stop-job ;
    # $z57|remove-job -force ;
    
    #    END KEEP PC AWAKE / UNLOCKED. Sleep, move mouse, write-host, SendKeys.
    
    
    # BEGIN START TRANSCRIPT
    $ErrorActionPreference="SilentlyContinue" ;
    Stop-Transcript | out-null ;
    $ErrorActionPreference = "Continue" ;
    Start-Transcript -path $zdrive\downloads\4.txt.transcript.txt ;
    Write-Output "See 4txtDailyLog.txt and 4txtPermanentLog.txt" ;
    #    END START TRANSCRIPT    
      
    # Invoke script: Start capturing streams with ffmpeg, wget, curl, streamripper, and ....
    & $zblock ; 
    
    # a blank line must follow '& $zblock' 
    
    • 0

相关问题

  • 如何创建脚本来监听内容变化并一直接触父文件夹?

  • 在不删除任何文件的情况下重置 Windows 安装的命令是什么

  • 最低比特率 ffmpeg 输出的编解码器和设置

  • Windows 2016 不会运行 .bat 文件

  • 索尼WH-1000XMX2蓝牙耳机无法自动正确连接

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve