youtube-dl 如何使用所有可能的文件名调用 PowerShell 脚本

youtube-dl 如何使用所有可能的文件名调用 PowerShell 脚本

我编写了一个 PowerShell 脚本来对通过 youtube-dl 下载的音频进行一些后期处理,并尝试使用该--exec标志自动调用它。问题是我不知道如何正确地执行此操作,以便它适用于所有可能的文件名。

'适用于包含或的视频标题以外的命令()

PS > youtube-dl -i -f bestaudio --exec 'powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "{}"' https://youtu.be/zRunkRiylvM
[youtube] zRunkRiylvM: Downloading webpage
[youtube] zRunkRiylvM: Downloading video info webpage
[download] Dream Big, Princess – Live Your Story (Official Lyric Video) _ Disney-zRunkRiylvM.webm has already been downloaded
[download] 100% of 3.14MiB
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "Dream Big, Princess – Live Your Story (Official Lyric Video) _ Disney-zRunkRiylvM.webm"
Official : The term 'Official' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:78
+ ... Normalize.ps1 Dream Big, Princess – Live Your Story (Official Lyric V ...
+                                                          ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Official:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

ERROR: Command returned error code 1

PS > youtube-dl -i -f bestaudio --exec 'powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "{}"' https://youtu.be/tTuwo_TqlhQ
[youtube] tTuwo_TqlhQ: Downloading webpage
[youtube] tTuwo_TqlhQ: Downloading video info webpage
[download] Destination: Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a
[download] 100% of 3.05MiB in 00:00
[ffmpeg] Correcting container in "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
The string is missing the terminator: '.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

ERROR: Command returned error code 1

'并且仅对标题中包含以下内容的视频中断的命令:

PS > youtube-dl -i -f bestaudio --exec "powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 '{}'" https://youtu.be/tTuwo_TqlhQ
[youtube] tTuwo_TqlhQ: Downloading webpage
[youtube] tTuwo_TqlhQ: Downloading video info webpage
[download] Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a has already been downloaded
[download] 100% of 3.05MiB
[ffmpeg] Correcting container in "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 '"Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"'
The string is missing the terminator: '.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

ERROR: Command returned error code 1

我怎样才能让它与这些以及其他我可能错过的边缘情况一起工作?

答案1

使用-Filepowershell 的标志有效:

youtube-dl -i -f bestaudio --exec 'powershell -ExecutionPolicy RemoteSigned -File D:\PowerShell\ConvertAndNormalize.ps1 "{}"' https://www.youtube.com/playlist?list=PLpSnlSGciSWPBUsHQKmXGX3TB-FTSO0U6

相关内容